final String orderLineCode = "order-line-code"
+ UUID.randomUUID().toString();
OrderLineDTO orderLineDTO = new OrderLineDTO();
orderLineDTO.name = "Order line " + UUID.randomUUID().toString();
orderLineDTO.code = orderLineCode;
HoursGroupDTO hoursGroupDTO = new HoursGroupDTO("hours-groupYY",
ResourceEnumDTO.WORKER, 1000,
new HashSet<CriterionRequirementDTO>());
orderLineDTO.hoursGroups.add(hoursGroupDTO);
orderDTO.children.add(orderLineDTO);
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
.addOrders(orderListDTO).instanceConstraintViolationsList;
assertTrue(instanceConstraintViolationsList.toString(),
instanceConstraintViolationsList.size() == 0);
final OrderElement orderElement = transactionService
.runOnTransaction(new IOnTransaction<OrderElement>() {
@Override
public OrderElement execute() {
try {
return orderElementDAO.findUniqueByCode(code);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
});
assertNotNull(orderElement);
final OrderLine orderLine = transactionService
.runOnTransaction(new IOnTransaction<OrderLine>() {
@Override
public OrderLine execute() {
try {
OrderLine line = (OrderLine) orderElementDAO
.findUniqueByCode(orderLineCode);
line.getHoursGroups().size();
return line;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
});
assertNotNull(orderLine);
assertThat(orderLine.getHoursGroups().size(), equalTo(1));
transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
orderElementDAO.flush();
sessionFactory.getCurrentSession().evict(orderElement);
sessionFactory.getCurrentSession().evict(orderLine);
return null;
}
});
orderLineDTO.hoursGroups.iterator().next().workingHours = 1500;
HoursGroupDTO hoursGroupDTO2 = new HoursGroupDTO("hours-groupXX",
ResourceEnumDTO.WORKER, 2000,
new HashSet<CriterionRequirementDTO>());
orderLineDTO.hoursGroups.add(hoursGroupDTO2);
orderListDTO = createOrderListDTO(orderDTO);