Search in sources :

Example 11 with ProcedureException

use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.

the class UserAggregationFunctionTest method shouldNotAllowNonPublicUpdateMethod.

@Test
void shouldNotAllowNonPublicUpdateMethod() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(NonPublicUpdateMethod.class));
    assertThat(exception.getMessage()).isEqualTo("Aggregation update method 'update' in InnerAggregator must be public.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 12 with ProcedureException

use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.

the class UserAggregationFunctionTest method shouldGiveHelpfulErrorOnNullMessageException.

@Test
void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable {
    // Given
    CallableUserAggregationFunction method = compile(FunctionThatThrowsNullMsgExceptionAtInvocation.class).get(0);
    ProcedureException exception = assertThrows(ProcedureException.class, () -> method.create(prepareContext()).update(new AnyValue[] {}));
    assertThat(exception.getMessage()).isEqualTo("Failed to invoke function `org.neo4j.procedure.impl.test`: Caused by: java.lang.IndexOutOfBoundsException");
}
Also used : CallableUserAggregationFunction(org.neo4j.kernel.api.procedure.CallableUserAggregationFunction) AnyValue(org.neo4j.values.AnyValue) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 13 with ProcedureException

use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.

the class UserAggregationFunctionTest method shouldGiveHelpfulErrorOnFunctionReturningInvalidType.

@Test
void shouldGiveHelpfulErrorOnFunctionReturningInvalidType() {
    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]"));
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 14 with ProcedureException

use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.

the class UserAggregationFunctionTest 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."));
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 15 with ProcedureException

use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.

the class UserAggregationFunctionTest method shouldNotAllowMissingAnnotations.

@Test
void shouldNotAllowMissingAnnotations() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(FunctionWithMissingAnnotations.class));
    assertThat(exception.getMessage()).isEqualTo("Class 'MissingAggregator' must contain methods annotated with both '@UserAggregationResult' as well as '@UserAggregationUpdate'.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Aggregations

ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)124 Test (org.junit.jupiter.api.Test)95 CallableProcedure (org.neo4j.kernel.api.procedure.CallableProcedure)21 AnyValue (org.neo4j.values.AnyValue)19 QualifiedName (org.neo4j.internal.kernel.api.procs.QualifiedName)14 KernelException (org.neo4j.exceptions.KernelException)10 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)10 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)9 Arrays (java.util.Arrays)8 List (java.util.List)8 RawIterator (org.neo4j.collection.RawIterator)8 UserFunctionSignature (org.neo4j.internal.kernel.api.procs.UserFunctionSignature)8 CallableUserFunction (org.neo4j.kernel.api.procedure.CallableUserFunction)8 Collectors (java.util.stream.Collectors)7 ProcedureSignature (org.neo4j.internal.kernel.api.procs.ProcedureSignature)7 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)7 Method (java.lang.reflect.Method)6 ArrayList (java.util.ArrayList)6 FieldSignature (org.neo4j.internal.kernel.api.procs.FieldSignature)6 CallableUserAggregationFunction (org.neo4j.kernel.api.procedure.CallableUserAggregationFunction)6