use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureOutputSignatureCompilerTest method shouldGiveHelpfulErrorOnUnmappable.
@Test
void shouldGiveHelpfulErrorOnUnmappable() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> signatures(UnmappableRecord.class));
assertThat(exception.getMessage()).startsWith("Field `wat` in record `UnmappableRecord` cannot be converted to a Neo4j type: " + "Don't know how to map `org.neo4j.procedure.impl.ProcedureOutputSignatureCompilerTest$UnmappableRecord`");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureOutputSignatureCompilerTest method shouldWarnAgainstStdLibraryClassesSinceTheseIndicateUserError.
@Test
void shouldWarnAgainstStdLibraryClassesSinceTheseIndicateUserError() {
// Impl note: We may want to change this behavior and actually allow procedures to return `Long` etc,
// with a default column name. So Stream<Long> would become records like (out: Long)
// Drawback of that is that it'd cause cognitive dissonance, it's not obvious what's a record
// and what is a primitive value..
ProcedureException exception = assertThrows(ProcedureException.class, () -> signatures(Long.class));
assertThat(exception.getMessage()).isEqualTo(String.format("Procedures must return a Stream of records, where a record is a concrete class%n" + "that you define, with public non-final fields defining the fields in the record.%n" + "If you''d like your procedure to return `Long`, you could define a record class like:%n" + "public class Output '{'%n" + " public Long out;%n" + "'}'%n%n" + "And then define your procedure as returning `Stream<Output>`."));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldGiveHelpfulErrorOnConstructorThatRequiresArgument.
@Test
void shouldGiveHelpfulErrorOnConstructorThatRequiresArgument() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(WeirdConstructorProcedure.class));
assertThat(exception.getMessage()).isEqualTo("Unable to find a usable public no-argument constructor in the class `WeirdConstructorProcedure`. 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 shouldGiveHelpfulErrorOnNoPublicConstructor.
@Test
void shouldGiveHelpfulErrorOnNoPublicConstructor() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(PrivateConstructorFunction.class));
assertThat(exception.getMessage()).isEqualTo("Unable to find a usable public no-argument constructor in the class `PrivateConstructorFunction`. 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 shouldGiveHelpfulErrorOnContextAnnotatedStaticField.
@Test
void shouldGiveHelpfulErrorOnContextAnnotatedStaticField() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(FunctionWithStaticContextAnnotatedField.class));
assertThat(exception.getMessage()).isEqualTo(String.format("The field `gdb` in the class named `FunctionWithStaticContextAnnotatedField` 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."));
}
Aggregations