Search in sources :

Example 6 with CompilationMessage

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

the class PerformsWriteMethodVisitorTest method rejects_conflicted_mode_usage.

@Test
public void rejects_conflicted_mode_usage() {
    Element element = elementTestUtils.findMethodElement(PerformsWriteProcedures.class, "conflictingMode");
    Stream<CompilationMessage> errors = visitor.visit(element);
    assertThat(errors).hasSize(1).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).contains(tuple(Diagnostic.Kind.ERROR, element, "@PerformsWrites usage error: cannot use mode other than Mode.DEFAULT"));
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 7 with CompilationMessage

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

the class DuplicatedProcedureValidatorTest method detects_duplicate_procedure_with_overridden_names.

@Test
public void detects_duplicate_procedure_with_overridden_names() {
    Element procedureA = procedureMethod(OverriddenProcedureA.class.getName());
    Element procedureB = procedureMethod(OverriddenProcedureB.class.getName());
    Collection<Element> duplicates = asList(procedureA, procedureB);
    Stream<CompilationMessage> errors = validator.apply(duplicates);
    assertThat(errors).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).containsExactlyInAnyOrder(tuple(Diagnostic.Kind.ERROR, procedureA, "Procedure|function name <override> is already defined 2 times. It should be defined only once!"), tuple(Diagnostic.Kind.ERROR, procedureB, "Procedure|function name <override> is already defined 2 times. It should be defined only " + "once!"));
}
Also used : OverriddenProcedureA(org.neo4j.tooling.procedure.validators.examples.override.OverriddenProcedureA) OverriddenProcedureB(org.neo4j.tooling.procedure.validators.examples.OverriddenProcedureB) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 8 with CompilationMessage

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

the class PerformsWriteMethodVisitorTest method rejects_non_procedure_methods.

@Test
public void rejects_non_procedure_methods() {
    Element element = elementTestUtils.findMethodElement(PerformsWriteProcedures.class, "missingProcedureAnnotation");
    Stream<CompilationMessage> errors = visitor.visit(element);
    assertThat(errors).hasSize(1).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).contains(tuple(Diagnostic.Kind.ERROR, element, "@PerformsWrites usage error: missing @Procedure annotation on method"));
}
Also used : Element(javax.lang.model.element.Element) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) Test(org.junit.Test)

Example 9 with CompilationMessage

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

the class UserFunctionVisitorTest method functions_with_specified_name_cannot_be_in_root_namespace.

@Test
public void functions_with_specified_name_cannot_be_in_root_namespace() {
    Element function = elementTestUtils.findMethodElement(UserFunctionsExamples.class, "functionWithName");
    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> 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 10 with CompilationMessage

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

the class DuplicatedProcedureValidatorTest method detects_duplicate_procedure_with_default_names.

@Test
public void detects_duplicate_procedure_with_default_names() {
    Element procedureA = procedureMethod(DefaultProcedureA.class.getName());
    Element procedureB = procedureMethod(DefaultProcedureB.class.getName());
    Collection<Element> duplicates = asList(procedureA, procedureB);
    Stream<CompilationMessage> errors = validator.apply(duplicates);
    String procedureName = "org.neo4j.tooling.procedure.validators.examples.procedure";
    assertThat(errors).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).containsExactlyInAnyOrder(tuple(Diagnostic.Kind.ERROR, procedureA, "Procedure|function name <" + procedureName + "> is already defined 2 times. It should be defined " + "only once!"), tuple(Diagnostic.Kind.ERROR, procedureB, "Procedure|function name <" + procedureName + "> is already defined 2 times. It should be defined only once!"));
}
Also used : DefaultProcedureA(org.neo4j.tooling.procedure.validators.examples.DefaultProcedureA) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) CompilationMessage(org.neo4j.tooling.procedure.messages.CompilationMessage) DefaultProcedureB(org.neo4j.tooling.procedure.validators.examples.DefaultProcedureB) 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