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));
}
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));
}
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"));
}
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>"));
}
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();
}
}
Aggregations