Search in sources :

Example 26 with User

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

the class ContractExpirationNotificationBean_IT method should_not_send_email_when_user_is_inactive.

@Test
public void should_not_send_email_when_user_is_inactive() throws MessagingException {
    // create an inactive user with a contract ending in 1 month
    User user = SpringUtilsForTesting.createUser("inactive");
    user.setActive(false);
    user.setEndContractDate(Date.from(LocalDate.now().plusMonths(1).atStartOfDay(ZoneId.systemDefault()).toInstant()));
    UserDAO userDAO = (UserDAO) SpringUtils.getSpringBean("daoUser");
    userDAO.insert(user);
    ContractExpirationNotificationBean sut = new ContractExpirationNotificationBean(mailService);
    int userCount = sut.checkExpirationDate();
    assertThat(userCount, is(0));
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) Test(org.junit.Test)

Example 27 with User

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

the class ContractExpirationNotificationBean_IT method should_send_email_when_probation_period_expires_in_1_day.

@Test
public void should_send_email_when_probation_period_expires_in_1_day() throws MessagingException {
    // create a user with a probation ending tomorrow
    User user = SpringUtilsForTesting.createUser("probation-1d");
    user.setEndTestPeriodDate(Date.from(LocalDate.now().plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()));
    UserDAO userDAO = (UserDAO) SpringUtils.getSpringBean("daoUser");
    userDAO.insert(user);
    ContractExpirationNotificationBean sut = new ContractExpirationNotificationBean(mailService);
    int userCount = sut.checkExpirationDate();
    assertThat(userCount, is(1));
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) Test(org.junit.Test)

Example 28 with User

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

the class LinkBeanTest method shouldDismissPasswordResetRequestWithInactiveUser.

@Test
public void shouldDismissPasswordResetRequestWithInactiveUser() {
    User testUser = new User();
    testUser.setLogin("testName");
    testUser.setActive(false);
    sutMock.setName("testName");
    doReturn(testUser).when(userManager).getUserByLogin("testName");
    String result = sutMock.passwordResetRequest();
    verify(sutMock, never()).sendMail((Link) any(), any());
    assertThat(result, equalTo("emailSentFailed"));
}
Also used : User(com.autentia.tnt.businessobject.User) Test(org.junit.Test)

Example 29 with User

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

the class LinkBeanTest method shouldFailWhenCheckingWithNonExistentUser.

@Test
public void shouldFailWhenCheckingWithNonExistentUser() {
    Link testLink = new Link();
    testLink.setLink("linkTest");
    testLink.setUser("testUser");
    testLink.setInsertDate(new Date());
    doReturn(Arrays.asList(testLink)).when(sutMock).getLinksWithLink("linkTest");
    doReturn(new User()).when(sutMock).getUserByName("testUser");
    String result = sutMock.checkLinkAndResetPassword(testLink.getLink());
    assertThat(result, equalTo("<p>El enlace no existe o ha caducado</p>"));
}
Also used : User(com.autentia.tnt.businessobject.User) Link(com.autentia.tnt.businessobject.Link) Date(java.util.Date) Test(org.junit.Test)

Example 30 with User

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

the class GlobalHoursReportCSVServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String pStartDate = req.getParameter("startDate");
    String pEndDate = req.getParameter("endDate");
    String pBillable = req.getParameter("billable");
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    StringBuilder csvReport = new StringBuilder();
    GlobalHoursReportBean ghReportBean = (GlobalHoursReportBean) req.getSession().getAttribute("globalHoursReportBean");
    PrintWriter writer = resp.getWriter();
    try {
        Date startDate = sdf.parse(pStartDate);
        Date endDate = sdf.parse(pEndDate);
        boolean billable = Boolean.valueOf(pBillable);
        ghReportBean.setEndDate(endDate);
        ghReportBean.setStartDate(startDate);
        ghReportBean.setBillable(billable);
        List<User> users = ghReportBean.getUsers();
        List<GlobalHourReport> globalHourReports = ghReportBean.getAll();
        csvReport.append(getCSVHeader(users));
        csvReport.append(getCSVBody(globalHourReports));
        csvReport.append(getCSVFooter(users, globalHourReports));
        resp.setContentType("text/csv");
        resp.setContentLength(csvReport.length());
        writer.append(csvReport.toString());
    } catch (ParseException e) {
        Log.error("Error en el parseo ", e);
    } finally {
        writer.close();
    }
}
Also used : User(com.autentia.tnt.businessobject.User) GlobalHourReport(com.autentia.tnt.businessobject.GlobalHourReport) GlobalHoursReportBean(com.autentia.tnt.bean.activity.GlobalHoursReportBean) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) PrintWriter(java.io.PrintWriter)

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