Search in sources :

Example 1 with DefaultSchemaMaker

use of org.janusgraph.core.schema.DefaultSchemaMaker in project janusgraph by JanusGraph.

the class JanusGraphDefaultSchemaMakerTest method testMakePropertyKey.

@Test
public void testMakePropertyKey() {
    PropertyKeyMaker pkm = mockPropertyKeyMaker();
    DefaultSchemaMaker schemaMaker = JanusGraphDefaultSchemaMaker.INSTANCE;
    byte b = 100;
    short s = 10000;
    schemaMaker.makePropertyKey(pkm, "Foo");
    schemaMaker.makePropertyKey(pkm, 'f');
    schemaMaker.makePropertyKey(pkm, true);
    schemaMaker.makePropertyKey(pkm, b);
    schemaMaker.makePropertyKey(pkm, s);
    schemaMaker.makePropertyKey(pkm, 100);
    schemaMaker.makePropertyKey(pkm, 100L);
    schemaMaker.makePropertyKey(pkm, 100.0f);
    schemaMaker.makePropertyKey(pkm, 1.23e2);
    schemaMaker.makePropertyKey(pkm, new Date());
    schemaMaker.makePropertyKey(pkm, Geoshape.point(42.3601f, 71.0589f));
    schemaMaker.makePropertyKey(pkm, UUID.randomUUID());
    schemaMaker.makePropertyKey(pkm, new Object());
    verifyAll();
}
Also used : PropertyKeyMaker(org.janusgraph.core.schema.PropertyKeyMaker) DefaultSchemaMaker(org.janusgraph.core.schema.DefaultSchemaMaker) Date(java.util.Date) Test(org.junit.Test)

Example 2 with DefaultSchemaMaker

use of org.janusgraph.core.schema.DefaultSchemaMaker in project janusgraph by JanusGraph.

the class StandardJanusGraphTxTest method createTxWithMockedInternals.

private StandardJanusGraphTx createTxWithMockedInternals() {
    StandardJanusGraph mockGraph = createMock(StandardJanusGraph.class);
    TransactionConfiguration txConfig = createMock(TransactionConfiguration.class);
    GraphDatabaseConfiguration gdbConfig = createMock(GraphDatabaseConfiguration.class);
    TimestampProvider tsProvider = createMock(TimestampProvider.class);
    Serializer mockSerializer = createMock(Serializer.class);
    EdgeSerializer mockEdgeSerializer = createMock(EdgeSerializer.class);
    IndexSerializer mockIndexSerializer = createMock(IndexSerializer.class);
    RelationType relationType = createMock(RelationType.class);
    IDManager idManager = createMock(IDManager.class);
    PropertyKey propertyKey = createMock(PropertyKey.class);
    DefaultSchemaMaker defaultSchemaMaker = createMock(DefaultSchemaMaker.class);
    expect(mockGraph.getConfiguration()).andReturn(gdbConfig);
    expect(mockGraph.isOpen()).andReturn(true).anyTimes();
    expect(mockGraph.getDataSerializer()).andReturn(mockSerializer);
    expect(mockGraph.getEdgeSerializer()).andReturn(mockEdgeSerializer);
    expect(mockGraph.getIndexSerializer()).andReturn(mockIndexSerializer);
    expect(mockGraph.getIDManager()).andReturn(idManager);
    expect(gdbConfig.getTimestampProvider()).andReturn(tsProvider);
    expect(txConfig.isSingleThreaded()).andReturn(true);
    expect(txConfig.hasPreloadedData()).andReturn(false);
    expect(txConfig.hasVerifyExternalVertexExistence()).andReturn(false);
    expect(txConfig.hasVerifyInternalVertexExistence()).andReturn(false);
    expect(txConfig.getVertexCacheSize()).andReturn(6);
    expect(txConfig.isReadOnly()).andReturn(true);
    expect(txConfig.getDirtyVertexSize()).andReturn(2);
    expect(txConfig.getIndexCacheWeight()).andReturn(2L);
    expect(txConfig.getGroupName()).andReturn(null);
    expect(txConfig.getAutoSchemaMaker()).andReturn(defaultSchemaMaker);
    expect(defaultSchemaMaker.makePropertyKey(isA(PropertyKeyMaker.class), notNull())).andReturn(propertyKey);
    expect(relationType.isPropertyKey()).andReturn(false);
    expect(propertyKey.isPropertyKey()).andReturn(true);
    replayAll();
    StandardJanusGraphTx partialMock = createMockBuilder(StandardJanusGraphTx.class).withConstructor(mockGraph, txConfig).addMockedMethod("getRelationType").createMock();
    expect(partialMock.getRelationType("Foo")).andReturn(null);
    expect(partialMock.getRelationType("Qux")).andReturn(propertyKey);
    expect(partialMock.getRelationType("Baz")).andReturn(relationType);
    replay(partialMock);
    return partialMock;
}
Also used : IndexSerializer(org.janusgraph.graphdb.database.IndexSerializer) IDManager(org.janusgraph.graphdb.idmanagement.IDManager) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) PropertyKeyMaker(org.janusgraph.core.schema.PropertyKeyMaker) TimestampProvider(org.janusgraph.diskstorage.util.time.TimestampProvider) DefaultSchemaMaker(org.janusgraph.core.schema.DefaultSchemaMaker) RelationType(org.janusgraph.core.RelationType) EdgeSerializer(org.janusgraph.graphdb.database.EdgeSerializer) PropertyKey(org.janusgraph.core.PropertyKey) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) EdgeSerializer(org.janusgraph.graphdb.database.EdgeSerializer) IndexSerializer(org.janusgraph.graphdb.database.IndexSerializer) Serializer(org.janusgraph.graphdb.database.serialize.Serializer)

Aggregations

DefaultSchemaMaker (org.janusgraph.core.schema.DefaultSchemaMaker)2 PropertyKeyMaker (org.janusgraph.core.schema.PropertyKeyMaker)2 Date (java.util.Date)1 PropertyKey (org.janusgraph.core.PropertyKey)1 RelationType (org.janusgraph.core.RelationType)1 TimestampProvider (org.janusgraph.diskstorage.util.time.TimestampProvider)1 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)1 EdgeSerializer (org.janusgraph.graphdb.database.EdgeSerializer)1 IndexSerializer (org.janusgraph.graphdb.database.IndexSerializer)1 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)1 Serializer (org.janusgraph.graphdb.database.serialize.Serializer)1 IDManager (org.janusgraph.graphdb.idmanagement.IDManager)1 Test (org.junit.Test)1