Criterion criterion = CriterionDAOTest.createValidCriterion();
Criterion otherCriterion = CriterionDAOTest.createValidCriterion();
Worker worker = Worker.create("firstName", "surName", "2333232");
ICriterionType<Criterion> criterionType = createTypeThatMatches(false,
criterion, otherCriterion);
worker.addSatisfaction(new CriterionWithItsType(criterionType,
criterion), Interval.range(year(5000), year(6000)));
worker.addSatisfaction(new CriterionWithItsType(criterionType,
criterion), Interval.range(year(4000),year(5000)));
assertThat(worker.query().from(criterion).enforcedInAll(
Interval.range(year(4001), year(4999))).result().size(),
equalTo(1));
assertThat(worker.query().from(criterion).enforcedInAll(
Interval.range(year(4001), year(5000))).result().size(),
equalTo(0));
assertThat(worker.query().from(criterion).enforcedInAll(
Interval.range(year(5000), year(5001))).result().size(),
equalTo(1));
assertThat(worker.query().from(criterion).enforcedInAll(
Interval.range(year(5001), year(5500))).result().size(),
equalTo(1));
worker.finish(new CriterionWithItsType(criterionType, criterion));
assertThat(worker.query().from(criterion).enforcedInAll(
Interval.range(year(4001), year(4999))).result().size(),
equalTo(1));
assertThat(worker.query().from(criterion).enforcedInAll(
Interval.range(year(5001), year(5500))).result().size(),
equalTo(1));
assertFalse(worker.canAddSatisfaction(new CriterionWithItsType(
criterionType, otherCriterion), Interval
.from(CriterionSatisfactionDAOTest.year(4001))));
}