Search in sources :

Example 21 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class BoltResponseMessageTest method shouldSerializeNode.

@Test
void shouldSerializeNode() throws Throwable {
    NodeValue nodeValue = nodeValue(12L, stringArray("User", "Banana"), VirtualValues.map(new String[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) }));
    assertThat(serialized(nodeValue)).isEqualTo("B1 71 91 B3 4E 0C 92 84 55 73 65 72 86 42 61 6E" + lineSeparator() + "61 6E 61 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67" + lineSeparator() + "65 0E");
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) AnyValue(org.neo4j.values.AnyValue) Test(org.junit.jupiter.api.Test)

Example 22 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PrimitiveOnlyValueWriterTest method newRelationshipValue.

private static RelationshipValue newRelationshipValue() {
    NodeValue startNode = nodeValue(24, stringArray("Person"), EMPTY_MAP);
    NodeValue endNode = nodeValue(42, stringArray("Person"), EMPTY_MAP);
    return relationshipValue(42, startNode, endNode, stringValue("KNOWS"), EMPTY_MAP);
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue)

Example 23 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PathValueBuilderTest method shouldHandleEmptyMultiRel.

@Test
void shouldHandleEmptyMultiRel() {
    // Given  (n1)<--(n2)-->(n3)
    NodeValue n1 = node(42);
    PathValueBuilder builder = builder(n1);
    // When (n1)<--(n2)--(n3)
    builder.addNode(n1);
    builder.addMultipleUndirected(EMPTY_LIST);
    // Then
    assertEquals(path(n1), builder.build());
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) Test(org.junit.jupiter.api.Test)

Example 24 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PathValueBuilderTest method shouldHandleLongerPathWithMultiRelWhereEndNodeIsKnown.

@Test
void shouldHandleLongerPathWithMultiRelWhereEndNodeIsKnown() {
    // 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.addMultipleUndirected(list(r1, r2), n3);
    // Then
    assertEquals(path(n1, r1, n2, r2, n3), builder.build());
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 25 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PathValueBuilderTest method shouldHandleNoValue.

@Test
void shouldHandleNoValue() {
    // Given  (n1)<--(n2)-->(n3)
    NodeValue node = node(42);
    RelationshipValue relationship = relationship(1337, node(43), node);
    PathValueBuilder builder = builder(node, relationship);
    // When (n1)<--(n2)--(n3)
    builder.addNode(node);
    builder.addIncoming(relationship);
    builder.addUndirected(NO_VALUE);
    // Then
    assertEquals(NO_VALUE, builder.build());
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Aggregations

NodeValue (org.neo4j.values.virtual.NodeValue)26 Test (org.junit.jupiter.api.Test)22 RelationshipValue (org.neo4j.values.virtual.RelationshipValue)13 AnyValue (org.neo4j.values.AnyValue)5 PathValue (org.neo4j.values.virtual.PathValue)3 Values.stringValue (org.neo4j.values.storable.Values.stringValue)2 ListValue (org.neo4j.values.virtual.ListValue)2 MapValue (org.neo4j.values.virtual.MapValue)2 VirtualNodeValue (org.neo4j.values.virtual.VirtualNodeValue)2 VirtualRelationshipValue (org.neo4j.values.virtual.VirtualRelationshipValue)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)1 Mockito (org.mockito.Mockito)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Answer (org.mockito.stubbing.Answer)1