Search in sources :

Example 6 with StubNodeCursor

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();
}
Also used : StubNodeCursor(org.neo4j.internal.kernel.api.helpers.StubNodeCursor) InOrder(org.mockito.InOrder) TokenSet(org.neo4j.internal.kernel.api.TokenSet) TestRelationshipChain(org.neo4j.internal.kernel.api.helpers.TestRelationshipChain) Test(org.junit.jupiter.api.Test)

Example 7 with StubNodeCursor

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);
}
Also used : StubNodeCursor(org.neo4j.internal.kernel.api.helpers.StubNodeCursor) TokenSet(org.neo4j.internal.kernel.api.TokenSet) TestRelationshipChain(org.neo4j.internal.kernel.api.helpers.TestRelationshipChain) Test(org.junit.jupiter.api.Test)

Aggregations

StubNodeCursor (org.neo4j.internal.kernel.api.helpers.StubNodeCursor)7 Test (org.junit.jupiter.api.Test)6 StubRead (org.neo4j.internal.kernel.api.helpers.StubRead)4 TokenSet (org.neo4j.internal.kernel.api.TokenSet)3 StubPropertyCursor (org.neo4j.internal.kernel.api.helpers.StubPropertyCursor)3 TestRelationshipChain (org.neo4j.internal.kernel.api.helpers.TestRelationshipChain)3 Value (org.neo4j.values.storable.Value)3 InOrder (org.mockito.InOrder)1 StubCursorFactory (org.neo4j.internal.kernel.api.helpers.StubCursorFactory)1 StubRelationshipCursor (org.neo4j.internal.kernel.api.helpers.StubRelationshipCursor)1