use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class StateOperationsAutoIndexingTest method shouldSignalRelationshipPropertyAddedToAutoIndex.
@Test
public void shouldSignalRelationshipPropertyAddedToAutoIndex() throws Exception {
// Given
int propertyKeyId = 1;
DefinedProperty property = property(propertyKeyId, "Hello!");
RelationshipItem relationship = mock(RelationshipItem.class);
when(storeStmt.acquireSingleRelationshipCursor(1337)).thenReturn(cursor(relationship));
when(storeLayer.relationshipGetProperty(storeStmt, relationship, propertyKeyId)).thenReturn(empty());
// When
context.relationshipSetProperty(stmt, 1337, property);
// Then
verify(relOps).propertyAdded(writeOps, 1337, property);
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class StateOperationsAutoIndexingTest method shouldSignalRelationshipPropertyChangedToAutoIndex.
@Test
public void shouldSignalRelationshipPropertyChangedToAutoIndex() throws Exception {
// Given
int propertyKeyId = 1;
DefinedProperty property = property(propertyKeyId, "Hello!");
PropertyItem existingProperty = mock(PropertyItem.class);
when(existingProperty.propertyKeyId()).thenReturn(property.propertyKeyId());
when(existingProperty.value()).thenReturn("Goodbye!");
RelationshipItem relationship = mock(RelationshipItem.class);
when(storeStmt.acquireSingleRelationshipCursor(1337)).thenReturn(cursor(relationship));
when(storeLayer.relationshipGetProperty(storeStmt, relationship, propertyKeyId)).thenReturn(cursor(existingProperty));
// When
context.relationshipSetProperty(stmt, 1337, property);
// Then
verify(relOps).propertyChanged(eq(writeOps), eq(1337L), any(Property.class), eq(property));
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class StateOperationsAutoIndexingTest method shouldSignalNodePropertyAddedToAutoIndex.
@Test
public void shouldSignalNodePropertyAddedToAutoIndex() throws Exception {
// Given
DefinedProperty property = property(1, "Hello!");
NodeItem node = mock(NodeItem.class);
when(node.labels()).thenReturn(PrimitiveIntCollections.emptySet());
when(storeStmt.acquireSingleNodeCursor(1337)).thenReturn(cursor(node));
when(storeLayer.nodeGetProperty(eq(storeStmt), any(NodeItem.class), eq(property.propertyKeyId()))).thenReturn(cursor());
// When
context.nodeSetProperty(stmt, 1337, property);
// Then
verify(nodeOps).propertyAdded(writeOps, 1337, property);
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class TxStateTest method addNodesToIndex.
private IndexUpdater addNodesToIndex(final NewIndexDescriptor descriptor) {
return new IndexUpdater() {
@Override
public void withDefaultStringProperties(long... nodeIds) {
Collection<Pair<Long, String>> entries = new ArrayList<>(nodeIds.length);
for (long nodeId : nodeIds) {
entries.add(of(nodeId, "value" + nodeId));
}
withStringProperties(entries);
}
@Override
public void withStringProperties(Collection<Pair<Long, String>> nodesWithValues) {
final int labelId = descriptor.schema().getLabelId();
final int propertyKeyId = descriptor.schema().getPropertyId();
for (Pair<Long, String> entry : nodesWithValues) {
long nodeId = entry.first();
state.nodeDoCreate(nodeId);
state.nodeDoAddLabel(labelId, nodeId);
DefinedProperty propertyAfter = stringProperty(propertyKeyId, entry.other());
state.nodeDoAddProperty(nodeId, propertyAfter);
state.indexDoUpdateEntry(descriptor.schema(), nodeId, null, OrderedPropertyValues.ofUndefined(propertyAfter.value()));
}
}
@Override
public <T extends Number> void withNumberProperties(Collection<Pair<Long, T>> nodesWithValues) {
final int labelId = descriptor.schema().getLabelId();
final int propertyKeyId = descriptor.schema().getPropertyId();
for (Pair<Long, T> entry : nodesWithValues) {
long nodeId = entry.first();
state.nodeDoCreate(nodeId);
state.nodeDoAddLabel(labelId, nodeId);
DefinedProperty propertyAfter = numberProperty(propertyKeyId, entry.other());
state.nodeDoAddProperty(nodeId, propertyAfter);
state.indexDoUpdateEntry(descriptor.schema(), nodeId, null, OrderedPropertyValues.ofUndefined(propertyAfter.value()));
}
}
@Override
public void withBooleanProperties(Collection<Pair<Long, Boolean>> nodesWithValues) {
final int labelId = descriptor.schema().getLabelId();
final int propertyKeyId = descriptor.schema().getPropertyId();
for (Pair<Long, Boolean> entry : nodesWithValues) {
long nodeId = entry.first();
state.nodeDoCreate(nodeId);
state.nodeDoAddLabel(labelId, nodeId);
DefinedProperty propertyAfter = booleanProperty(propertyKeyId, entry.other());
state.nodeDoAddProperty(nodeId, propertyAfter);
state.indexDoUpdateEntry(descriptor.schema(), nodeId, null, OrderedPropertyValues.ofUndefined(propertyAfter.value()));
}
}
};
}
use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.
the class TxStateVisitorTest method shouldSeeAddedRelationshipProperties.
@Test
public void shouldSeeAddedRelationshipProperties() throws Exception {
// Given
long relId = 1L;
int propKey = 2;
GatheringVisitor visitor = new GatheringVisitor();
DefinedProperty prop = stringProperty(propKey, "hello");
state.relationshipDoReplaceProperty(relId, stringProperty(propKey, ""), prop);
// When
state.accept(visitor);
// Then
assertThat(visitor.relPropertyChanges, contains(propChange(relId, noProperty, asList(prop), noRemoved)));
}
Aggregations