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);
instanceConstraintViolationsList = orderElementService
.addOrders(orderListDTO).instanceConstraintViolationsList;
assertThat(instanceConstraintViolationsList.size(), equalTo(0));
final OrderElement orderElement2 = transactionService
.runOnTransaction(new IOnTransaction<OrderElement>() {
@Override
public OrderElement execute() {
try {
OrderElement element = orderElementDAO
.findUniqueByCode(code);
for (AdvanceMeasurement measurement : element
.getDirectAdvanceAssignmentSubcontractor()
.getAdvanceMeasurements()) {
measurement.getDate();
}
return element;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
});
assertNotNull(orderElement2);
advanceAssignment = orderElement2
.getDirectAdvanceAssignmentSubcontractor();
assertNotNull(advanceAssignment);
SortedSet<AdvanceMeasurement> advanceMeasurements = advanceAssignment
.getAdvanceMeasurements();
assertThat(advanceMeasurements.size(), equalTo(2));
for (AdvanceMeasurement advanceMeasurement : advanceMeasurements) {
assertThat(advanceMeasurement.getDate(), anyOf(equalTo(date),
equalTo(date.plusWeeks(1))));