Search in sources :

Example 1 with CompilationMessage

use of org.neo4j.tooling.procedure.messages.CompilationMessage in project neo4j by neo4j.

the class UserFunctionVisitorTest method functions_with_specified_value_cannot_be_in_root_namespace.

@Test
public void functions_with_specified_value_cannot_be_in_root_namespace() {
    Element function = elementTestUtils.findMethodElement(UserFunctionsExamples.class, "functionWithValue");
    Stream<CompilationMessage> errors = visitor.visit(function);
    assertThat(errors).hasSize(1).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).contains(tuple(Diagnostic.Kind.ERROR, function, "Function <in_root_namespace_again> cannot be defined in the root namespace. Valid name example: com.acme.my_function"));
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 2 with CompilationMessage

use of org.neo4j.tooling.procedure.messages.CompilationMessage in project neo4j by neo4j.

the class UserFunctionVisitorTest method functions_with_unsupported_return_types_are_invalid.

@Test
public void functions_with_unsupported_return_types_are_invalid() {
    Element function = elementTestUtils.findMethodElement(UserFunctionsExamples.class, "wrongReturnType");
    Stream<CompilationMessage> errors = visitor.visit(function);
    assertThat(errors).hasSize(1).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).contains(tuple(Diagnostic.Kind.ERROR, function, "Unsupported return type <void> of function defined in <org.neo4j.tooling.procedure.visitors.examples.UserFunctionsExamples#wrongReturnType>."));
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 3 with CompilationMessage

use of org.neo4j.tooling.procedure.messages.CompilationMessage in project neo4j by neo4j.

the class UserFunctionVisitorTest method functions_with_non_annotated_parameters_are_invalid.

@Test
public void functions_with_non_annotated_parameters_are_invalid() {
    Element function = elementTestUtils.findMethodElement(UserFunctionsExamples.class, "missingParameterAnnotation");
    Stream<CompilationMessage> errors = visitor.visit(function);
    assertThat(errors).hasSize(1).extracting(CompilationMessage::getCategory, CompilationMessage::getContents).contains(tuple(Diagnostic.Kind.ERROR, "@org.neo4j.procedure.Name usage error: missing on parameter <arg1>"));
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 4 with CompilationMessage

use of org.neo4j.tooling.procedure.messages.CompilationMessage in project neo4j by neo4j.

the class UserFunctionVisitorTest method functions_in_non_root_namespace_are_valid.

@Test
public void functions_in_non_root_namespace_are_valid() {
    Element function = elementTestUtils.findMethodElement(UserFunctionsExamples.class, "ok");
    Stream<CompilationMessage> errors = visitor.visit(function);
    assertThat(errors).isEmpty();
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 5 with CompilationMessage

use of org.neo4j.tooling.procedure.messages.CompilationMessage in project neo4j by neo4j.

the class PerformsWriteMethodVisitorTest method validates_regular_procedure.

@Test
public void validates_regular_procedure() {
    Element element = elementTestUtils.findMethodElement(PerformsWriteProcedures.class, "ok");
    Stream<CompilationMessage> errors = visitor.visit(element);
    assertThat(errors).isEmpty();
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Aggregations

Element (javax.lang.model.element.Element)11 Test (org.junit.Test)11 CompilationMessage (org.neo4j.tooling.procedure.messages.CompilationMessage)11 TypeElement (javax.lang.model.element.TypeElement)2 DefaultProcedureA (org.neo4j.tooling.procedure.validators.examples.DefaultProcedureA)1 DefaultProcedureB (org.neo4j.tooling.procedure.validators.examples.DefaultProcedureB)1 OverriddenProcedureB (org.neo4j.tooling.procedure.validators.examples.OverriddenProcedureB)1 OverriddenProcedureA (org.neo4j.tooling.procedure.validators.examples.override.OverriddenProcedureA)1