Search in sources :

Example 21 with ConditionEvents

use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.

the class ClassCallsCodeUnitConditionTest method checkCondition.

private ConditionEvents checkCondition(ArchCondition<JavaClass> condition) {
    ConditionEvents events = new ConditionEvents();
    condition.check(CALLER_CLASS, events);
    return events;
}
Also used : ConditionEvents(com.tngtech.archunit.lang.ConditionEvents)

Example 22 with ConditionEvents

use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.

the class ClassCallsCodeUnitConditionTest method call_with_correct_name_and_params_matches.

@Test
public void call_with_correct_name_and_params_matches() {
    ConditionEvents events = checkCondition(callMethodWhere(target(name(TargetClass.appendStringMethod)).and(target(rawParameterTypes(TargetClass.appendStringParams))).and(target(owner(type(TargetClass.class))))));
    assertThat(events).containNoViolation();
}
Also used : TargetClass(com.tngtech.archunit.lang.conditions.testobjects.TargetClass) ConditionEvents(com.tngtech.archunit.lang.ConditionEvents) Test(org.junit.Test)

Example 23 with ConditionEvents

use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.

the class ContainAnyConditionTest method inverting_works.

@Test
public void inverting_works() throws Exception {
    ConditionEvents events = new ConditionEvents();
    containAnyElementThat(IS_SERIALIZABLE).check(ONE_SERIALIZABLE_AND_ONE_NON_SERIALIZABLE_OBJECT, events);
    assertThat(events).containNoViolation();
    assertThat(events.getAllowed()).as("Exactly one allowed event occurred").hasSize(1);
    assertThat(getInverted(events)).containViolations(isSerializableMessageFor(SerializableObject.class));
}
Also used : SerializableObject(com.tngtech.archunit.lang.conditions.ContainsOnlyConditionTest.SerializableObject) ConditionEvents(com.tngtech.archunit.lang.ConditionEvents) Test(org.junit.Test)

Example 24 with ConditionEvents

use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.

the class ContainAnyConditionTest method satisfied_works_and_description_contains_mismatches.

@Test
public void satisfied_works_and_description_contains_mismatches() {
    ConditionEvents events = new ConditionEvents();
    containAnyElementThat(IS_SERIALIZABLE).check(TWO_NONSERIALIZABLE_OBJECTS, events);
    assertThat(events).containViolations(messageForTwoTimes(isSerializableMessageFor(Object.class)));
    events = new ConditionEvents();
    containAnyElementThat(IS_SERIALIZABLE).check(ONE_SERIALIZABLE_AND_ONE_NON_SERIALIZABLE_OBJECT, events);
    assertThat(events).containNoViolation();
}
Also used : ConditionEvents(com.tngtech.archunit.lang.ConditionEvents) Test(org.junit.Test)

Example 25 with ConditionEvents

use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.

the class ContainAnyConditionTest method if_there_are_no_input_events_no_ContainsAnyEvent_is_added.

@Test
public void if_there_are_no_input_events_no_ContainsAnyEvent_is_added() {
    ConditionEvents events = new ConditionEvents();
    containOnlyElementsThat(IS_SERIALIZABLE).check(emptyList(), events);
    assertThat(events.isEmpty()).as("events are empty").isTrue();
}
Also used : ConditionEvents(com.tngtech.archunit.lang.ConditionEvents) Test(org.junit.Test)

Aggregations

ConditionEvents (com.tngtech.archunit.lang.ConditionEvents)53 ArchCondition (com.tngtech.archunit.lang.ArchCondition)31 JavaClass (com.tngtech.archunit.core.domain.JavaClass)25 JavaMethod (com.tngtech.archunit.core.domain.JavaMethod)22 SimpleConditionEvent (com.tngtech.archunit.lang.SimpleConditionEvent)22 Test (org.junit.Test)15 List (java.util.List)9 SourcePredicates.isJavaClass (org.apache.flink.architecture.common.SourcePredicates.isJavaClass)9 DescribedPredicate (com.tngtech.archunit.base.DescribedPredicate)8 JavaMember (com.tngtech.archunit.core.domain.JavaMember)7 Collectors (java.util.stream.Collectors)7 JavaParameterizedType (com.tngtech.archunit.core.domain.JavaParameterizedType)6 JavaType (com.tngtech.archunit.core.domain.JavaType)6 HasName (com.tngtech.archunit.core.domain.properties.HasName)6 Collections (java.util.Collections)6 Stream (java.util.stream.Stream)6 JavaField (com.tngtech.archunit.core.domain.JavaField)5 ConditionEvent (com.tngtech.archunit.lang.ConditionEvent)4 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)4 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)3