use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class JsonUtilTest method testSerializeVertexLabel.
@Test
public void testSerializeVertexLabel() {
FakeObjects fakeObject = new FakeObjects();
PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name");
PropertyKey age = fakeObject.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, Cardinality.SINGLE);
PropertyKey city = fakeObject.newPropertyKey(IdGenerator.of(3), "city");
VertexLabel vl = fakeObject.newVertexLabel(IdGenerator.of(1), "person", IdStrategy.CUSTOMIZE_NUMBER, name.id(), age.id(), city.id());
Mockito.when(fakeObject.graph().mapPkId2Name(vl.properties())).thenReturn(Arrays.asList(name.name(), age.name(), city.name()));
String json = JsonUtil.toJson(vl);
Assert.assertEquals("{\"id\":1,\"name\":\"person\"," + "\"id_strategy\":\"CUSTOMIZE_NUMBER\"," + "\"primary_keys\":[],\"nullable_keys\":[]," + "\"index_labels\":[]," + "\"properties\":[\"name\",\"age\",\"city\"]," + "\"status\":\"CREATED\"," + "\"ttl\":0,\"enable_label_index\":true," + "\"user_data\":{}}", json);
}
Aggregations