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;
}
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();
}
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));
}
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();
}
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();
}
Aggregations