use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionTest method shouldGiveHelpfulErrorOnConstructorThatRequiresArgument.
@Test
void shouldGiveHelpfulErrorOnConstructorThatRequiresArgument() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(WeirdConstructorFunction.class));
assertThat(exception.getMessage()).isEqualTo("Unable to find a usable public no-argument constructor in the class `WeirdConstructorFunction`. Please add a " + "valid, public constructor, recompile the class and try again.");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionTest method shouldGiveHelpfulErrorOnFunctionReturningInvalidType.
@Test
void shouldGiveHelpfulErrorOnFunctionReturningInvalidType() {
// When
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(FunctionWithInvalidOutput.class));
assertThat(exception.getMessage()).isEqualTo(String.format("Don't know how to map `char[]` to the Neo4j Type System.%n" + "Please refer to to the documentation for full details.%n" + "For your reference, known types are: [boolean, byte[], double, java.lang.Boolean, " + "java.lang.Double, java.lang.Long, java.lang.Number, java.lang.Object, " + "java.lang.String, java.time.LocalDate, java.time.LocalDateTime, " + "java.time.LocalTime, java.time.OffsetTime, java.time.ZonedDateTime, " + "java.time.temporal.TemporalAmount, java.util.List, java.util.Map, long]"));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldGiveHelpfulErrorOnContextAnnotatedStaticField.
@Test
void shouldGiveHelpfulErrorOnContextAnnotatedStaticField() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(ProcedureWithStaticContextAnnotatedField.class));
assertThat(exception.getMessage()).isEqualTo(String.format("The field `gdb` in the class named `ProcedureWithStaticContextAnnotatedField` is annotated as a @Context field,%n" + "but it is static. @Context fields must be public, non-final and non-static,%n" + "because they are reset each time a procedure is invoked."));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldRunClassWithMultipleProceduresDeclared.
@Test
void shouldRunClassWithMultipleProceduresDeclared() throws Throwable {
// Given
List<CallableProcedure> compiled = compile(MultiProcedureProcedure.class);
CallableProcedure bananaPeople = compiled.get(0);
CallableProcedure coolPeople = compiled.get(1);
// When
RawIterator<AnyValue[], ProcedureException> coolOut = coolPeople.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
RawIterator<AnyValue[], ProcedureException> bananaOut = bananaPeople.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(coolOut)).containsExactly(new AnyValue[] { stringValue("Bonnie") }, new AnyValue[] { stringValue("Clyde") });
assertThat(asList(bananaOut)).containsExactly(new AnyValue[] { stringValue("Jake"), longValue(18L) }, new AnyValue[] { stringValue("Pontus"), longValue(2L) });
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldRunProcedureWithInternalTypes.
@Test
void shouldRunProcedureWithInternalTypes() throws Throwable {
// Given
CallableProcedure proc = compile(InternalTypes.class).get(0);
// When
RawIterator<AnyValue[], ProcedureException> out = proc.apply(prepareContext(), new AnyValue[] { longValue(42), stringValue("hello"), Values.TRUE }, EMPTY_RESOURCE_TRACKER);
// Then
assertThat(out.next()).isEqualTo(new AnyValue[] { longValue(42), stringValue("hello"), Values.TRUE });
assertFalse(out.hasNext());
}
Aggregations