Search in sources :

Example 1 with LabelEntry

use of org.neo4j.graphdb.event.LabelEntry in project neo4j by neo4j.

the class TxStateTransactionDataViewTest method shouldListRemovedLabels.

@Test
public void shouldListRemovedLabels() throws Exception {
    // Given
    state.nodeDoRemoveLabel(2, 1L);
    when(ops.labelGetName(2)).thenReturn("theLabel");
    // When
    Iterable<LabelEntry> labelEntries = snapshot().removedLabels();
    // Then
    LabelEntry entry = single(labelEntries);
    assertThat(entry.label().name(), equalTo("theLabel"));
    assertThat(entry.node().getId(), equalTo(1L));
}
Also used : LabelEntry(org.neo4j.graphdb.event.LabelEntry) Test(org.junit.Test)

Example 2 with LabelEntry

use of org.neo4j.graphdb.event.LabelEntry in project neo4j by neo4j.

the class TxStateTransactionDataViewTest method shouldListAddedLabels.

@Test
public void shouldListAddedLabels() throws Exception {
    // Given
    state.nodeDoAddLabel(2, 1L);
    when(ops.labelGetName(2)).thenReturn("theLabel");
    when(storeStatement.acquireSingleNodeCursor(1)).thenReturn(asNodeCursor(1));
    // When
    Iterable<LabelEntry> labelEntries = snapshot().assignedLabels();
    // Then
    LabelEntry entry = single(labelEntries);
    assertThat(entry.label().name(), equalTo("theLabel"));
    assertThat(entry.node().getId(), equalTo(1L));
}
Also used : LabelEntry(org.neo4j.graphdb.event.LabelEntry) Test(org.junit.Test)

Example 3 with LabelEntry

use of org.neo4j.graphdb.event.LabelEntry in project neo4j by neo4j.

the class ExpectedTransactionData method compareTo.

void compareTo(TransactionData data) {
    Set<Node> expectedCreatedNodes = new HashSet<>(this.expectedCreatedNodes);
    Set<Relationship> expectedCreatedRelationships = new HashSet<>(this.expectedCreatedRelationships);
    Set<Node> expectedDeletedNodes = new HashSet<>(this.expectedDeletedNodes);
    Set<Relationship> expectedDeletedRelationships = new HashSet<>(this.expectedDeletedRelationships);
    Map<Node, Map<String, PropertyEntryImpl<Node>>> expectedAssignedNodeProperties = clone(this.expectedAssignedNodeProperties);
    Map<Relationship, Map<String, PropertyEntryImpl<Relationship>>> expectedAssignedRelationshipProperties = clone(this.expectedAssignedRelationshipProperties);
    Map<Node, Map<String, PropertyEntryImpl<Node>>> expectedRemovedNodeProperties = clone(this.expectedRemovedNodeProperties);
    Map<Relationship, Map<String, PropertyEntryImpl<Relationship>>> expectedRemovedRelationshipProperties = clone(this.expectedRemovedRelationshipProperties);
    Map<Node, Set<String>> expectedAssignedLabels = cloneLabelData(this.expectedAssignedLabels);
    Map<Node, Set<String>> expectedRemovedLabels = cloneLabelData(this.expectedRemovedLabels);
    for (Node node : data.createdNodes()) {
        assertTrue(expectedCreatedNodes.remove(node));
        assertFalse(data.isDeleted(node));
    }
    assertTrue("Expected some created nodes that weren't seen: " + expectedCreatedNodes, expectedCreatedNodes.isEmpty());
    for (Relationship rel : data.createdRelationships()) {
        assertTrue(expectedCreatedRelationships.remove(rel));
        assertFalse(data.isDeleted(rel));
    }
    assertTrue("Expected created relationships not encountered " + expectedCreatedRelationships, expectedCreatedRelationships.isEmpty());
    for (Node node : data.deletedNodes()) {
        assertTrue("Unexpected deleted node " + node, expectedDeletedNodes.remove(node));
        assertTrue(data.isDeleted(node));
    }
    assertTrue("Expected deleted nodes: " + expectedDeletedNodes, expectedDeletedNodes.isEmpty());
    for (Relationship rel : data.deletedRelationships()) {
        assertTrue(expectedDeletedRelationships.remove(rel));
        assertTrue(data.isDeleted(rel));
    }
    assertTrue("Expected deleted relationships not encountered " + expectedDeletedRelationships, expectedDeletedRelationships.isEmpty());
    for (PropertyEntry<Node> entry : data.assignedNodeProperties()) {
        checkAssigned(expectedAssignedNodeProperties, entry);
        assertFalse(data.isDeleted(entry.entity()));
    }
    assertTrue("Expected assigned node properties not encountered " + expectedAssignedNodeProperties, expectedAssignedNodeProperties.isEmpty());
    for (PropertyEntry<Relationship> entry : data.assignedRelationshipProperties()) {
        checkAssigned(expectedAssignedRelationshipProperties, entry);
        assertFalse(data.isDeleted(entry.entity()));
    }
    assertTrue("Expected assigned relationship properties not encountered " + expectedAssignedRelationshipProperties, expectedAssignedRelationshipProperties.isEmpty());
    for (PropertyEntry<Node> entry : data.removedNodeProperties()) {
        checkRemoved(expectedRemovedNodeProperties, entry);
    }
    assertTrue("Expected removed node properties not encountered " + expectedRemovedNodeProperties, expectedRemovedNodeProperties.isEmpty());
    for (PropertyEntry<Relationship> entry : data.removedRelationshipProperties()) {
        checkRemoved(expectedRemovedRelationshipProperties, entry);
    }
    assertTrue("Expected removed relationship properties not encountered " + expectedRemovedRelationshipProperties, expectedRemovedRelationshipProperties.isEmpty());
    for (LabelEntry entry : data.assignedLabels()) {
        check(expectedAssignedLabels, entry);
    }
    assertTrue("Expected assigned labels not encountered " + expectedAssignedLabels, expectedAssignedLabels.isEmpty());
    for (LabelEntry entry : data.removedLabels()) {
        check(expectedRemovedLabels, entry);
    }
    assertTrue("Expected removed labels not encountered " + expectedRemovedLabels, expectedRemovedLabels.isEmpty());
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Node(org.neo4j.graphdb.Node) LabelEntry(org.neo4j.graphdb.event.LabelEntry) Relationship(org.neo4j.graphdb.Relationship) HashMap(java.util.HashMap) Map(java.util.Map) AutoCreatingHashMap(org.neo4j.kernel.impl.util.AutoCreatingHashMap) HashSet(java.util.HashSet)

Example 4 with LabelEntry

use of org.neo4j.graphdb.event.LabelEntry in project neo4j by neo4j.

the class TxStateTransactionDataViewTest method shouldListAddedLabels.

@Test
void shouldListAddedLabels() throws Exception {
    // Given
    int labelId = 2;
    when(tokenRead.nodeLabelName(labelId)).thenReturn("theLabel");
    state.nodeDoAddLabel(labelId, 1L);
    // When
    Iterable<LabelEntry> labelEntries = snapshot().assignedLabels();
    // Then
    LabelEntry entry = single(labelEntries);
    assertThat(entry.label().name()).isEqualTo("theLabel");
    assertThat(entry.node().getId()).isEqualTo(1L);
}
Also used : LabelEntry(org.neo4j.graphdb.event.LabelEntry) Test(org.junit.jupiter.api.Test)

Example 5 with LabelEntry

use of org.neo4j.graphdb.event.LabelEntry in project neo4j by neo4j.

the class TxStateTransactionDataViewTest method shouldListRemovedLabels.

@Test
void shouldListRemovedLabels() throws Exception {
    // Given
    int labelId = 2;
    when(tokenRead.nodeLabelName(labelId)).thenReturn("theLabel");
    state.nodeDoRemoveLabel(labelId, 1L);
    // When
    Iterable<LabelEntry> labelEntries = snapshot().removedLabels();
    // Then
    LabelEntry entry = single(labelEntries);
    assertThat(entry.label().name()).isEqualTo("theLabel");
    assertThat(entry.node().getId()).isEqualTo(1L);
}
Also used : LabelEntry(org.neo4j.graphdb.event.LabelEntry) Test(org.junit.jupiter.api.Test)

Aggregations

LabelEntry (org.neo4j.graphdb.event.LabelEntry)5 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 AutoCreatingHashMap (org.neo4j.kernel.impl.util.AutoCreatingHashMap)1