Search in sources :

Example 1 with RecordCursor

use of org.neo4j.kernel.impl.store.RecordCursor in project neo4j by neo4j.

the class MockedNeoStores method basicMockedNeoStores.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static NeoStores basicMockedNeoStores() {
    NeoStores neoStores = mock(NeoStores.class);
    // Cursor, absolutely mocked and cannot be used at all as it is
    RecordCursor cursor = mockedRecordCursor();
    // NodeStore - DynamicLabelStore
    NodeStore nodeStore = mock(NodeStore.class);
    when(nodeStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    // NodeStore - DynamicLabelStore
    DynamicArrayStore dynamicLabelStore = mock(DynamicArrayStore.class);
    when(dynamicLabelStore.newRecordCursor(any())).thenReturn(cursor);
    when(nodeStore.getDynamicLabelStore()).thenReturn(dynamicLabelStore);
    // RelationshipStore
    RelationshipStore relationshipStore = mock(RelationshipStore.class);
    when(relationshipStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getRelationshipStore()).thenReturn(relationshipStore);
    // RelationshipGroupStore
    RelationshipGroupStore relationshipGroupStore = mock(RelationshipGroupStore.class);
    when(relationshipGroupStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getRelationshipGroupStore()).thenReturn(relationshipGroupStore);
    // PropertyStore
    PropertyStore propertyStore = mock(PropertyStore.class);
    when(propertyStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getPropertyStore()).thenReturn(propertyStore);
    // PropertyStore -- DynamicStringStore
    DynamicStringStore propertyStringStore = mock(DynamicStringStore.class);
    when(propertyStringStore.newRecordCursor(any())).thenReturn(cursor);
    when(propertyStore.getStringStore()).thenReturn(propertyStringStore);
    // PropertyStore -- DynamicArrayStore
    DynamicArrayStore propertyArrayStore = mock(DynamicArrayStore.class);
    when(propertyArrayStore.newRecordCursor(any())).thenReturn(cursor);
    when(propertyStore.getArrayStore()).thenReturn(propertyArrayStore);
    return neoStores;
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) NodeStore(org.neo4j.kernel.impl.store.NodeStore) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) DynamicArrayStore(org.neo4j.kernel.impl.store.DynamicArrayStore) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore)

Example 2 with RecordCursor

use of org.neo4j.kernel.impl.store.RecordCursor in project neo4j by neo4j.

the class StoreIteratorRelationshipCursorTest method retrieveUnusedRelationship.

@Test
public void retrieveUnusedRelationship() {
    final RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
    RecordCursor recordCursor = mock(RecordCursor.class);
    RelationshipStore relationshipStore = getRelationshipStore(relationshipRecord, recordCursor);
    when(recordCursor.next(RELATIONSHIP_ID, relationshipRecord, RecordLoad.CHECK)).thenAnswer(new RelationshipAnswer(relationshipRecord, false));
    try (StoreIteratorRelationshipCursor cursor = createRelationshipCursor(relationshipRecord, relationshipStore)) {
        cursor.init(PrimitiveLongCollections.iterator(RELATIONSHIP_ID));
        assertTrue(cursor.next());
        assertEquals(RELATIONSHIP_ID, cursor.get().id());
    }
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) Test(org.junit.Test)

Example 3 with RecordCursor

use of org.neo4j.kernel.impl.store.RecordCursor in project neo4j by neo4j.

the class StoreIteratorRelationshipCursorTest method retrieveUsedRelationship.

@Test
public void retrieveUsedRelationship() throws Exception {
    final RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
    RecordCursor recordCursor = mock(RecordCursor.class);
    RelationshipStore relationshipStore = getRelationshipStore(relationshipRecord, recordCursor);
    when(recordCursor.next(RELATIONSHIP_ID, relationshipRecord, RecordLoad.CHECK)).thenAnswer(new RelationshipAnswer(relationshipRecord, true));
    try (StoreIteratorRelationshipCursor cursor = createRelationshipCursor(relationshipRecord, relationshipStore)) {
        cursor.init(PrimitiveLongCollections.iterator(RELATIONSHIP_ID));
        assertTrue(cursor.next());
        assertEquals(RELATIONSHIP_ID, cursor.get().id());
    }
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) Test(org.junit.Test)

Aggregations

RecordCursor (org.neo4j.kernel.impl.store.RecordCursor)3 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)3 Test (org.junit.Test)2 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)2 DynamicArrayStore (org.neo4j.kernel.impl.store.DynamicArrayStore)1 DynamicStringStore (org.neo4j.kernel.impl.store.DynamicStringStore)1 NeoStores (org.neo4j.kernel.impl.store.NeoStores)1 NodeStore (org.neo4j.kernel.impl.store.NodeStore)1 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)1 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)1