/* Update criterion type and test. */
assertNoConstraintViolations(criterionService.addCriterionTypes(
createCriterionTypeListDTO(ctUpdated)));
CriterionType ctEntity = criterionTypeDAO.findByCode(ct.code);
assertTrue(ctEntity.getCriterions().size() == 4);
/* Test criterion hierarchy. */
Criterion c1Entity = ctEntity.getCriterion(c1.name);
Criterion c2Entity = ctEntity.getCriterion(c2Updated.name);
Criterion c2c1Entity = ctEntity.getCriterion(c2c1.name);
Criterion c3Entity = ctEntity.getCriterion(c3.name);
assertNull(c1Entity.getParent());
assertTrue(c1Entity.getChildren().size() == 1);
assertTrue(c1Entity.getChildren().contains(c2Entity));
assertTrue(c2Entity.getChildren().size() == 1);
assertTrue(c2Entity.getChildren().contains(c2c1Entity));
assertTrue(c2c1Entity.getChildren().size() == 0);
assertNull(c3Entity.getParent());
assertTrue(c3Entity.getChildren().size() == 0);
/*
* Basic properties in criteria "c1" and "c2", which are contained in
* "ctUpdated", must not be modified, except c2's name property.
*/
assertEquals(c1.name, c1Entity.getName());
assertEquals(c1.active, c1Entity.isActive());
assertEquals(c2Updated.name, c2Entity.getName());
assertEquals(c2.active, c2Entity.isActive());
/*
* Basic properties values, except description, must be not be
* modified.
*/
assertEquals(ct.name, ctEntity.getName());
assertEquals(ctUpdated.description, ctEntity.getDescription());
assertEquals(ct.allowHierarchy, ctEntity.allowHierarchy());
assertEquals(ct.allowSimultaneousCriterionsPerResource,
ctEntity.isAllowSimultaneousCriterionsPerResource());
assertEquals(ct.enabled, ctEntity.isEnabled());
assertEquals(ResourceEnumConverter.fromDTO(ct.resource),
ctEntity.getResource());
}