Search in sources :

Example 6 with ProcedureException

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

the class ResourceInjectionTest method shouldFailNicelyWhenAggregationFunctionUsesUnknownAPI.

@Test
void shouldFailNicelyWhenAggregationFunctionUsesUnknownAPI() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> compiler.compileAggregationFunction(AggregationFunctionWithUnknownAPI.class));
    assertThat(exception.getMessage()).isEqualTo("Unable to set up injection for procedure `AggregationFunctionWithUnknownAPI`, " + "the field `api` has type `class org.neo4j.procedure.impl.ResourceInjectionTest$UnknownAPI` which is not a known injectable component.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 7 with ProcedureException

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

the class ResourceInjectionTest method shouldFailNicelyWhenUnknownAPI.

@Test
void shouldFailNicelyWhenUnknownAPI() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> compiler.compileProcedure(ProcedureWithUnknownAPI.class, null, true));
    assertThat(exception.getMessage()).isEqualTo("Unable to set up injection for procedure `ProcedureWithUnknownAPI`, " + "the field `api` has type `class org.neo4j.procedure.impl.ResourceInjectionTest$UnknownAPI` " + "which is not a known injectable component.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 8 with ProcedureException

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

the class ResourceInjectionTest method shouldFailNicelyWhenUnsafeAPISafeModeAggregationFunction.

@Test
void shouldFailNicelyWhenUnsafeAPISafeModeAggregationFunction() throws Throwable {
    // When
    List<CallableUserAggregationFunction> procList = compiler.compileAggregationFunction(AggregationFunctionWithUnsafeAPI.class);
    assertThat(logProvider).forClass(getClass()).forLevel(WARN).containsMessages("org.neo4j.procedure.impl.listCoolPeople", "unavailable");
    assertThat(procList.size()).isEqualTo(1);
    ProcedureException exception = assertThrows(ProcedureException.class, () -> {
        procList.get(0).create(prepareContext()).update(new AnyValue[] {});
        procList.get(0).create(prepareContext()).result();
    });
    assertThat(exception.getMessage()).contains("org.neo4j.procedure.impl.listCoolPeople", "unavailable");
}
Also used : CallableUserAggregationFunction(org.neo4j.kernel.api.procedure.CallableUserAggregationFunction) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 9 with ProcedureException

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

the class ResourceInjectionTest method shouldFailNicelyWhenFunctionUsesUnknownAPI.

@Test
void shouldFailNicelyWhenFunctionUsesUnknownAPI() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> compiler.compileFunction(FunctionWithUnknownAPI.class, false));
    assertThat(exception.getMessage()).isEqualTo("Unable to set up injection for procedure `FunctionWithUnknownAPI`, " + "the field `api` has type `class org.neo4j.procedure.impl.ResourceInjectionTest$UnknownAPI` which is not a known injectable component.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 10 with ProcedureException

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

the class UserAggregationFunctionTest 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.");
}
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