use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.
the class PathValueBuilderTest method builder.
private static PathValueBuilder builder(AnyValue... values) {
DbAccess dbAccess = mock(DbAccess.class);
RelationshipScanCursor cursors = mock(RelationshipScanCursor.class);
Map<Long, RelationshipValue> relMap = new HashMap<>();
for (AnyValue value : values) {
if (value instanceof NodeValue) {
NodeValue nodeValue = (NodeValue) value;
when(dbAccess.nodeById(nodeValue.id())).thenReturn(nodeValue);
} else if (value instanceof RelationshipValue) {
RelationshipValue relationshipValue = (RelationshipValue) value;
relMap.put(relationshipValue.id(), relationshipValue);
} else {
throw new AssertionError("invalid input");
}
Mockito.doAnswer((Answer<Void>) invocationOnMock -> {
long id = invocationOnMock.getArgument(0);
RelationshipScanCursor cursor = invocationOnMock.getArgument(1);
RelationshipValue rel = relMap.get(id);
when(cursor.sourceNodeReference()).thenReturn(rel.startNode().id());
when(cursor.targetNodeReference()).thenReturn(rel.endNode().id());
return null;
}).when(dbAccess).singleRelationship(anyLong(), any(RelationshipScanCursor.class));
}
return new PathValueBuilder(dbAccess, cursors);
}
Aggregations