@Test void pathShouldEqualItself() { assertEqual( path( node( 1L ) ), path( node( 1L ) ) ); assertEqual( path( node( 1L ), rel( 2L, 1L, 3L ), node( 3L ) ), path( node( 1L ), rel( 2L, 1L, 3L ), node( 3L ) ) ); assertEqual( path( node( 1L ), rel( 2L, 1L, 3L ), node( 2L ), rel( 3L, 2L, 1L ), node( 1L ) ), path( node( 1L ), rel( 2L, 1L, 3L ), node( 2L ), rel( 3L, 2L, 1L ), node( 1L ) ) ); }
@Test void pathShouldContainOneMoreNodeThenEdges() { assertThrows( Exception.class, () -> VirtualValues.path( nodes( 1L, 2L ), relationships() ) ); }
@Test void shouldHandleNaNCorrectly() { assertIncomparable( toAnyValue(Double.NaN), toAnyValue( Double.NaN ) ); assertIncomparable( toAnyValue( 1 ), toAnyValue( Double.NaN ) ); assertIncomparable( toAnyValue( Double.NaN ), toAnyValue( 1 ) ); }
@Test void pathShouldHandleNullEdge() { assertThrows( AssertionError.class, () -> VirtualValues.path( nodes( 1L ), null ) ); }
@Test void pathShouldHandleNullNodes() { assertThrows( AssertionError.class, () -> VirtualValues.path( null, relationships( 1L ) ) ); } }
@Test void pathShouldNotOnlyContainRelationship() { assertThrows( AssertionError.class, () -> VirtualValues.path( nodes(), relationships( 1L ) ) ); }
public static ListValue list( Object... objects ) { AnyValue[] values = new AnyValue[objects.length]; for ( int i = 0; i < objects.length; i++ ) { values[i] = toAnyValue( objects[i] ); } return VirtualValues.list( values ); }
@Test void pathShouldNotEqualOtherPath() { assertNotEqual( path( node( 1L ) ), path( node( 2L ) ) ); assertNotEqual( path( node( 1L ) ), path( node( 1L ), rel( 1L, 1L, 2L ), node( 2L ) ) ); assertNotEqual( path( node( 1L ) ), path( node( 2L ), rel( 1L, 2L, 1L ), node( 1L ) ) ); assertNotEqual( path( node( 1L ), rel( 2L, 1L, 3L ), node( 3L ) ), path( node( 1L ), rel( 3L, 1L, 3L ), node( 3L ) ) ); assertNotEqual( path( node( 1L ), rel( 2L, 1L, 2L ), node( 2L ) ), path( node( 1L ), rel( 2L, 1L, 3L ), node( 3L ) ) ); }
public static VirtualValue map( Object... keyOrVal ) { assert keyOrVal.length % 2 == 0; String[] keys = new String[keyOrVal.length / 2]; AnyValue[] values = new AnyValue[keyOrVal.length / 2]; for ( int i = 0; i < keyOrVal.length; i += 2 ) { keys[i / 2] = (String) keyOrVal[i]; values[i / 2] = toAnyValue( keyOrVal[i + 1] ); } return VirtualValues.map( keys, values ); }