Fix tests failing on Jenkins due to new predefined users with profiles

FEA: ItEr76S30PermissionsEnhancements
This commit is contained in:
Manuel Rego Casasnovas 2012-06-22 13:03:39 +02:00
parent 9498f508b2
commit a1e4ecd38d
5 changed files with 25 additions and 10 deletions

View file

@ -131,7 +131,7 @@ public enum PredefinedProfiles {
public Profile getFromDB() {
try {
return Registry.getProfileDAO().findByProfileName(name);
return Registry.getProfileDAO().findByProfileNameLoadingRoles(name);
} catch (InstanceNotFoundException e) {
return null;
}

View file

@ -51,4 +51,7 @@ public interface IProfileDAO extends IGenericDAO<Profile, Long>{
List<OrderAuthorization> getOrderAuthorizationsByProfile(Profile profile);
Profile findByProfileNameLoadingRoles(String profileName)
throws InstanceNotFoundException;
}

View file

@ -112,4 +112,13 @@ public class ProfileDAO extends GenericDAOHibernate<Profile, Long> implements
}
}
@Override
@Transactional(readOnly = true)
public Profile findByProfileNameLoadingRoles(String profileName)
throws InstanceNotFoundException {
Profile profile = findByProfileName(profileName);
profile.getRoles().size();
return profile;
}
}

View file

@ -66,18 +66,18 @@ public class UsersBootstrapInDBTest {
@Test
@Rollback(false)
public void testMandatoryUsersCreated() throws InstanceNotFoundException {
public void testLoadProfiles() {
profileBootstrap.loadRequiredData();
checkLoadRequiredData();
// Load data again to verify that a second load does not cause problems
checkLoadRequiredData();
}
private void checkLoadRequiredData() throws InstanceNotFoundException {
@Test
@Rollback(false)
public void testLoadUsers() {
usersBootstrap.loadRequiredData();
}
@Test
public void testMandatoryUsersCreated() throws InstanceNotFoundException {
for (PredefinedUsers u : PredefinedUsers.values()) {
@ -85,7 +85,6 @@ public class UsersBootstrapInDBTest {
assertEquals(u.getLoginName(), user.getLoginName());
assertEquals(u.getInitialRoles(), user.getRoles());
assertEquals(u.getInitialProfiles(), user.getProfiles());
}

View file

@ -37,6 +37,7 @@ import org.junit.runner.RunWith;
import org.libreplan.business.common.IAdHocTransactionService;
import org.libreplan.business.common.IOnTransaction;
import org.libreplan.business.scenarios.bootstrap.IScenariosBootstrap;
import org.libreplan.business.users.daos.IProfileDAO;
import org.libreplan.business.users.entities.Profile;
import org.libreplan.business.users.entities.UserRole;
import org.libreplan.web.users.bootstrap.IUsersBootstrapInDB;
@ -73,6 +74,9 @@ public class DBUserDetailsServiceTest {
@Autowired
private IAdHocTransactionService transactionService;
@Autowired
private IProfileDAO profileDAO;
@Before
public void loadScenariosBootsrap() {
/*