CriterionType ctWorker = createCriterionType(ResourceEnum.WORKER);
CostCategory costCategory = createCostCategory();
/* Create a machine DTO. */
MachineDTO m1 = new MachineDTO("name", "desc");
CriterionSatisfactionDTO m1s1 = new CriterionSatisfactionDTO(
ctMachine
.getName(), "c1", getDate(2000, 1, 1), getDate(2000, 2, 1));
m1.criterionSatisfactions.add(m1s1);
ResourcesCostCategoryAssignmentDTO m1a1 = new ResourcesCostCategoryAssignmentDTO(
costCategory.getName(), getDate(2000, 1, 1),
getDate(2000, 2, 1));
m1.resourcesCostCategoryAssignments.add(m1a1);
/* Create a worker DTO. */
String nif = getUniqueName();
WorkerDTO w1 = new WorkerDTO(getUniqueName(), "surname", nif);
CriterionSatisfactionDTO w1s1 = new CriterionSatisfactionDTO(
ctWorker
.getName(), "c1", getDate(2000, 1, 1), getDate(2000, 2, 1));
w1.criterionSatisfactions.add(w1s1);
ResourcesCostCategoryAssignmentDTO w1a1 = new ResourcesCostCategoryAssignmentDTO(
costCategory.getName(), getDate(2000, 1, 1),
getDate(2000, 2, 1));
w1.resourcesCostCategoryAssignments.add(w1a1);
/* Add resources. */
assertNoConstraintViolations(resourceService
.addResources(createResourceListDTO(m1, w1)));
/*
* Build DTOs for making the following update: + m1: update name, m1s1's
* start date, and add a new cost category assignment. + w1: update
* surname, w1a1's start date, and add a new criterion satisfaction.
*/
MachineDTO m1Updated = new MachineDTO(m1.code, "name" + "UPDATED", null);
CriterionSatisfactionDTO m1s1Updated = new CriterionSatisfactionDTO(
m1s1.code, null, null, getDate(2000, 1, 2), null);
m1Updated.criterionSatisfactions.add(m1s1Updated);
ResourcesCostCategoryAssignmentDTO m1a2 = new ResourcesCostCategoryAssignmentDTO(
costCategory.getName(), getDate(2000, 3, 1),
getDate(2000, 4, 1));
m1Updated.resourcesCostCategoryAssignments.add(m1a2);
WorkerDTO w1Updated = new WorkerDTO(w1.code, null, "surname"
+ "UPDATED", null);
CriterionSatisfactionDTO w1s2 = new CriterionSatisfactionDTO(
ctWorker
.getName(), "c1", getDate(2000, 3, 1), getDate(2000, 4, 1));
w1Updated.criterionSatisfactions.add(w1s2);
ResourcesCostCategoryAssignmentDTO w1a1Updated = new ResourcesCostCategoryAssignmentDTO(
w1a1.code, null, getDate(2000, 2, 1), null);