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));
}
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));
}
Aggregations