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;
}
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());
}
}
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());
}
}
Aggregations