public AnyValue toValue( Object obj ) { return ValueUtils.of( obj ); } }
public static Object makeValueNeoSafe( Object object ) { AnyValue value = object instanceof AnyValue ? ((AnyValue) object) : ValueUtils.of( object ); return org.neo4j.cypher.internal.runtime.interpreted.makeValueNeoSafe.apply( value ); }
public static ListValue asListValue( List<?> collection ) { ArrayList<AnyValue> values = new ArrayList<>( collection.size() ); for ( Object o : collection ) { values.add( ValueUtils.of( o ) ); } return VirtualValues.fromList( values ); }
public static ListValue asListValue( Iterable<?> collection ) { ArrayList<AnyValue> values = new ArrayList<>(); for ( Object o : collection ) { values.add( ValueUtils.of( o ) ); } return VirtualValues.fromList( values ); }
public static MapValue asMapValue( Map<String,Object> map ) { MapValueBuilder builder = new MapValueBuilder( map.size() ); for ( Map.Entry<String,Object> entry : map.entrySet() ) { builder.add( entry.getKey(), ValueUtils.of( entry.getValue() ) ); } return builder.build(); }
@Test public void shouldFailWhenLocalDateTimeIsSentWithRun() throws Exception { testFailureWithV2Value( ValueUtils.of( LocalDateTime.now() ), "LocalDateTime" ); }
@Test public void shouldFailWhenZonedDateTimeIsSentWithRun() throws Exception { testFailureWithV2Value( ValueUtils.of( ZonedDateTime.now() ), "ZonedDateTime" ); }
@Test public void shouldRunSimpleReadOnlyFunction() throws Throwable { // Given CallableUserFunction func = compile( SingleReadOnlyFunction.class ).get( 0 ); // When Object out = func.apply( new BasicContext(), new AnyValue[0] ); // Then assertThat(out, equalTo( ValueUtils.of( Arrays.asList("Bonnie", "Clyde") ) ) ); }
@Test public void shouldCallExternalErrorOnLocalDateTime() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( LocalDateTime.now() ), "LocalDateTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnDateTimeWithZoneName() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( ZonedDateTime.now() ), "ZonedDateTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnDate() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( LocalDate.now() ), "LocalDate values cannot be unpacked with this version of bolt." ); }
@Test public void shouldFailWhenLocalTimeIsSentWithRun() throws Exception { testFailureWithV2Value( ValueUtils.of( LocalTime.now() ), "LocalTime" ); }
@Test public void shouldFailWhenOffsetTimeIsSentWithRun() throws Exception { testFailureWithV2Value( ValueUtils.of( OffsetTime.now() ), "OffsetTime" ); }
@Test public void shouldFailWhenOffsetDateTimeIsSentWithRun() throws Exception { testFailureWithV2Value( ValueUtils.of( OffsetDateTime.now() ), "OffsetDateTime" ); }
@Test public void shouldCallExternalErrorOnTime() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( OffsetTime.now() ), "OffsetTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnDateTimeWithOffset() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( OffsetDateTime.now() ), "OffsetDateTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnLocalTime() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( LocalTime.now() ), "LocalTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldLoadWhiteListedFunction() throws Throwable { // Given procedureCompiler = new ReflectiveProcedureCompiler( new TypeMappers(), components, new ComponentRegistry(), NullLog.getInstance(), new ProcedureConfig( Config.defaults( GraphDatabaseSettings.procedure_whitelist, "org.neo4j.kernel.impl.proc.listCoolPeople" ) ) ); CallableUserFunction method = compile( SingleReadOnlyFunction.class ).get( 0 ); // Expect Object out = method.apply( new BasicContext(), new AnyValue[0] ); assertThat(out, equalTo( ValueUtils.of( Arrays.asList("Bonnie", "Clyde") ) ) ); }