Search in sources :

Example 1 with PropertyEntry

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

the class TxStateTransactionDataViewTest method shouldListAddedNodePropertiesProperties.

@Test
public void shouldListAddedNodePropertiesProperties() throws Exception {
    // Given
    int propertyKeyId = 1;
    DefinedProperty prevProp = stringProperty(propertyKeyId, "prevValue");
    state.nodeDoChangeProperty(1L, prevProp, stringProperty(propertyKeyId, "newValue"));
    when(ops.propertyKeyGetName(propertyKeyId)).thenReturn("theKey");
    long propertyId = 20L;
    when(storeStatement.acquireSingleNodeCursor(1L)).thenReturn(asNodeCursor(1L, propertyId, labels()));
    when(storeStatement.acquireSinglePropertyCursor(propertyId, propertyKeyId, NO_LOCK)).thenReturn(asPropertyCursor(prevProp));
    // When
    Iterable<PropertyEntry<Node>> propertyEntries = snapshot().assignedNodeProperties();
    // Then
    PropertyEntry<Node> entry = single(propertyEntries);
    assertThat(entry.key(), equalTo("theKey"));
    assertThat(entry.value(), equalTo((Object) "newValue"));
    assertThat(entry.previouslyCommitedValue(), equalTo((Object) "prevValue"));
    assertThat(entry.entity().getId(), equalTo(1L));
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyEntry(org.neo4j.graphdb.event.PropertyEntry) Node(org.neo4j.graphdb.Node) Test(org.junit.Test)

Example 2 with PropertyEntry

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

the class TxStateTransactionDataViewTest method shouldListRemovedNodeProperties.

@Test
public void shouldListRemovedNodeProperties() throws Exception {
    // Given
    int propertyKeyId = 1;
    DefinedProperty prevProp = stringProperty(propertyKeyId, "prevValue");
    state.nodeDoRemoveProperty(1L, prevProp);
    when(ops.propertyKeyGetName(propertyKeyId)).thenReturn("theKey");
    long propertyId = 20L;
    when(storeStatement.acquireSingleNodeCursor(1L)).thenReturn(asNodeCursor(1L, propertyId, labels()));
    when(storeStatement.acquireSinglePropertyCursor(propertyId, propertyKeyId, NO_LOCK)).thenReturn(asPropertyCursor(prevProp));
    // When
    Iterable<PropertyEntry<Node>> propertyEntries = snapshot().removedNodeProperties();
    // Then
    PropertyEntry<Node> entry = single(propertyEntries);
    assertThat(entry.key(), equalTo("theKey"));
    assertThat(entry.previouslyCommitedValue(), equalTo("prevValue"));
    assertThat(entry.entity().getId(), equalTo(1L));
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyEntry(org.neo4j.graphdb.event.PropertyEntry) Node(org.neo4j.graphdb.Node) Test(org.junit.Test)

Example 3 with PropertyEntry

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

the class TxStateTransactionDataViewTest method shouldListRemovedNodeProperties.

@Test
void shouldListRemovedNodeProperties() throws Exception {
    // Given
    int propertyKeyId = ops.propertyKeyTokenHolder().getOrCreateId("theKey");
    Value prevValue = Values.of("prevValue");
    state.nodeDoRemoveProperty(1L, propertyKeyId);
    ops.withNode(1).properties("theKey", prevValue);
    // When
    Iterable<PropertyEntry<Node>> propertyEntries = snapshot().removedNodeProperties();
    // Then
    PropertyEntry<Node> entry = single(propertyEntries);
    assertThat(entry.key()).isEqualTo("theKey");
    assertThat(entry.previouslyCommittedValue()).isEqualTo("prevValue");
    assertThat(entry.entity().getId()).isEqualTo(1L);
}
Also used : PropertyEntry(org.neo4j.graphdb.event.PropertyEntry) Node(org.neo4j.graphdb.Node) Value(org.neo4j.values.storable.Value) Test(org.junit.jupiter.api.Test)

Example 4 with PropertyEntry

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

the class TxStateTransactionDataViewTest method shouldListAddedRelationshipProperties.

@Test
void shouldListAddedRelationshipProperties() throws Exception {
    // Given
    Value prevValue = Values.of("prevValue");
    int propertyKeyId = ops.propertyKeyTokenHolder().getOrCreateId("theKey");
    state.relationshipDoReplaceProperty(1L, propertyKeyId, prevValue, Values.of("newValue"));
    ops.withRelationship(1, 0, 0, 0).properties("theKey", prevValue);
    // When
    Iterable<PropertyEntry<Relationship>> propertyEntries = snapshot().assignedRelationshipProperties();
    // Then
    PropertyEntry<Relationship> entry = single(propertyEntries);
    assertThat(entry.key()).isEqualTo("theKey");
    assertThat(entry.value()).isEqualTo("newValue");
    assertThat(entry.previouslyCommittedValue()).isEqualTo("prevValue");
    assertThat(entry.entity().getId()).isEqualTo(1L);
}
Also used : PropertyEntry(org.neo4j.graphdb.event.PropertyEntry) Relationship(org.neo4j.graphdb.Relationship) Value(org.neo4j.values.storable.Value) Test(org.junit.jupiter.api.Test)

Example 5 with PropertyEntry

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

the class TxStateTransactionDataViewTest method shouldListRemovedRelationshipProperties.

@Test
public void shouldListRemovedRelationshipProperties() throws Exception {
    // Given
    int propertyKeyId = 1;
    DefinedProperty prevValue = stringProperty(propertyKeyId, "prevValue");
    state.relationshipDoRemoveProperty(1L, prevValue);
    when(ops.propertyKeyGetName(propertyKeyId)).thenReturn("theKey");
    long propertyId = 40L;
    when(storeStatement.acquireSingleRelationshipCursor(1)).thenReturn(asRelationshipCursor(1, 0, 0, 0, propertyId));
    when(storeStatement.acquireSinglePropertyCursor(propertyId, propertyKeyId, NO_LOCK)).thenReturn(asPropertyCursor(prevValue));
    // When
    Iterable<PropertyEntry<Relationship>> propertyEntries = snapshot().removedRelationshipProperties();
    // Then
    PropertyEntry<Relationship> entry = single(propertyEntries);
    assertThat(entry.key(), equalTo("theKey"));
    assertThat(entry.previouslyCommitedValue(), equalTo((Object) "prevValue"));
    assertThat(entry.entity().getId(), equalTo(1L));
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyEntry(org.neo4j.graphdb.event.PropertyEntry) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Aggregations

PropertyEntry (org.neo4j.graphdb.event.PropertyEntry)10 Test (org.junit.jupiter.api.Test)5 Node (org.neo4j.graphdb.Node)5 Relationship (org.neo4j.graphdb.Relationship)5 Test (org.junit.Test)4 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)4 Value (org.neo4j.values.storable.Value)4 TransactionData (org.neo4j.graphdb.event.TransactionData)2 ApocConfiguration (apoc.ApocConfiguration)1 Description (apoc.Description)1 SetBackedList (apoc.coll.SetBackedList)1 Util (apoc.util.Util)1 Util.map (apoc.util.Util.map)1 java.util (java.util)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Stream (java.util.stream.Stream)1 org.neo4j.graphdb (org.neo4j.graphdb)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 RelationshipType (org.neo4j.graphdb.RelationshipType)1