@Test
@Transactional
public void checkChangeIndirectCriterionToInvalid() {
Order order = Order.create();
order.useSchedulingDataFor(mockedOrderVersion);
OrderLineGroup container1 = OrderLineGroup.create();
container1.useSchedulingDataFor(mockedOrderVersion);
order.add(container1);
OrderLineGroup container2 = OrderLineGroup.create();
container2.useSchedulingDataFor(mockedOrderVersion);
container1.add(container2);
OrderLine line = OrderLine.createOrderLineWithUnfixedPercentage(100);
line.useSchedulingDataFor(mockedOrderVersion);
container2.add(line);
CriterionType type = CriterionType.create("", "");
type.setResource(ResourceEnum.WORKER);
CriterionRequirement requirement = DirectCriterionRequirement
.create(Criterion.create(type));
order.addDirectCriterionRequirement(requirement);
assertThat(container2.getCriterionRequirements().size(), equalTo(1));
IndirectCriterionRequirement requirementAtContainer = (IndirectCriterionRequirement) container2
.getCriterionRequirements().iterator().next();
container2.setValidCriterionRequirement(requirementAtContainer, false);
assertThat(container1.getCriterionRequirements().size(), equalTo(1));
assertTrue(container1.getCriterionRequirements().iterator().next()
.isValid());
assertThat(container2.getCriterionRequirements().size(), equalTo(1));
assertFalse(container2.getCriterionRequirements().iterator().next()
.isValid());
assertThat(line.getCriterionRequirements().size(), equalTo(1));
assertFalse(line.getCriterionRequirements().iterator().next().isValid());