Search in sources :

Example 6 with OfferDAO

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

the class DuplicateOfferTest method testDuplicateOfferWithSimpleDataOnly.

/**
 * Comprobacion de que se duplique la oferta sin relaciones 1:N
 */
@Test
public void testDuplicateOfferWithSimpleDataOnly() {
    final OfferManager offerManager = (OfferManager) SpringUtilsForTesting.getSpringBean("managerOffer");
    final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
    insertInitialData();
    final Offer duplicated = offerManager.duplicateOffer(offer);
    if (duplicated.getId() != null) {
        fail("el id debe ser 'null' en vez de '" + duplicated.getId() + "'");
    }
    if (duplicated.getNumber() != null) {
        fail("el numero debe ser '" + offer.getNumber() + "' en vez de '" + duplicated.getNumber() + "'");
    }
    if (!duplicated.getContact().equals(offer.getContact())) {
        fail("el contacto debe ser '" + offer.getContact().getName() + "' en vez de '" + duplicated.getContact().getName() + "'");
    }
    if (!duplicated.getMaturityDate().equals(offer.getMaturityDate())) {
        fail("la fecha de madurez debe ser '" + offer.getMaturityDate() + "' en vez de '" + duplicated.getMaturityDate() + "'");
    }
    duplicated.setNumber("123456");
    offerDAO.insert(duplicated);
    if (offerManager.getAllEntities(new OfferSearch(), new SortCriteria()).size() != 2) {
        fail("deberia haber 2 ofertas en vez de '" + offerManager.getAllEntities(new OfferSearch(), new SortCriteria()).size() + "'");
    }
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) OfferSearch(com.autentia.tnt.dao.search.OfferSearch) Offer(com.autentia.tnt.businessobject.Offer) OfferManager(com.autentia.tnt.manager.contacts.OfferManager) OfferDAO(com.autentia.tnt.dao.hibernate.OfferDAO) Test(org.junit.Test)

Example 7 with OfferDAO

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

the class OfferTest method testOfferCostNameLength.

@Test
public void testOfferCostNameLength() {
    final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
    insertInitialData();
    insertOfferCosts();
    paneles.setName(VERY_LARGE_TEXT);
    offerDAO.update(offer);
    if (!paneles.getName().equals(MAX_TEXT)) {
        fail("el nombre del material deberia tener una longitud de " + Offer.MAX_LENGTH + " caracteres, pero tiene " + paneles.getName().length());
    }
}
Also used : OfferDAO(com.autentia.tnt.dao.hibernate.OfferDAO) Test(org.junit.Test)

Example 8 with OfferDAO

use of com.autentia.tnt.dao.hibernate.OfferDAO 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);
}
Also used : DepartmentDAO(com.autentia.tnt.dao.hibernate.DepartmentDAO) Date(java.util.Date) WorkingAgreementDAO(com.autentia.tnt.dao.hibernate.WorkingAgreementDAO) 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)

Example 9 with OfferDAO

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

the class OfferTest method testOfferObservationsLength.

@Test
public void testOfferObservationsLength() {
    final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
    insertInitialData();
    offer.setObservations(VERY_LARGE_TEXT);
    offerDAO.update(offer);
    if (!offer.getObservations().equals(MAX_TEXT)) {
        fail("las observaciones deberian tener una longitud de " + Offer.MAX_LENGTH + " caracteres, pero tienen " + offer.getObservations().length());
    }
}
Also used : OfferDAO(com.autentia.tnt.dao.hibernate.OfferDAO) Test(org.junit.Test)

Aggregations

OfferDAO (com.autentia.tnt.dao.hibernate.OfferDAO)9 Test (org.junit.Test)6 ContactDAO (com.autentia.tnt.dao.hibernate.ContactDAO)3 OrganizationDAO (com.autentia.tnt.dao.hibernate.OrganizationDAO)3 ProjectDAO (com.autentia.tnt.dao.hibernate.ProjectDAO)3 Date (java.util.Date)3 Offer (com.autentia.tnt.businessobject.Offer)2 DepartmentDAO (com.autentia.tnt.dao.hibernate.DepartmentDAO)2 RoleDAO (com.autentia.tnt.dao.hibernate.RoleDAO)2 UserCategoryDAO (com.autentia.tnt.dao.hibernate.UserCategoryDAO)2 UserDAO (com.autentia.tnt.dao.hibernate.UserDAO)2 WorkingAgreementDAO (com.autentia.tnt.dao.hibernate.WorkingAgreementDAO)2 OfferManager (com.autentia.tnt.manager.contacts.OfferManager)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 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 OfferSearch (com.autentia.tnt.dao.search.OfferSearch)1