Search in sources :

Example 1 with A

use of com.tngtech.archunit.lang.syntax.elements.GivenCodeUnitsTest.A in project ArchUnit by TNG.

the class CodeUnitsShouldTest method complex_code_unit_syntax.

@Test
public void complex_code_unit_syntax() {
    EvaluationResult result = codeUnits().that(doNotHaveParametersOfType(List.class)).should().beAnnotatedWith(A.class).andShould().beProtected().orShould().haveRawReturnType(String.class).evaluate(importClasses(ClassWithVariousMembers.class));
    assertViolation(result);
    String failure = getOnlyElement(result.getFailureReport().getDetails());
    assertThat(failure).matches(String.format(".*Constructor .*%s.* does not have modifier PROTECTED.*", quote(CONSTRUCTOR_ONE_ARG))).contains("and Constructor").matches(String.format(".*Constructor .*%s.* is not annotated with @A.*", quote(CONSTRUCTOR_ONE_ARG))).matches(String.format(".*Constructor .*%s.* does not have raw return type %s.*", quote(CONSTRUCTOR_ONE_ARG), String.class.getName()));
}
Also used : A(com.tngtech.archunit.lang.syntax.elements.GivenCodeUnitsTest.A) ClassWithVariousMembers(com.tngtech.archunit.lang.syntax.elements.GivenCodeUnitsTest.ClassWithVariousMembers) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) Test(org.junit.Test)

Aggregations

EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)1 A (com.tngtech.archunit.lang.syntax.elements.GivenCodeUnitsTest.A)1 ClassWithVariousMembers (com.tngtech.archunit.lang.syntax.elements.GivenCodeUnitsTest.ClassWithVariousMembers)1 Test (org.junit.Test)1