Search in sources :

Example 86 with PropertyKey

use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.

the class PropertyKeyCoreTest method testCreateTime.

@Test
public void testCreateTime() {
    SchemaManager schema = graph().schema();
    PropertyKey id = schema.propertyKey("id").asText().valueSingle().create();
    Date createTime = (Date) id.userdata().get(Userdata.CREATE_TIME);
    Date now = DateUtil.now();
    Assert.assertFalse(createTime.after(now));
    id = schema.getPropertyKey("id");
    createTime = (Date) id.userdata().get(Userdata.CREATE_TIME);
    Assert.assertFalse(createTime.after(now));
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Date(java.util.Date) Test(org.junit.Test)

Example 87 with PropertyKey

use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.

the class PropertyKeyCoreTest method testAddPropertyKeyWithoutDataType.

@Test
public void testAddPropertyKeyWithoutDataType() {
    SchemaManager schema = graph().schema();
    PropertyKey id = schema.propertyKey("id").valueSingle().create();
    Assert.assertEquals(DataType.TEXT, id.dataType());
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Test(org.junit.Test)

Example 88 with PropertyKey

use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.

the class PropertyKeyCoreTest method testAppendPropertyKeyWithUserdata.

@Test
public void testAppendPropertyKeyWithUserdata() {
    SchemaManager schema = graph().schema();
    PropertyKey age = schema.propertyKey("age").userdata("min", 0).create();
    Assert.assertEquals(2, age.userdata().size());
    Assert.assertEquals(0, age.userdata().get("min"));
    age = schema.propertyKey("age").userdata("min", 1).userdata("max", 100).append();
    Assert.assertEquals(3, age.userdata().size());
    Assert.assertEquals(1, age.userdata().get("min"));
    Assert.assertEquals(100, age.userdata().get("max"));
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Test(org.junit.Test)

Example 89 with PropertyKey

use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.

the class PropertyKeyCoreTest method testAddPropertyKeyWithoutCardinality.

@Test
public void testAddPropertyKeyWithoutCardinality() {
    SchemaManager schema = graph().schema();
    PropertyKey id = schema.propertyKey("id").asText().create();
    Assert.assertEquals(Cardinality.SINGLE, id.cardinality());
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Test(org.junit.Test)

Example 90 with PropertyKey

use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.

the class PropertyKeyCoreTest method testAddPropertyKeyWithoutDataTypeAndCardinality.

@Test
public void testAddPropertyKeyWithoutDataTypeAndCardinality() {
    SchemaManager schema = graph().schema();
    PropertyKey id = schema.propertyKey("id").create();
    Assert.assertEquals(DataType.TEXT, id.dataType());
    Assert.assertEquals(Cardinality.SINGLE, id.cardinality());
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Test(org.junit.Test)

Aggregations

PropertyKey (com.baidu.hugegraph.schema.PropertyKey)94 Id (com.baidu.hugegraph.backend.id.Id)31 Test (org.junit.Test)24 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)20 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)15 HugeGraph (com.baidu.hugegraph.HugeGraph)13 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)11 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)9 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)9 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)9 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)7 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)7 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)6 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)6 DataType (com.baidu.hugegraph.type.define.DataType)6 Map (java.util.Map)6 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)5 Timed (com.codahale.metrics.annotation.Timed)5 RolesAllowed (jakarta.annotation.security.RolesAllowed)5 Collection (java.util.Collection)5