use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor in project neo4j by neo4j.
the class PlainOperationsTest method shouldAcquiredSharedLabelLocksWhenDetachDeletingNode.
@Test
void shouldAcquiredSharedLabelLocksWhenDetachDeletingNode() {
// given
long nodeId = 1L;
long labelId1 = 1;
long labelId2 = 2;
returnRelationships(transaction, new TestRelationshipChain(nodeId));
when(transaction.ambientNodeCursor()).thenReturn(new StubNodeCursor(false).withNode(nodeId));
when(nodeCursor.next()).thenReturn(true);
TokenSet labels = mock(TokenSet.class);
when(labels.all()).thenReturn(new long[] { labelId1, labelId2 });
when(nodeCursor.labels()).thenReturn(labels);
// when
operations.nodeDetachDelete(nodeId);
// then
InOrder order = inOrder(locks, creationContext);
order.verify(creationContext).acquireNodeDeletionLock(txState, locks, LockTracer.NONE, nodeId);
order.verify(locks).acquireShared(LockTracer.NONE, ResourceTypes.LABEL, labelId1, labelId2);
order.verify(locks).acquireShared(LockTracer.NONE, ResourceTypes.LABEL, TOKEN_INDEX_RESOURCE_ID);
order.verifyNoMoreInteractions();
}
use of org.neo4j.internal.kernel.api.helpers.StubNodeCursor in project neo4j by neo4j.
the class PlainOperationsTest method detachDeleteNodeWithoutRelationshipsExclusivelyLockNode.
@Test
void detachDeleteNodeWithoutRelationshipsExclusivelyLockNode() {
long nodeId = 1L;
returnRelationships(transaction, new TestRelationshipChain(nodeId));
when(transaction.ambientNodeCursor()).thenReturn(new StubNodeCursor(false).withNode(nodeId));
when(nodeCursor.next()).thenReturn(true);
TokenSet labels = mock(TokenSet.class);
when(labels.all()).thenReturn(EMPTY_LONG_ARRAY);
when(nodeCursor.labels()).thenReturn(labels);
operations.nodeDetachDelete(nodeId);
order.verify(creationContext).acquireNodeDeletionLock(txState, locks, LockTracer.NONE, nodeId);
order.verify(locks, never()).releaseExclusive(ResourceTypes.NODE, nodeId);
order.verify(txState).nodeDoDelete(nodeId);
}
Aggregations