Search in sources :

Example 51 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class RequestHolidayBean method getUserRequests.

// Getters to list possible values of related entities
/**
 * Get the list of all userRequests
 *
 * @return the list of all userRequests
 */
public List<SelectItem> getUserRequests() {
    List<User> refs = UserManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    for (User ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 52 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class UserHolidaysStateBean method getAll.

public List<UserHolidaysState> getAll() {
    List<UserHolidaysState> ret = new ArrayList<UserHolidaysState>();
    if (chargeYear == null)
        return ret;
    UserManager userManager = UserManager.getDefault();
    UserSearch searchUser = new UserSearch();
    searchUser.setActive(true);
    List<User> users = userManager.getAllEntities(searchUser, new SortCriteria(sortColumn, sortAscending));
    for (User us : users) {
        ret.add(manager.calculateUserHolidaysState(us, this.getChargeYear()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) UserManager(com.autentia.tnt.manager.admin.UserManager) ArrayList(java.util.ArrayList) UserHolidaysState(com.autentia.tnt.businessobject.UserHolidaysState) UserSearch(com.autentia.tnt.dao.search.UserSearch)

Example 53 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class ContactBean method getAllUsers.

public List<SelectItem> getAllUsers() {
    final List<User> refs = UserManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (User ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 54 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class LinkBeanTest method shouldProcessPasswordResetRequest.

@Test
public void shouldProcessPasswordResetRequest() {
    User testUser = new User();
    testUser.setLogin("testName");
    testUser.setActive(true);
    testUser.setEmail("test@mail.com");
    sutMock.setName("testName");
    Link testLink = new Link();
    testLink.setLink("randomLink");
    doReturn(testUser).when(sutMock).getUserByName("testName");
    doReturn(externalContext).when(sutMock).getFacesExternalContext();
    doReturn(testLink).when(sutMock).generateLink("testName");
    String result = sutMock.passwordResetRequest();
    verify(sutMock).sendMail(testLink, "test@mail.com");
    assertThat(result, equalTo("emailSent"));
}
Also used : User(com.autentia.tnt.businessobject.User) Link(com.autentia.tnt.businessobject.Link) Test(org.junit.Test)

Example 55 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class LinkBeanTest method shouldResetPasswordWithLdap.

@Test
public void shouldResetPasswordWithLdap() {
    User testUser = new User();
    testUser.setPassword("test");
    String[] x = new String[] { "x" };
    String[] y = new String[] { "y" };
    String[] z = new String[] { "z" };
    String[] v = new String[] { "v" };
    String[] w = new String[] { "w" };
    doReturn(x).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords0");
    doReturn(y).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords1");
    doReturn(z).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords2");
    doReturn(v).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords3");
    doReturn(w).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords4");
    doReturn("changed").when(authManager).resetPasswordExternal(testUser, x, y, z, v, w);
    doReturn(false).when(configurationUtil).isLdapProviderEnabled();
    String changedPassword = sutMock.resetPassword(testUser);
    verify(userManager).updateEntity(testUser, true);
    assertThat(changedPassword, equalTo("changed"));
}
Also used : User(com.autentia.tnt.businessobject.User) Test(org.junit.Test)

Aggregations

User (com.autentia.tnt.businessobject.User)70 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)17 SortCriteria (com.autentia.tnt.dao.SortCriteria)15 SelectItem (javax.faces.model.SelectItem)11 UserDAO (com.autentia.tnt.dao.hibernate.UserDAO)10 Date (java.util.Date)9 Link (com.autentia.tnt.businessobject.Link)6 UserSearch (com.autentia.tnt.dao.search.UserSearch)5 Attributes (javax.naming.directory.Attributes)5 BasicAttributes (javax.naming.directory.BasicAttributes)5 Activity (com.autentia.tnt.businessobject.Activity)4 Attribute (javax.naming.directory.Attribute)4 BasicAttribute (javax.naming.directory.BasicAttribute)4 GlobalHourReport (com.autentia.tnt.businessobject.GlobalHourReport)3 GlobalHoursReportBean (com.autentia.tnt.bean.activity.GlobalHoursReportBean)2 Commissioning (com.autentia.tnt.businessobject.Commissioning)2 Objective (com.autentia.tnt.businessobject.Objective)2 Occupation (com.autentia.tnt.businessobject.Occupation)2 DataIntegrityException (com.autentia.tnt.dao.DataIntegrityException)2