in computer-test/src/main/java/org/apache/hugegraph/computer/core/io/CsvStructGraphOutputTest.java [115:162]
public void testWriteReadVertexWithProperties() throws IOException {
UnitTestBase.updateOptions(
ComputerOptions.OUTPUT_WITH_ADJACENT_EDGES, "false",
ComputerOptions.OUTPUT_WITH_VERTEX_PROPERTIES, "true",
ComputerOptions.OUTPUT_WITH_EDGE_PROPERTIES, "false"
);
ComputerContext context = context();
GraphFactory factory = context.graphFactory();
Id longId = BytesId.of(100L);
IdListList idListList = new IdListList();
IdList idList1 = new IdList();
idList1.add(BytesId.of(66L));
IdList idList2 = new IdList();
idList2.add(BytesId.of(998L));
idList2.add(BytesId.of(999L));
idListList.add(idList1);
idListList.add(idList2);
Vertex vertex = factory.createVertex(longId, idListList);
vertex.properties().put("boolean", new BooleanValue(true));
vertex.properties().put("byte", new IntValue(127));
vertex.properties().put("short", new IntValue(16383));
vertex.properties().put("int", new IntValue(1000000));
vertex.properties().put("long", new LongValue(10000000000L));
vertex.properties().put("float", new FloatValue(0.1F));
vertex.properties().put("double", new DoubleValue(-0.01D));
vertex.properties().put("idvalue", longId);
String fileName = "output3.csv";
File file = new File(fileName);
try {
BufferedFileOutput dos = new BufferedFileOutput(file);
StructGraphOutput output = (StructGraphOutput)
IOFactory.createGraphOutput(
context, OutputFormat.CSV, dos);
output.writeVertex(vertex);
dos.close();
@SuppressWarnings("deprecation")
String text = FileUtils.readFileToString(file);
Assert.assertEquals("100,[[66],[998,999]],{true,127,-0.01,16383," +
"100,0.1,1000000,10000000000}" +
System.lineSeparator(), text);
} finally {
FileUtils.deleteQuietly(file);
}
}