use of org.neo4j.kernel.api.DataWriteOperations in project neo4j by neo4j.
the class PropertyIT method shouldRollbackSetNodePropertyValue.
@Test
public void shouldRollbackSetNodePropertyValue() throws Exception {
// GIVEN
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
long nodeId = statement.dataWriteOperations().nodeCreate();
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("clown");
commit();
// WHEN
DataWriteOperations dataWriteOperations = dataWriteOperationsInNewTransaction();
dataWriteOperations.nodeSetProperty(nodeId, stringProperty(propertyKeyId, "bozo"));
rollback();
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertThat(readOperations.nodeHasProperty(nodeId, propertyKeyId), is(false));
assertThat(readOperations.nodeGetProperty(nodeId, propertyKeyId), nullValue());
}
use of org.neo4j.kernel.api.DataWriteOperations in project neo4j by neo4j.
the class PropertyIT method shouldUpdateNodePropertyValue.
@Test
public void shouldUpdateNodePropertyValue() throws Exception {
// GIVEN
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
long nodeId = statement.dataWriteOperations().nodeCreate();
int propertyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("clown");
statement.dataWriteOperations().nodeSetProperty(nodeId, stringProperty(propertyId, "bozo"));
commit();
// WHEN
DataWriteOperations dataWriteOperations = dataWriteOperationsInNewTransaction();
dataWriteOperations.nodeSetProperty(nodeId, Property.intProperty(propertyId, 42));
commit();
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(42, readOperations.nodeGetProperty(nodeId, propertyId));
}
Aggregations