@Test
@Transactional
public void testCantAddCriterionSatisfactionWithTypeAllowMultipleResource() {
Criterion criterion = CriterionDAOTest.createValidCriterion();
Criterion otherCriterion = CriterionDAOTest.createValidCriterion();
Worker worker = Worker.create("firstName", "surName", "2333232");
ICriterionType<Criterion> criterionType = createTypeThatMatches(true,
criterion,otherCriterion);
Interval intervalA = Interval.range(date(2009,10,8),date(2009,10,25));
Interval intervalB = Interval.range(date(2009,10,5),date(2009,10,9));
Interval intervalC = Interval.range(date(2009,11,12),date(2009,11,16));
Interval intervalE = Interval.range(date(2009,10,26),date(2009,10,30));
worker.addSatisfaction(new CriterionWithItsType(criterionType,
criterion), intervalA);
//Same Criterion
assertFalse(worker.canAddSatisfaction(new CriterionWithItsType(
criterionType, criterion), intervalB));
//Distinct Criterion
assertTrue(worker.canAddSatisfaction(new CriterionWithItsType(
criterionType, otherCriterion), intervalC));
//without overlap
assertTrue(worker.canAddSatisfaction(new CriterionWithItsType(
criterionType, criterion), intervalE));
}