OrderDTO orderDTO = new OrderDTO();
orderDTO.name = "Order name " + UUID.randomUUID().toString();
orderDTO.code = code;
orderDTO.initDate = DateConverter.toXMLGregorianCalendar(new Date());
MaterialAssignmentDTO materialAssignmentDTO = new MaterialAssignmentDTO(
materialcode1, BigDecimal.valueOf(100.0), BigDecimal.TEN, null);
orderDTO.materialAssignments.add(materialAssignmentDTO);
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
.addOrders(orderListDTO).instanceConstraintViolationsList;
assertThat(instanceConstraintViolationsList.size(), equalTo(0));
final OrderElement orderElement = transactionService
.runOnTransaction(new IOnTransaction<OrderElement>() {
@Override
public OrderElement execute() {
try {
OrderElement element = orderElementDAO
.findUniqueByCode(code);
element.getMaterialAssignments().size();
return element;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
});
assertNotNull(orderElement);
assertThat(orderElement.getMaterialAssignments().size(), equalTo(1));
transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
orderElementDAO.flush();
sessionFactory.getCurrentSession().evict(orderElement);
return null;
}
});
orderDTO.materialAssignments.iterator().next().units = BigDecimal
.valueOf(150.0);
MaterialAssignmentDTO materialAssignmentDTO2 = new MaterialAssignmentDTO(
materialcode2, BigDecimal.valueOf(200.0), BigDecimal.ONE, null);
orderDTO.materialAssignments.add(materialAssignmentDTO);
orderDTO.materialAssignments.add(materialAssignmentDTO2);
orderListDTO = createOrderListDTO(orderDTO);