assertEquals(previous + 1, externalCompanyDAO.list(ExternalCompany.class).size());
}
@Test
public void testRelationWithUser() throws InstanceNotFoundException {
final User user = createValidUser();
final ExternalCompany externalCompany = createValidExternalCompany();
externalCompany.setCompanyUser(user);
IOnTransaction<Void> saveEntities = new IOnTransaction<Void>() {
@Override
public Void execute() {
userDAO.save(user);
externalCompanyDAO.save(externalCompany);
return null;
}
};
transactionService.runOnTransaction(saveEntities);
IOnTransaction<Void> retrieveEntitiesInOtherTransaction = new IOnTransaction<Void>() {
@Override
public Void execute() {
try{
ExternalCompany retrievedCompany = externalCompanyDAO.find(externalCompany.getId());
assertEquals(user.getLoginName(), retrievedCompany.getCompanyUser().getLoginName());
}
catch (InstanceNotFoundException e) {
fail("Unexpected InstanceNotFoundException");
}
return null;