use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateWithTtl.
@Test
public void testCreateWithTtl() {
VertexLabel vertexLabel = schema().vertexLabel("person1").useAutomaticId().properties("name", "age", "date").build();
vertexLabel = vertexLabelAPI.create(vertexLabel);
Assert.assertEquals("person1", vertexLabel.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
Assert.assertEquals(true, vertexLabel.enableLabelIndex());
Set<String> props = ImmutableSet.of("name", "age", "date");
Assert.assertEquals(props, vertexLabel.properties());
Assert.assertEquals(0L, vertexLabel.ttl());
Assert.assertNull(vertexLabel.ttlStartTime());
vertexLabel = schema().vertexLabel("person2").useAutomaticId().properties("name", "age", "date").ttl(3000L).build();
vertexLabel = vertexLabelAPI.create(vertexLabel);
Assert.assertEquals("person2", vertexLabel.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
Assert.assertEquals(true, vertexLabel.enableLabelIndex());
Assert.assertEquals(props, vertexLabel.properties());
Assert.assertEquals(3000L, vertexLabel.ttl());
Assert.assertNull(vertexLabel.ttlStartTime());
vertexLabel = schema().vertexLabel("person3").useAutomaticId().properties("name", "age", "date").ttl(3000L).ttlStartTime("date").build();
vertexLabel = vertexLabelAPI.create(vertexLabel);
Assert.assertEquals("person3", vertexLabel.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
Assert.assertEquals(true, vertexLabel.enableLabelIndex());
Assert.assertEquals(props, vertexLabel.properties());
Assert.assertEquals(3000L, vertexLabel.ttl());
Assert.assertEquals("date", vertexLabel.ttlStartTime());
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testListByNames.
@Test
public void testListByNames() {
VertexLabel person = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
person = vertexLabelAPI.create(person);
VertexLabel software = schema().vertexLabel("software").useCustomizeStringId().properties("name", "lang", "price").build();
software = vertexLabelAPI.create(software);
List<VertexLabel> vertexLabels;
vertexLabels = vertexLabelAPI.list(ImmutableList.of("person"));
Assert.assertEquals(1, vertexLabels.size());
assertContains(vertexLabels, person);
vertexLabels = vertexLabelAPI.list(ImmutableList.of("software"));
Assert.assertEquals(1, vertexLabels.size());
assertContains(vertexLabels, software);
vertexLabels = vertexLabelAPI.list(ImmutableList.of("person", "software"));
Assert.assertEquals(2, vertexLabels.size());
assertContains(vertexLabels, person);
assertContains(vertexLabels, software);
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testAppendWithUndefinedPropertyKey.
@Test
public void testAppendWithUndefinedPropertyKey() {
VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age").build();
vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
Assert.assertEquals("person", vertexLabel1.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel1.idStrategy());
Set<String> props = ImmutableSet.of("name", "age");
Assert.assertEquals(props, vertexLabel1.properties());
VertexLabel vertexLabel2 = schema().vertexLabel("person").properties("undefined").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.append(vertexLabel2);
});
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreate.
@Test
public void testCreate() {
VertexLabel vertexLabel = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
vertexLabel = vertexLabelAPI.create(vertexLabel);
Assert.assertEquals("person", vertexLabel.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
Assert.assertEquals(true, vertexLabel.enableLabelIndex());
Set<String> props = ImmutableSet.of("name", "age", "city");
Assert.assertEquals(props, vertexLabel.properties());
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateWithNonNullKeysIntersectPrimaryKeys.
@Test
public void testCreateWithNonNullKeysIntersectPrimaryKeys() {
VertexLabel vertexLabel1 = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("name").nullableKeys("name").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(vertexLabel1);
});
VertexLabel vertexLabel2 = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("name", "age").nullableKeys("name").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(vertexLabel2);
});
VertexLabel vertexLabel3 = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("name").nullableKeys("name", "age").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(vertexLabel3);
});
}
Aggregations