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_month.
@Test
public void should_send_email_when_contract_expires_in_1_month() throws MessagingException {
// create a user with a contract ending in 1 month from now
User user = SpringUtilsForTesting.createUser("contract-1m");
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(1));
}
use of com.autentia.tnt.dao.hibernate.UserDAO 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.dao.hibernate.UserDAO 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.dao.hibernate.UserDAO in project TNTConcept by autentia.
the class OfferTest method insertInitialData.
/**
* Metodo encargado de insertar datos muy generales pero que son necesarios
* para generar facturas en base a ofertas
*/
private void insertInitialData() {
final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
final ProjectDAO projectDAO = (ProjectDAO) SpringUtilsForTesting.getSpringBean("daoProject");
final OrganizationDAO organizationDAO = (OrganizationDAO) SpringUtilsForTesting.getSpringBean("daoOrganization");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
final UserDAO userDAO = (UserDAO) SpringUtilsForTesting.getSpringBean("daoUser");
final RoleDAO roleDAO = (RoleDAO) SpringUtilsForTesting.getSpringBean("daoRole");
final UserCategoryDAO categoryDAO = (UserCategoryDAO) SpringUtilsForTesting.getSpringBean("daoUserCategory");
final DepartmentDAO departmentDAO = (DepartmentDAO) SpringUtilsForTesting.getSpringBean("daoDepartment");
final WorkingAgreementDAO workingAgreementDAO = (WorkingAgreementDAO) SpringUtilsForTesting.getSpringBean("daoWorkingAgreement");
final Role role = new Role();
roleDAO.insert(role);
final Department department = new Department();
department.setName("departamento");
departmentDAO.insert(department);
final UserCategory category = new UserCategory();
categoryDAO.insert(category);
final WorkingAgreement workingAgreement = new WorkingAgreement();
workingAgreementDAO.insert(workingAgreement);
contact.setName("Sergio Hermida");
contactDAO.insert(contact);
projectDAO.insert(project);
organizationDAO.insert(organization);
user.setRole(role);
user.setCategory(category);
user.setDepartment(department);
user.setAgreement(workingAgreement);
userDAO.insert(user);
offer.setNumber(OFFER_NUMBER);
offer.setOrganization(organization);
offer.setContact(contact);
offer.setTitle(OFFER_TITLE);
offer.setDescription(OFFER_DESCRIPTION);
offer.setOfferPotential(OfferPotential.MEDIUM);
offer.setOfferState(OfferState.OPEN);
offer.setCreationDate(new Date());
offer.setMaturityDate(new Date());
offerDAO.insert(offer);
}
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_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));
}
Aggregations