Search in sources :

Example 66 with ProcedureException

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

the class ProceduresTest method shouldNotAllowDuplicateFieldNamesInInput.

@Test
void shouldNotAllowDuplicateFieldNamesInInput() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.register(procedureWithSignature(procedureSignature("asd").in("a", NTAny).in("a", NTAny).build())));
    assertThat(exception.getMessage()).isEqualTo("Procedure `asd(a :: ANY?, a :: ANY?) :: ()` cannot be registered, because it contains a duplicated input field, 'a'. " + "You need to rename or remove one of the duplicate fields.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 67 with ProcedureException

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

the class ProceduresTest method shouldNotAllowCallingNonExistingProcedure.

@Test
void shouldNotAllowCallingNonExistingProcedure() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.procedure(signature.name()));
    assertThat(exception.getMessage()).isEqualTo("There is no procedure with the name `org.myproc` registered for this database instance. Please ensure you've spelled the " + "procedure name correctly and that the procedure is properly deployed.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 68 with ProcedureException

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

the class ProceduresTest method shouldSignalNonExistingProcedure.

@Test
void shouldSignalNonExistingProcedure() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.procedure(signature.name()));
    assertThat(exception.getMessage()).isEqualTo("There is no procedure with the name `org.myproc` registered for this database instance. Please ensure you've spelled the " + "procedure name correctly and that the procedure is properly deployed.");
}
Also used : ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Example 69 with ProcedureException

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

the class ProceduresTest method shouldMakeContextAvailable.

@Test
void shouldMakeContextAvailable() throws Throwable {
    // Given
    procs.register(new CallableProcedure.BasicProcedure(signature) {

        @Override
        public RawIterator<AnyValue[], ProcedureException> apply(Context ctx, AnyValue[] input, ResourceTracker resourceTracker) {
            return RawIterator.<AnyValue[], ProcedureException>of(new AnyValue[] { stringValue(ctx.thread().getName()) });
        }
    });
    Context ctx = prepareContext();
    ProcedureHandle procedureHandle = procs.procedure(signature.name());
    // When
    RawIterator<AnyValue[], ProcedureException> result = procs.callProcedure(ctx, procedureHandle.id(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
    // Then
    assertThat(asList(result)).contains(new AnyValue[] { stringValue(Thread.currentThread().getName()) });
}
Also used : BasicContext.buildContext(org.neo4j.kernel.api.procedure.BasicContext.buildContext) Context(org.neo4j.kernel.api.procedure.Context) ProcedureHandle(org.neo4j.internal.kernel.api.procs.ProcedureHandle) ResourceTracker(org.neo4j.kernel.api.ResourceTracker) AnyValue(org.neo4j.values.AnyValue) CallableProcedure(org.neo4j.kernel.api.procedure.CallableProcedure) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) RawIterator(org.neo4j.collection.RawIterator) Test(org.junit.jupiter.api.Test)

Example 70 with ProcedureException

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

the class ProceduresTest method shouldNotAllowDuplicateFieldNamesInOutput.

@Test
void shouldNotAllowDuplicateFieldNamesInOutput() {
    ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.register(procedureWithSignature(procedureSignature("asd").out("a", NTAny).out("a", NTAny).build())));
    assertThat(exception.getMessage()).isEqualTo("Procedure `asd() :: (a :: ANY?, a :: ANY?)` cannot be registered, because it contains a duplicated output field, 'a'. " + "You need to rename or remove one of the duplicate fields.");
}
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