Search in sources :

Example 11 with UserDAO

use of com.autentia.tnt.dao.hibernate.UserDAO 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 12 with UserDAO

use of com.autentia.tnt.dao.hibernate.UserDAO 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 13 with UserDAO

use of com.autentia.tnt.dao.hibernate.UserDAO 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

UserDAO (com.autentia.tnt.dao.hibernate.UserDAO)13 User (com.autentia.tnt.businessobject.User)10 Test (org.junit.Test)9 DepartmentDAO (com.autentia.tnt.dao.hibernate.DepartmentDAO)3 RoleDAO (com.autentia.tnt.dao.hibernate.RoleDAO)3 UserCategoryDAO (com.autentia.tnt.dao.hibernate.UserCategoryDAO)3 WorkingAgreementDAO (com.autentia.tnt.dao.hibernate.WorkingAgreementDAO)3 ContactDAO (com.autentia.tnt.dao.hibernate.ContactDAO)2 OfferDAO (com.autentia.tnt.dao.hibernate.OfferDAO)2 OrganizationDAO (com.autentia.tnt.dao.hibernate.OrganizationDAO)2 ProjectDAO (com.autentia.tnt.dao.hibernate.ProjectDAO)2 Date (java.util.Date)2 Department (com.autentia.tnt.businessobject.Department)1 OfferRole (com.autentia.tnt.businessobject.OfferRole)1 Role (com.autentia.tnt.businessobject.Role)1 UserCategory (com.autentia.tnt.businessobject.UserCategory)1 WorkingAgreement (com.autentia.tnt.businessobject.WorkingAgreement)1