Search in sources :

Example 1 with UserDAO

use of com.autentia.tnt.dao.hibernate.UserDAO in project TNTConcept by autentia.

the class DuplicateOfferTest 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);
}
Also used : UserCategory(com.autentia.tnt.businessobject.UserCategory) DepartmentDAO(com.autentia.tnt.dao.hibernate.DepartmentDAO) Date(java.util.Date) WorkingAgreementDAO(com.autentia.tnt.dao.hibernate.WorkingAgreementDAO) Role(com.autentia.tnt.businessobject.Role) OfferRole(com.autentia.tnt.businessobject.OfferRole) Department(com.autentia.tnt.businessobject.Department) UserCategoryDAO(com.autentia.tnt.dao.hibernate.UserCategoryDAO) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) RoleDAO(com.autentia.tnt.dao.hibernate.RoleDAO) OfferDAO(com.autentia.tnt.dao.hibernate.OfferDAO) OrganizationDAO(com.autentia.tnt.dao.hibernate.OrganizationDAO) ProjectDAO(com.autentia.tnt.dao.hibernate.ProjectDAO) WorkingAgreement(com.autentia.tnt.businessobject.WorkingAgreement)

Example 2 with UserDAO

use of com.autentia.tnt.dao.hibernate.UserDAO in project TNTConcept by autentia.

the class SpringUtilsForTesting method createUserInContextWithRoleAndDepartment.

public static User createUserInContextWithRoleAndDepartment() {
    setUserForTestingInContext();
    final User user = new User();
    user.setLogin("admin");
    user.setRole(createRoleInContext());
    user.setDepartment(createDepartmentInContext());
    user.setCategory(createUserCategoryInContext());
    user.setAgreement(createAgreementInContext());
    final UserDAO userDao = (UserDAO) appCtx.getBean("daoUser");
    userDao.insert(user);
    user.setActive(true);
    return user;
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO)

Example 3 with UserDAO

use of com.autentia.tnt.dao.hibernate.UserDAO in project TNTConcept by autentia.

the class SpringUtilsForTesting method deleteUserInContext.

public static void deleteUserInContext(User userInContext) {
    final UserDAO userDao = (UserDAO) appCtx.getBean("daoUser");
    userDao.delete(userInContext);
    final UserCategoryDAO userCategoryDAO = (UserCategoryDAO) appCtx.getBean("daoUserCategory");
    userCategoryDAO.delete(userInContext.getCategory());
    final WorkingAgreementDAO workingAgreementDAO = (WorkingAgreementDAO) appCtx.getBean("daoWorkingAgreement");
    workingAgreementDAO.delete(userInContext.getAgreement());
    final RoleDAO roleDao = (RoleDAO) appCtx.getBean("daoRole");
    roleDao.delete(userInContext.getRole());
    final DepartmentDAO departmentDao = (DepartmentDAO) appCtx.getBean("daoDepartment");
    departmentDao.delete(userInContext.getDepartment());
}
Also used : UserCategoryDAO(com.autentia.tnt.dao.hibernate.UserCategoryDAO) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) RoleDAO(com.autentia.tnt.dao.hibernate.RoleDAO) DepartmentDAO(com.autentia.tnt.dao.hibernate.DepartmentDAO) WorkingAgreementDAO(com.autentia.tnt.dao.hibernate.WorkingAgreementDAO)

Example 4 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_contract_expires_in_3_months_and_1_day.

@Test
public void should_not_send_email_when_contract_expires_in_3_months_and_1_day() throws MessagingException {
    // create a user with a contract ending in 3 months and 1 day
    User user = SpringUtilsForTesting.createUser("contract-3m-1d");
    user.setEndContractDate(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)

Example 5 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_3_months.

@Test
public void should_send_email_when_contract_expires_in_3_months() throws MessagingException {
    // create a user with a contract ending in 3 months from now
    User user = SpringUtilsForTesting.createUser("contract-3m");
    user.setEndContractDate(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)

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