Search in sources :

Example 31 with Element

use of javax.lang.model.element.Element 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 32 with Element

use of javax.lang.model.element.Element 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 33 with Element

use of javax.lang.model.element.Element 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 34 with Element

use of javax.lang.model.element.Element in project neo4j by neo4j.

the class DuplicatedProcedureValidatorTest method procedureMethod.

private Element procedureMethod(String name) {
    TypeElement typeElement = elements.getTypeElement(name);
    Collection<Element> procedures = findProcedures(typeElement);
    if (procedures.size() != 1) {
        throw new AssertionError("Test procedure class should only have 1 defined procedure");
    }
    return procedures.iterator().next();
}
Also used : TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement)

Example 35 with Element

use of javax.lang.model.element.Element 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)286 TypeElement (javax.lang.model.element.TypeElement)227 ExecutableElement (javax.lang.model.element.ExecutableElement)148 VariableElement (javax.lang.model.element.VariableElement)96 TypeMirror (javax.lang.model.type.TypeMirror)68 PackageElement (javax.lang.model.element.PackageElement)48 ArrayList (java.util.ArrayList)39 DeclaredType (javax.lang.model.type.DeclaredType)30 IOException (java.io.IOException)29 Map (java.util.Map)26 HashSet (java.util.HashSet)23 LinkedHashSet (java.util.LinkedHashSet)22 List (java.util.List)22 Set (java.util.Set)22 Test (org.junit.Test)21 ElementKind (javax.lang.model.element.ElementKind)20 AnnotationMirror (javax.lang.model.element.AnnotationMirror)19 Elements (javax.lang.model.util.Elements)18 HashMap (java.util.HashMap)16 LinkedHashMap (java.util.LinkedHashMap)15