use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class GlobalHoursReportCSVServlet method getCSVBody.
private StringBuilder getCSVBody(List<GlobalHourReport> globalHourReports) {
StringBuilder sbBody = new StringBuilder();
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator(',');
DecimalFormat formatter = new DecimalFormat("#0.00", symbols);
for (GlobalHourReport report : globalHourReports) {
String organization = report.getProject().getClient().getName();
String project = report.getProject().getName();
java.util.Iterator<User> users = report.getIterator();
double totalHours = 0;
double totalCost = 0;
sbBody.append("\"").append(organization).append("\"").append(CSV_SEPARATOR).append("\"").append(project).append("\"");
while (users.hasNext()) {
User user = users.next();
double userProjectCost = report.getUserHours(user) * user.getSalaryPerHour();
totalHours += report.getUserHours(user);
totalCost += userProjectCost;
sbBody.append(CSV_SEPARATOR).append("\"").append(formatter.format(report.getUserHours(user))).append("\"").append(CSV_SEPARATOR).append("\"").append(formatter.format(userProjectCost)).append("\"");
}
sbBody.append(CSV_SEPARATOR).append("\"").append(formatter.format(totalHours)).append("\"").append(CSV_SEPARATOR).append("\"").append(formatter.format(totalCost)).append("\"").append("\r\n");
}
return sbBody;
}
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_month.
@Test
public void should_send_email_when_probation_period_expires_in_1_month() throws MessagingException {
// create a user with a probation of 1 month from now
User user = SpringUtilsForTesting.createUser("probation-1m");
user.setEndTestPeriodDate(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(1));
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class ContractExpirationNotificationBean_IT method should_send_email_when_contract_expires_in_1_day.
@Test
public void should_send_email_when_contract_expires_in_1_day() throws MessagingException {
// create a user with a contract ending tomorrow
User user = SpringUtilsForTesting.createUser("contract-1d");
user.setEndContractDate(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 ContractExpirationNotificationBean_IT method should_send_email_when_probation_period_expires_in_3_months.
@Test
public void should_send_email_when_probation_period_expires_in_3_months() throws MessagingException {
// create a user with a probation of 3 months from now
User user = SpringUtilsForTesting.createUser("probation-3m");
user.setEndTestPeriodDate(Date.from(LocalDate.now().plusMonths(3).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 ContractExpirationNotificationBean_IT method should_not_send_email_when_probation_expires_in_3_months_and_1_day.
@Test
public void should_not_send_email_when_probation_expires_in_3_months_and_1_day() throws MessagingException {
// create a user with a probation ending in 3 months and 1 day
User user = SpringUtilsForTesting.createUser("probation-3m-1d");
user.setEndTestPeriodDate(Date.from(LocalDate.now().plusMonths(3).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(0));
}
Aggregations