Search in sources :

Example 1 with StubRead

use of org.neo4j.internal.kernel.api.helpers.StubRead in project neo4j by neo4j.

the class OperationsTest method returnRelationships.

public static void returnRelationships(KernelTransactionImplementation ktx, final TestRelationshipChain relIds) {
    StubRead read = new StubRead();
    when(ktx.dataRead()).thenReturn(read);
    StubCursorFactory cursorFactory = new StubCursorFactory(true);
    cursorFactory.withRelationshipTraversalCursors(new StubRelationshipCursor(relIds));
    when(ktx.lockTracer()).thenReturn(NONE);
    when(ktx.cursors()).thenReturn(cursorFactory);
    when(ktx.ambientNodeCursor()).thenAnswer(args -> new StubNodeCursor(false).withNode(42L));
}
Also used : StubNodeCursor(org.neo4j.internal.kernel.api.helpers.StubNodeCursor) StubRead(org.neo4j.internal.kernel.api.helpers.StubRead) StubCursorFactory(org.neo4j.internal.kernel.api.helpers.StubCursorFactory) StubRelationshipCursor(org.neo4j.internal.kernel.api.helpers.StubRelationshipCursor)

Example 2 with StubRead

use of org.neo4j.internal.kernel.api.helpers.StubRead in project neo4j by neo4j.

the class CursorPropertyAccessorTest method shouldLookupProperty.

@Test
void shouldLookupProperty() throws EntityNotFoundException {
    // given
    long nodeId = 10;
    Value value = Values.of("abc");
    int propertyKeyId = 0;
    StubNodeCursor nodeCursor = new StubNodeCursor().withNode(nodeId, new long[] {}, genericMap(999, Values.of(12345), propertyKeyId, value));
    CursorPropertyAccessor accessor = new CursorPropertyAccessor(nodeCursor, new StubPropertyCursor(), new StubRead());
    // when
    Value readValue = accessor.getNodePropertyValue(nodeId, propertyKeyId, NULL);
    // then
    assertEquals(value, readValue);
}
Also used : StubNodeCursor(org.neo4j.internal.kernel.api.helpers.StubNodeCursor) StubRead(org.neo4j.internal.kernel.api.helpers.StubRead) Value(org.neo4j.values.storable.Value) StubPropertyCursor(org.neo4j.internal.kernel.api.helpers.StubPropertyCursor) Test(org.junit.jupiter.api.Test)

Example 3 with StubRead

use of org.neo4j.internal.kernel.api.helpers.StubRead in project neo4j by neo4j.

the class CursorPropertyAccessorTest method shouldReturnNoValueOnMissingProperty.

@Test
void shouldReturnNoValueOnMissingProperty() throws EntityNotFoundException {
    // given
    long nodeId = 10;
    StubNodeCursor nodeCursor = new StubNodeCursor().withNode(nodeId, new long[] {}, genericMap(999, Values.of(12345)));
    CursorPropertyAccessor accessor = new CursorPropertyAccessor(nodeCursor, new StubPropertyCursor(), new StubRead());
    // when
    Value readValue = accessor.getNodePropertyValue(nodeId, 0, NULL);
    // then
    assertEquals(NO_VALUE, readValue);
}
Also used : StubNodeCursor(org.neo4j.internal.kernel.api.helpers.StubNodeCursor) StubRead(org.neo4j.internal.kernel.api.helpers.StubRead) Value(org.neo4j.values.storable.Value) StubPropertyCursor(org.neo4j.internal.kernel.api.helpers.StubPropertyCursor) Test(org.junit.jupiter.api.Test)

Example 4 with StubRead

use of org.neo4j.internal.kernel.api.helpers.StubRead in project neo4j by neo4j.

the class CursorPropertyAccessorTest method shouldThrowOnEntityNotFound.

@Test
void shouldThrowOnEntityNotFound() {
    // given
    long nodeId = 10;
    Value value = Values.of("abc");
    int propertyKeyId = 0;
    StubNodeCursor nodeCursor = new StubNodeCursor().withNode(nodeId, new long[] {}, genericMap(999, Values.of(12345), propertyKeyId, value));
    CursorPropertyAccessor accessor = new CursorPropertyAccessor(nodeCursor, new StubPropertyCursor(), new StubRead());
    // when
    assertThrows(EntityNotFoundException.class, () -> accessor.getNodePropertyValue(nodeId + 1, propertyKeyId, NULL));
}
Also used : StubNodeCursor(org.neo4j.internal.kernel.api.helpers.StubNodeCursor) StubRead(org.neo4j.internal.kernel.api.helpers.StubRead) Value(org.neo4j.values.storable.Value) StubPropertyCursor(org.neo4j.internal.kernel.api.helpers.StubPropertyCursor) Test(org.junit.jupiter.api.Test)

Aggregations

StubNodeCursor (org.neo4j.internal.kernel.api.helpers.StubNodeCursor)4 StubRead (org.neo4j.internal.kernel.api.helpers.StubRead)4 Test (org.junit.jupiter.api.Test)3 StubPropertyCursor (org.neo4j.internal.kernel.api.helpers.StubPropertyCursor)3 Value (org.neo4j.values.storable.Value)3 StubCursorFactory (org.neo4j.internal.kernel.api.helpers.StubCursorFactory)1 StubRelationshipCursor (org.neo4j.internal.kernel.api.helpers.StubRelationshipCursor)1