use of org.neo4j.kernel.api.properties.DefinedProperty 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));
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class TxStateTransactionDataViewTest method shouldListAddedRelationshipProperties.
@Test
public void shouldListAddedRelationshipProperties() throws Exception {
// Given
int propertyKeyId = 1;
DefinedProperty prevProp = stringProperty(propertyKeyId, "prevValue");
state.relationshipDoReplaceProperty(1L, prevProp, stringProperty(propertyKeyId, "newValue"));
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(prevProp));
// When
Iterable<PropertyEntry<Relationship>> propertyEntries = snapshot().assignedRelationshipProperties();
// Then
PropertyEntry<Relationship> 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));
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class NeoStoresTest method validateNodeRel1.
private void validateNodeRel1(final long node, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long rel1, long rel2, final int relType1, final int relType2) throws IOException {
assertTrue(nodeExists(node));
ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
PropertyReceiver<DefinedProperty> receiver = newPropertyReceiver(props);
propertyLoader.nodeLoadProperties(node, receiver);
int count = 0;
for (int keyId : props.keySet()) {
long id = props.get(keyId).other();
PropertyRecord record = getRecord(pStore, id);
PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
DefinedProperty data = block.newPropertyData(pStore);
if (data.propertyKeyId() == prop1.propertyKeyId()) {
assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals("string1", data.value());
nodeAddProperty(node, prop1.propertyKeyId(), "-string1");
} else if (data.propertyKeyId() == prop2.propertyKeyId()) {
assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(1, data.value());
nodeAddProperty(node, prop2.propertyKeyId(), -1);
} else if (data.propertyKeyId() == prop3.propertyKeyId()) {
assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(true, data.value());
nodeAddProperty(node, prop3.propertyKeyId(), false);
} else {
throw new IOException();
}
count++;
}
assertEquals(3, count);
count = validateAndCountRelationships(node, rel1, rel2, relType1, relType2);
assertEquals(2, count);
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class NeoStoresTest method testProps1.
@Test
public void testProps1() throws Exception {
initializeStores(storeDir, stringMap());
startTx();
long nodeId = nextId(Node.class);
transaction.nodeDoCreate(nodeId);
pStore.nextId();
DefinedProperty prop = nodeAddProperty(nodeId, index("nisse"), 10);
commitTx();
ds.stop();
initializeStores(storeDir, stringMap());
startTx();
DefinedProperty prop2 = nodeAddProperty(nodeId, prop.propertyKeyId(), 5);
transaction.nodeDoRemoveProperty(nodeId, prop2);
transaction.nodeDoDelete(nodeId);
commitTx();
ds.stop();
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class NeoStoresTest method validateRel1.
private void validateRel1(long rel, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long firstNode, long secondNode, int relType) throws IOException {
ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
propertyLoader.relLoadProperties(rel, newPropertyReceiver(props));
int count = 0;
for (int keyId : props.keySet()) {
long id = props.get(keyId).other();
PropertyRecord record = getRecord(pStore, id);
PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
DefinedProperty data = block.newPropertyData(pStore);
if (data.propertyKeyId() == prop1.propertyKeyId()) {
assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals("string1", data.value());
relAddProperty(rel, prop1.propertyKeyId(), "-string1");
} else if (data.propertyKeyId() == prop2.propertyKeyId()) {
assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(1, data.value());
relAddProperty(rel, prop2.propertyKeyId(), -1);
} else if (data.propertyKeyId() == prop3.propertyKeyId()) {
assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(true, data.value());
relAddProperty(rel, prop3.propertyKeyId(), false);
} else {
throw new IOException();
}
count++;
}
assertEquals(3, count);
assertRelationshipData(rel, firstNode, secondNode, relType);
}
Aggregations