orderDTO.name = "Order name " + UUID.randomUUID().toString();
orderDTO.code = code;
orderDTO.initDate = DateConverter.toXMLGregorianCalendar(new Date());
LocalDate date = new LocalDate();
AdvanceMeasurementDTO advanceMeasurementDTO = new AdvanceMeasurementDTO(
DateConverter.toXMLGregorianCalendar(date), new BigDecimal(15));
orderDTO.advanceMeasurements.add(advanceMeasurementDTO);
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.getDirectAdvanceAssignmentSubcontractor()
.getAdvanceMeasurements().size();
return element;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
});
assertNotNull(orderElement);
DirectAdvanceAssignment advanceAssignment = orderElement
.getDirectAdvanceAssignmentSubcontractor();
assertNotNull(advanceAssignment);
assertThat(advanceAssignment.getAdvanceMeasurements().size(),
equalTo(1));
transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
orderElementDAO.flush();
sessionFactory.getCurrentSession().evict(orderElement);
return null;
}
});
AdvanceMeasurementDTO advanceMeasurementDTO2 = new AdvanceMeasurementDTO(
DateConverter.toXMLGregorianCalendar(date.plusWeeks(1)),
new BigDecimal(20));
orderDTO.advanceMeasurements.add(advanceMeasurementDTO2);
orderListDTO = createOrderListDTO(orderDTO);