use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionTest method shouldNotAllowVoidOutput.
@Test
void shouldNotAllowVoidOutput() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(FunctionWithVoidOutput.class));
assertThat(exception.getMessage()).startsWith("Don't know how to map `void` to the Neo4j Type System.");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionTest method shouldGiveHelpfulErrorOnNullMessageException.
@Test
void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable {
// Given
CallableUserFunction proc = compile(FunctionThatThrowsNullMsgExceptionAtInvocation.class).get(0);
// When
ProcedureException exception = assertThrows(ProcedureException.class, () -> proc.apply(prepareContext(), new AnyValue[0]));
assertThat(exception.getMessage()).isEqualTo("Failed to invoke function `org.neo4j.procedure.impl.throwsAtInvocation`: Caused by: java.lang.IndexOutOfBoundsException");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionTest method shouldNotAllowOverridingFunctionNameWithoutNamespace.
@Test
void shouldNotAllowOverridingFunctionNameWithoutNamespace() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(FunctionWithSingleName.class));
assertThat(exception.getMessage()).isEqualTo("It is not allowed to define functions in the root namespace please use a " + "namespace, e.g. `@UserFunction(\"org.example.com.singleName\")");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldGiveHelpfulErrorOnNullMessageException.
@Test
void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable {
// Given
CallableProcedure proc = compile(ProcedureThatThrowsNullMsgExceptionAtInvocation.class).get(0);
ProcedureException exception = assertThrows(ProcedureException.class, () -> proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER));
assertThat(exception.getMessage()).isEqualTo("Failed to invoke procedure `org.neo4j.procedure.impl.throwsAtInvocation`: Caused by: java.lang.IndexOutOfBoundsException");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldLoadWhiteListedProcedure.
@Test
void shouldLoadWhiteListedProcedure() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_allowlist, List.of("org.neo4j.procedure.impl.listCoolPeople")));
Log log = mock(Log.class);
ProcedureCompiler procedureCompiler = new ProcedureCompiler(new TypeCheckers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, null, false).get(0);
// When
RawIterator<AnyValue[], ProcedureException> result = proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertEquals(result.next()[0], stringValue("Bonnie"));
}
Aggregations