final Object[] objects = transactionService
.runOnTransaction(new IOnTransaction<Object[]>() {
@Override
public Object[] execute() {
Scenario source = givenStoredScenario();
Scenario destination = givenStoredScenario();
Order order = givenStoredOrderInScenario(source);
return new Object[] { source.getId(),
destination.getId(), order };
}
});
final Order orderAtSource = (Order) objects[2];
transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
try {
Order order = orderDAO.findExistingEntity(orderAtSource
.getId());
Scenario source = scenarioDAO.find((Long) objects[0]);
Scenario destination = scenarioDAO.find((Long) objects[1]);
assertThat(source.getOrders().size(),
equalTo(numOrders + 1));
assertThat(destination.getOrders().size(),
equalTo(numOrders));
transferOrdersModel.getScenarios();
transferOrdersModel.setSourceScenario(source);
transferOrdersModel.setDestinationScenario(destination);
transferOrdersModel.transfer(order);
return null;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
});
transactionService.runOnTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
try {
Scenario source = scenarioDAO.find((Long) objects[0]);
Scenario destination = scenarioDAO.find((Long) objects[1]);
assertThat(source.getOrders().size(),
equalTo(numOrders + 1));
assertThat(destination.getOrders().size(),
equalTo(numOrders + 1));
assertNotNull(destination
.getOrderVersion((Order) objects[2]));
return null;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);