use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class BoltResponseMessageTest method shouldSerializeRelationship.
@Test
void shouldSerializeRelationship() throws Throwable {
RelationshipValue rel = relationshipValue(12L, nodeValue(1L, stringArray(), VirtualValues.EMPTY_MAP), nodeValue(2L, stringArray(), VirtualValues.EMPTY_MAP), stringValue("KNOWS"), VirtualValues.map(new String[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) }));
assertThat(serialized(rel)).isEqualTo("B1 71 91 B5 52 0C 01 02 85 4B 4E 4F 57 53 A2 84" + lineSeparator() + "6E 61 6D 65 83 42 6F 62 83 61 67 65 0E");
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class DefaultValueMapperTest method shouldMapDirectRelationship.
@Test
void shouldMapDirectRelationship() {
// Given
Node start, end;
Relationship relationship;
try (Transaction tx = db.beginTx()) {
start = tx.createNode();
end = tx.createNode();
relationship = start.createRelationshipTo(end, RelationshipType.withName("R"));
tx.commit();
}
RelationshipValue relationshipValue = VirtualValues.relationshipValue(relationship.getId(), nodeValue(start.getId(), Values.EMPTY_TEXT_ARRAY, EMPTY_MAP), nodeValue(start.getId(), Values.EMPTY_TEXT_ARRAY, EMPTY_MAP), stringValue("R"), EMPTY_MAP);
// Then
try (Transaction tx = db.beginTx()) {
var mapper = new DefaultValueMapper((InternalTransaction) tx);
Relationship coreAPIRelationship = mapper.mapRelationship(relationshipValue);
assertThat(coreAPIRelationship.getId()).isEqualTo(relationship.getId());
assertThat(coreAPIRelationship.getStartNode()).isEqualTo(start);
assertThat(coreAPIRelationship.getEndNode()).isEqualTo(end);
}
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathWrappingPathValue method relationships.
@Override
public RelationshipValue[] relationships() {
int length = path.length();
RelationshipValue[] values = new RelationshipValue[length];
int i = 0;
for (Relationship relationship : path.relationships()) {
values[i++] = ValueUtils.fromRelationshipEntity(relationship);
}
return values;
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathValueBuilderTest method shouldHandleNoValueInMultiRel.
@Test
void shouldHandleNoValueInMultiRel() {
// Given (n1)<--(n2)-->(n3)
NodeValue node1 = node(42);
NodeValue node2 = node(43);
NodeValue node3 = node(44);
RelationshipValue relationship1 = relationship(1337, node2, node1);
RelationshipValue relationship2 = relationship(1338, node2, node3);
PathValueBuilder builder = builder(node1, node2, node3, relationship1, relationship2);
// When (n1)<--(n2)--(n3)
builder.addNode(node1);
builder.addMultipleUndirected(list(relationship1, relationship2, NO_VALUE));
// Then
assertEquals(NO_VALUE, builder.build());
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathValueBuilderTest method shouldHandleLongerPath.
@Test
void shouldHandleLongerPath() {
// Given (n1)<--(n2)-->(n3)
NodeValue n1 = node(42);
NodeValue n2 = node(43);
NodeValue n3 = node(44);
RelationshipValue r1 = relationship(1337, n2, n1);
RelationshipValue r2 = relationship(1338, n2, n3);
PathValueBuilder builder = builder(n1, n2, n3, r1, r2);
// When (n1)<--(n2)--(n3)
builder.addNode(n1);
builder.addIncoming(r1);
builder.addUndirected(r2);
// Then
assertEquals(path(n1, r1, n2, r2, n3), builder.build());
}
Aggregations