Search in sources :

Example 1 with EntityReadOperations

use of org.neo4j.kernel.impl.api.operations.EntityReadOperations in project neo4j by neo4j.

the class NodeSchemaMatcherTest method setup.

@Before
public void setup() {
    state = mock(KernelStatement.class);
    PrimitiveIntSet labels = Primitive.intSet();
    labels.add(labelId1);
    Cursor<NodeItem> nodeItemCursor = StubCursors.asNodeCursor(0, labels);
    nodeItemCursor.next();
    node = nodeItemCursor.get();
    PrimitiveIntSet defaultPropertyIds = PrimitiveIntCollections.asSet(new int[] { propId1, propId2, unIndexedPropId });
    EntityReadOperations readOps = mock(EntityReadOperations.class);
    when(readOps.nodeGetPropertyKeys(state, node)).thenReturn(defaultPropertyIds);
    when(readOps.nodeGetProperty(state, node, propId1)).thenReturn("hi1");
    when(readOps.nodeGetProperty(state, node, propId2)).thenReturn("hi2");
    when(readOps.nodeGetProperty(state, node, unIndexedPropId)).thenReturn("hi3");
    nodeSchemaMatcher = new NodeSchemaMatcher<>(readOps);
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) PrimitiveIntSet(org.neo4j.collection.primitive.PrimitiveIntSet) EntityReadOperations(org.neo4j.kernel.impl.api.operations.EntityReadOperations) Before(org.junit.Before)

Example 2 with EntityReadOperations

use of org.neo4j.kernel.impl.api.operations.EntityReadOperations in project neo4j by neo4j.

the class IndexTxStateUpdaterTest method setup.

@Before
public void setup() {
    state = mock(KernelStatement.class);
    txState = mock(TransactionState.class);
    when(state.txState()).thenReturn(txState);
    SchemaReadOperations schemaReadOps = mock(SchemaReadOperations.class);
    when(schemaReadOps.indexesGetAll(state)).thenAnswer(x -> filter(GENERAL, indexes.iterator()));
    when(schemaReadOps.uniqueIndexesGetAll(state)).thenAnswer(x -> filter(UNIQUE, indexes.iterator()));
    when(schemaReadOps.indexesGetForLabel(state, labelId1)).thenAnswer(x -> filter(GENERAL, filter(hasLabel(labelId1), indexes.iterator())));
    when(schemaReadOps.uniqueIndexesGetForLabel(state, labelId1)).thenAnswer(x -> filter(UNIQUE, filter(hasLabel(labelId1), indexes.iterator())));
    when(schemaReadOps.indexesGetForLabel(state, labelId2)).thenAnswer(x -> filter(GENERAL, filter(hasLabel(labelId2), indexes.iterator())));
    when(schemaReadOps.uniqueIndexesGetForLabel(state, labelId2)).thenAnswer(x -> filter(UNIQUE, filter(hasLabel(labelId2), indexes.iterator())));
    PrimitiveIntSet labels = Primitive.intSet();
    labels.add(labelId1);
    labels.add(labelId2);
    Cursor<NodeItem> nodeItemCursor = StubCursors.asNodeCursor(0, labels);
    nodeItemCursor.next();
    node = nodeItemCursor.get();
    PrimitiveIntSet defaultPropertyIds = PrimitiveIntCollections.asSet(new int[] { propId1, propId2, propId3 });
    EntityReadOperations readOps = mock(EntityReadOperations.class);
    when(readOps.nodeGetPropertyKeys(state, node)).thenReturn(defaultPropertyIds);
    when(readOps.nodeGetProperties(state, node)).thenAnswer(p -> StubCursors.asPropertyCursor(Property.property(propId1, "hi1"), Property.property(propId2, "hi2"), Property.property(propId3, "hi3")));
    when(readOps.nodeGetProperty(state, node, propId1)).thenReturn("hi1");
    when(readOps.nodeGetProperty(state, node, propId2)).thenReturn("hi2");
    when(readOps.nodeGetProperty(state, node, propId3)).thenReturn("hi3");
    indexTxUpdater = new IndexTxStateUpdater(schemaReadOps, readOps);
}
Also used : TransactionState(org.neo4j.kernel.api.txstate.TransactionState) NodeItem(org.neo4j.storageengine.api.NodeItem) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) SchemaReadOperations(org.neo4j.kernel.impl.api.operations.SchemaReadOperations) PrimitiveIntSet(org.neo4j.collection.primitive.PrimitiveIntSet) EntityReadOperations(org.neo4j.kernel.impl.api.operations.EntityReadOperations) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 PrimitiveIntSet (org.neo4j.collection.primitive.PrimitiveIntSet)2 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)2 EntityReadOperations (org.neo4j.kernel.impl.api.operations.EntityReadOperations)2 NodeItem (org.neo4j.storageengine.api.NodeItem)2 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)1 SchemaReadOperations (org.neo4j.kernel.impl.api.operations.SchemaReadOperations)1