Search in sources :

Example 56 with User

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;
}
Also used : GlobalHourReport(com.autentia.tnt.businessobject.GlobalHourReport) User(com.autentia.tnt.businessobject.User) DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat)

Example 57 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_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));
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) Test(org.junit.Test)

Example 58 with User

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));
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) Test(org.junit.Test)

Example 59 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_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));
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) Test(org.junit.Test)

Example 60 with User

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));
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) 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