@Test
public void doingAnAndIntersectsTheAdditionalConstraints() {
boolean[][] validities = { { true, true }, { true, false },
{ false, true }, { false, false } };
for (final boolean[] pairs : validities) {
AvailabilityTimeLine a = AvailabilityTimeLine.allValid();
a.setVetoer(new IVetoer() {
@Override
public boolean isValid(LocalDate date) {
return pairs[0];
}
});
AvailabilityTimeLine b = AvailabilityTimeLine.allValid();
b.setVetoer(new IVetoer() {
@Override
public boolean isValid(LocalDate date) {
return pairs[1];
}
});
AvailabilityTimeLine result = a.and(b);
boolean expected = pairs[0] && pairs[1];
assertThat(result.isValid(earlyExample), equalTo(expected));
assertThat(result.isValid(contemporaryExample), equalTo(expected));
assertThat(result.isValid(lateExample), equalTo(expected));
}
}