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);
instanceConstraintViolationsList = orderElementService
.addOrders(orderListDTO).instanceConstraintViolationsList;
assertThat(instanceConstraintViolationsList.size(), equalTo(0));
final OrderElement orderElement2 = transactionService
.runOnTransaction(new IOnTransaction<OrderElement>() {
@Override
public OrderElement execute() {
try {
return orderElementDAO.findUniqueByCode(code);