use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method setUpMockUserDataService.
private void setUpMockUserDataService(boolean hasCreateCall, boolean hasUpdateUserCall, boolean hasUpdateAdminCall) {
// initialise the context with the user identified by the email
// "test1@test.com" seen as authenticated
Collection<User> userCollection = new ArrayList<>();
mockAdminUser = new User();
mockUser = new User();
mockNewUser = new User();
when(mockUserDataService.findAll()).thenReturn(userCollection);
when(mockUserDataService.read(4L)).thenReturn(mockAdminUser);
when(mockUserDataService.getUserFromEmail("admin@test.com")).thenReturn(mockAdminUser);
when(mockUserDataService.read(5L)).thenReturn(mockUser);
when(mockUserDataService.getUserFromEmail("user@test.com")).thenReturn(mockUser);
when(mockUserDataService.read(6L)).thenReturn(null);
when(mockUserDataService.getUserFromEmail("null")).thenReturn(null);
when(mockUserDataService.getUserFromEmail("newUser@test.com")).thenReturn(null);
if (hasCreateCall) {
when(mockUserDataService.create()).thenReturn(mockNewUser);
mockNewUser.setEmail1("newUser@test.com");
mockNewUser.setPassword("6eccfd91aa8a36582fbf64b8ea533692");
mockNewUser.setWebUrl1("http://www.newSite.com/");
mockNewUser.setPhoneNumber(null);
mockNewUser.setName(null);
mockNewUser.setFirstName(null);
mockNewUser.setAccountActivation(false);
mockNewUser.setRole(mockUserRole);
when(mockUserDataService.saveOrUpdate(mockNewUser)).thenReturn(mockNewUser);
mockNewUser.setEmail1("newUser@test.com");
}
if (hasUpdateUserCall) {
mockUser.setEmail1("user@test.com");
mockUser.setName("newName");
mockUser.setFirstName("newFirstName");
mockUser.setRole(mockAdminRole);
mockUser.setAccountActivation(false);
mockUser.setPhoneNumber("0102030405");
when(mockUserDataService.saveOrUpdate(mockUser)).thenReturn(mockUser);
mockUser.setEmail1("user@test.com");
}
mockAdminUser.setEmail1("admin@test.com");
mockAdminUser.setWebUrl1("http://www.admin.com");
mockAdminUser.setFirstName("firstNameAdmin");
mockAdminUser.setName("nameAdmin");
mockAdminUser.setPhoneNumber("0123456789");
mockAdminUser.setAccountActivation(true);
mockAdminUser.setId(4L);
mockAdminUser.setRole(mockAdminRole);
if (hasUpdateAdminCall) {
mockAdminUser.setName("newName");
mockAdminUser.setFirstName("newFirstName");
mockAdminUser.setPhoneNumber("0102030405");
when(mockUserDataService.saveOrUpdate(mockAdminUser)).thenReturn(mockAdminUser);
mockAdminUser.setEmail1("admin@test.com");
}
mockUser.setEmail1("user@test.com");
mockUser.setWebUrl1("http://www.user.com");
mockUser.setFirstName("firstNameUser");
mockUser.setName("nameUser");
mockUser.setPhoneNumber("9876543210");
mockUser.setAccountActivation(false);
mockUser.setId(5L);
mockUser.setRole(mockUserRole);
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOTest method testRead.
@Test
public void testRead() {
User user = userDAO.read(1L);
assertEquals("Test1", user.getName());
assertEquals("Role1", user.getRole().getRoleName());
user = userDAO.read(2L);
assertEquals("Test2", user.getName());
assertEquals("Role2", user.getRole().getRoleName());
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOTest method testFindUserFromName.
@Test
public void testFindUserFromName() {
User user = userDAO.findUserFromName("Test1");
assertEquals(Long.valueOf(1), user.getId());
user = userDAO.findUserFromName("test");
assertNull(user);
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOTest method testFindUserFromEmail.
@Test
public void testFindUserFromEmail() {
User user = userDAO.findUserFromEmail("test1@test.com");
assertEquals(Long.valueOf(1), user.getId());
assertEquals(2, user.getContractSet().size());
user = userDAO.findUserFromEmail("test@test.com");
assertNull(user);
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class OptionImplElementDAOTest method testFindOptionElementFromUserAndFamilyCode.
/**
* Test of findOptionElementFromUserAndFamilyCode method, of class OptionElementDAOImpl.
*/
@Test
public void testFindOptionElementFromUserAndFamilyCode() {
User user1 = userDAO.findUserFromEmail("test1@test.com");
User user2 = userDAO.findUserFromEmail("test2@test.com");
User user3 = userDAO.findUserFromEmail("test3@test.com");
Collection<OptionElementImpl> oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user1, "USER_OPTION");
assertEquals(2, oec.size());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user1, "ANOTHER_OPTION");
assertTrue(oec.isEmpty());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user2, "USER_OPTION");
assertEquals(1, oec.size());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user2, "ANOTHER_OPTION");
assertTrue(oec.isEmpty());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user3, "USER_OPTION");
assertTrue(oec.isEmpty());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user3, "ANOTHER_OPTION");
assertTrue(oec.isEmpty());
}
Aggregations