use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor in project neo4j by neo4j.
the class PlainOperationsTest method detachDeleteNodeExclusivelyLockNodes.
@Test
void detachDeleteNodeExclusivelyLockNodes() {
long nodeId = 1L;
returnRelationships(transaction, new TestRelationshipChain(nodeId).outgoing(1, 2L, 42));
when(transaction.ambientNodeCursor()).thenReturn(new StubNodeCursor(false).withNode(nodeId));
TokenSet labels = mock(TokenSet.class);
when(labels.all()).thenReturn(EMPTY_LONG_ARRAY);
when(nodeCursor.labels()).thenReturn(labels);
when(nodeCursor.next()).thenReturn(true);
operations.nodeDetachDelete(nodeId);
order.verify(creationContext).acquireNodeDeletionLock(txState, locks, LockTracer.NONE, nodeId);
order.verify(locks, never()).releaseExclusive(ResourceTypes.NODE, nodeId);
order.verify(locks, never()).releaseExclusive(ResourceTypes.NODE, 2L);
order.verify(txState).nodeDoDelete(nodeId);
}
use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor 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));
}
use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor 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);
}
use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor 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);
}
use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor 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));
}
Aggregations