Search in sources :

Example 46 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class TransactionRecordStateTest method shouldConvertChangedPropertyToNodePropertyUpdates.

@Test
public void shouldConvertChangedPropertyToNodePropertyUpdates() throws Exception {
    // GIVEN
    NeoStores neoStores = neoStoresRule.open();
    int nodeId = 0;
    TransactionRecordState recordState = newTransactionRecordState(neoStores);
    recordState.nodeCreate(nodeId);
    DefinedProperty property1 = recordState.nodeAddProperty(nodeId, propertyId1, value1);
    DefinedProperty property2 = recordState.nodeAddProperty(nodeId, propertyId2, value2);
    apply(neoStores, transactionRepresentationOf(recordState));
    // WHEN
    String newValue1 = "new", newValue2 = "new 2";
    recordState = newTransactionRecordState(neoStores);
    recordState.nodeChangeProperty(nodeId, property1.propertyKeyId(), newValue1);
    recordState.nodeChangeProperty(nodeId, property2.propertyKeyId(), newValue2);
    Iterable<NodeUpdates> indexUpdates = indexUpdatesOf(neoStores, recordState);
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(nodeId).changed(property1.propertyKeyId(), property1.value(), newValue1).changed(property2.propertyKeyId(), property2.value(), newValue2).build();
    assertEquals(expected, Iterables.single(indexUpdates));
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Test(org.junit.Test)

Example 47 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class TransactionRecordStateTest method shouldConvertRemovedPropertyToNodePropertyUpdates.

@Test
public void shouldConvertRemovedPropertyToNodePropertyUpdates() throws Exception {
    // GIVEN
    NeoStores neoStores = neoStoresRule.open();
    int nodeId = 0;
    TransactionRecordState recordState = newTransactionRecordState(neoStores);
    recordState.nodeCreate(nodeId);
    addLabelsToNode(recordState, nodeId, oneLabelId);
    DefinedProperty property1 = recordState.nodeAddProperty(nodeId, propertyId1, value1);
    DefinedProperty property2 = recordState.nodeAddProperty(nodeId, propertyId2, value2);
    apply(neoStores, transactionRepresentationOf(recordState));
    // WHEN
    recordState = newTransactionRecordState(neoStores);
    recordState.nodeRemoveProperty(nodeId, property1.propertyKeyId());
    recordState.nodeRemoveProperty(nodeId, property2.propertyKeyId());
    Iterable<NodeUpdates> indexUpdates = indexUpdatesOf(neoStores, recordState);
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(nodeId, oneLabelId).removed(property1.propertyKeyId(), property1.value()).removed(property2.propertyKeyId(), property2.value()).build();
    assertEquals(expected, Iterables.single(indexUpdates));
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Test(org.junit.Test)

Aggregations

DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)47 Test (org.junit.Test)23 Pair (org.neo4j.helpers.collection.Pair)9 IOException (java.io.IOException)8 InterruptedIOException (java.io.InterruptedIOException)8 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)8 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)8 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)8 PropertyItem (org.neo4j.storageengine.api.PropertyItem)8 NodeItem (org.neo4j.storageengine.api.NodeItem)7 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)7 Property (org.neo4j.kernel.api.properties.Property)6 PropertyEntry (org.neo4j.graphdb.event.PropertyEntry)4 DataWriteOperations (org.neo4j.kernel.api.DataWriteOperations)4 NodeUpdates (org.neo4j.kernel.api.index.NodeUpdates)4 NeoStores (org.neo4j.kernel.impl.store.NeoStores)4 StorageProperty (org.neo4j.storageengine.api.StorageProperty)4 Node (org.neo4j.graphdb.Node)3 Relationship (org.neo4j.graphdb.Relationship)3 Statement (org.neo4j.kernel.api.Statement)3