use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProceduresTest method shouldCallRegisteredProcedure.
@Test
void shouldCallRegisteredProcedure() throws Throwable {
// Given
procs.register(procedure);
ProcedureHandle procHandle = procs.procedure(signature.name());
// When
RawIterator<AnyValue[], ProcedureException> result = procs.callProcedure(buildContext(dependencyResolver, valueMapper).context(), procHandle.id(), new AnyValue[] { longValue(1337) }, EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(result)).contains(new AnyValue[] { longValue(1337) });
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionsTest method shouldMakeContextAvailable.
@Test
void shouldMakeContextAvailable() throws Throwable {
// Given
procs.register(new CallableUserFunction.BasicUserFunction(signature) {
@Override
public AnyValue apply(Context ctx, AnyValue[] input) throws ProcedureException {
return Values.stringValue(ctx.thread().getName());
}
});
Context ctx = prepareContext();
int functionId = procs.function(signature.name()).id();
// When
Object result = procs.callFunction(ctx, functionId, new AnyValue[0]);
// Then
assertThat(result).isEqualTo(Values.stringValue(Thread.currentThread().getName()));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class MethodSignatureCompilerTest method shouldGiveHelpfulErrorOnUnmappable.
@Test
void shouldGiveHelpfulErrorOnUnmappable() throws Throwable {
// Given
Method echo = ClassWithProcedureWithSimpleArgs.class.getMethod("echoWithInvalidType", UnmappableRecord.class);
ProcedureException exception = assertThrows(ProcedureException.class, () -> new MethodSignatureCompiler(new TypeCheckers()).signatureFor(echo));
assertThat(exception.getMessage()).startsWith(String.format("Argument `name` at position 0 in `echoWithInvalidType` with%n" + "type `UnmappableRecord` cannot be converted to a Neo4j type: Don't know how to map " + "`org.neo4j.procedure.impl.MethodSignatureCompilerTest$UnmappableRecord` to the Neo4j Type System.%n" + "Please refer to to the documentation for full details.%n" + "For your reference, known types are:"));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class MethodSignatureCompilerTest method shouldGiveHelpfulErrorOnMissingAnnotations.
@Test
void shouldGiveHelpfulErrorOnMissingAnnotations() throws Throwable {
// Given
Method echo = ClassWithProcedureWithSimpleArgs.class.getMethod("echoWithoutAnnotations", String.class, String.class);
ProcedureException exception = assertThrows(ProcedureException.class, () -> new MethodSignatureCompiler(new TypeCheckers()).signatureFor(echo));
assertThat(exception.getMessage()).isEqualTo(String.format("Argument at position 1 in method `echoWithoutAnnotations` is missing an `@Name` annotation.%n" + "Please add the annotation, recompile the class and try again."));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureOutputSignatureCompilerTest method shouldGiveHelpfulErrorOnPrivateField.
@Test
void shouldGiveHelpfulErrorOnPrivateField() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> signatures(RecordWithPrivateField.class));
assertThat(exception.getMessage()).startsWith("Field `wat` in record `RecordWithPrivateField` cannot be accessed. Please ensure the field is marked as `public`.");
}
Aggregations