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));
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class LockingStatementOperationsTest method shouldAcquireEntityWriteLockBeforeSettingPropertyOnNode.
@Test
public void shouldAcquireEntityWriteLockBeforeSettingPropertyOnNode() throws Exception {
// given
DefinedProperty property = Property.property(8, 9);
// when
lockingOps.nodeSetProperty(state, 123, property);
// then
order.verify(locks).acquireExclusive(LockTracer.NONE, ResourceTypes.NODE, 123);
order.verify(entityWriteOps).nodeSetProperty(state, 123, property);
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class PropertyIT method shouldRemoveSetExistingProperty.
@Test
public void shouldRemoveSetExistingProperty() throws Exception {
// GIVEN
dbWithNoCache();
int propertyKeyId;
long nodeId;
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
nodeId = statement.dataWriteOperations().nodeCreate();
propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("clown");
statement.dataWriteOperations().nodeSetProperty(nodeId, stringProperty(propertyKeyId, "bozo"));
commit();
}
DefinedProperty newProperty = stringProperty(propertyKeyId, "ozob");
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
// WHEN
statement.dataWriteOperations().nodeRemoveProperty(nodeId, propertyKeyId);
statement.dataWriteOperations().nodeSetProperty(nodeId, newProperty);
// THEN
assertThat(statement.readOperations().nodeGetProperty(nodeId, propertyKeyId), equalTo(newProperty.value()));
// WHEN
commit();
}
// THEN
{
ReadOperations readOperations = readOperationsInNewTransaction();
assertThat(readOperations.nodeGetProperty(nodeId, propertyKeyId), equalTo(newProperty.value()));
assertThat(toList(readOperations.nodeGetPropertyKeys(nodeId)), equalTo(asList(newProperty.propertyKeyId())));
}
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class PropertyIT method shouldBeAbleToSetAndReadLargeByteArray.
@Test
public void shouldBeAbleToSetAndReadLargeByteArray() throws Exception {
// GIVEN
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
long nodeId = statement.dataWriteOperations().nodeCreate();
// WHEN
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("clown");
DefinedProperty property = byteArrayProperty(propertyKeyId, new byte[100_000]);
statement.dataWriteOperations().nodeSetProperty(nodeId, property);
// WHEN
commit();
ReadOperations readOperations = readOperationsInNewTransaction();
// THEN
readOperations.nodeGetProperty(nodeId, propertyKeyId);
}
Aggregations