Search in sources :

Example 6 with ContactDAO

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

the class ContactPositionManagerTest method testDoAdvancedSearchBusyPosition.

/**
 * Buscar por puesto ocupado
 */
@Test
public void testDoAdvancedSearchBusyPosition() {
    final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
    final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
    final ContactPositionManager contactPositionManager = new ContactPositionManager(contactDAO, positionDAO);
    this.insertInitialData();
    this.insertContactData();
    final AdvancedSearchContactSearch advancedSearch = new AdvancedSearchContactSearch();
    final List<Position> positions = new ArrayList<Position>();
    positions.add(becario);
    advancedSearch.setPositions(positions);
    final List<ContactPosition> contactPositions = contactPositionManager.doAdvancedSearch(advancedSearch, JUST_ACTIVE);
    // debe salir un resultado, que es Antonio Ruiz ya que posee el cargo de becario
    if (contactPositions.size() != 1) {
        fail("Deberia haber salido 1 resultado (1 contacto), pero han salido " + contactPositions.size());
    }
    if (!contactPositions.get(0).getName().equals("Antonio Ruiz")) {
        fail("El resultado debería haber sido 'Antonio Ruiz', pero ha sido " + contactPositions.get(0).getName());
    }
}
Also used : PositionDAO(com.autentia.tnt.dao.hibernate.PositionDAO) AdvancedSearchContactSearch(com.autentia.tnt.dao.search.AdvancedSearchContactSearch) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) Position(com.autentia.tnt.businessobject.Position) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with ContactDAO

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

the class ContactPositionManagerTest method testDoAdvancedSearchEmptyPosition.

/**
 * Buscar por puesto libre
 */
@Test
public void testDoAdvancedSearchEmptyPosition() {
    final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
    final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
    final ContactPositionManager contactPositionManager = new ContactPositionManager(contactDAO, positionDAO);
    this.insertInitialData();
    this.insertContactData();
    final AdvancedSearchContactSearch advancedSearch = new AdvancedSearchContactSearch();
    final List<Position> positions = new ArrayList<Position>();
    positions.add(responsableDireccion);
    advancedSearch.setPositions(positions);
    final List<ContactPosition> contactPositions = contactPositionManager.doAdvancedSearch(advancedSearch, JUST_ACTIVE);
    // debe salir un resultado que es el puesto sin ocupantes
    if (contactPositions.size() != 1) {
        fail("Deberia haber salido 1 resultado (1 puesto), pero han salido " + contactPositions.size());
    }
    if (!contactPositions.get(0).getPosition().equals("Responsable de Dirección")) {
        fail("El resultado debería haber sido 'Responsable de Dirección', pero ha sido " + contactPositions.get(0).getPosition());
    }
}
Also used : PositionDAO(com.autentia.tnt.dao.hibernate.PositionDAO) AdvancedSearchContactSearch(com.autentia.tnt.dao.search.AdvancedSearchContactSearch) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) Position(com.autentia.tnt.businessobject.Position) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with ContactDAO

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

the class ContactPositionManagerTest method testDoAdvancedSearchHistoricalSimpleValue.

/**
 * Buscar por en historico y en activo
 */
@Test
public void testDoAdvancedSearchHistoricalSimpleValue() {
    final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
    final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
    final EntityChangeDAO entityChangeDAO = (EntityChangeDAO) SpringUtilsForTesting.getSpringBean("daoEntityChange");
    final ContactPositionManager contactPositionManager = new ContactPositionManager(contactDAO, positionDAO);
    this.insertInitialData();
    this.insertContactData();
    // añadimos que Pilar Sancho trabajaba en Italia
    final EntityChange changePosition = new EntityChange();
    changePosition.setField(Contact.FIELD_COUNTRY);
    changePosition.setNewValue("España");
    changePosition.setOldValue("Italia");
    changePosition.setEntityId(pilarSancho.getId());
    changePosition.setEntityName("com.autentia.tnt.businessobject.Contact");
    entityChangeDAO.insert(changePosition);
    final AdvancedSearchContactSearch advancedSearch = new AdvancedSearchContactSearch();
    advancedSearch.setCountry("Italia");
    final List<ContactPosition> contactPositions = contactPositionManager.doAdvancedSearch(advancedSearch, ACTIVE_AND_HISTORICAL);
    // debe salir dos resultados, ya que hay uno que es becario actualmente y otro que lo fue
    if (contactPositions.size() != 1) {
        fail("Deberia haber salido 1 resultado, pero han salido " + contactPositions.size());
    }
}
Also used : PositionDAO(com.autentia.tnt.dao.hibernate.PositionDAO) AdvancedSearchContactSearch(com.autentia.tnt.dao.search.AdvancedSearchContactSearch) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) EntityChange(com.autentia.tnt.tracking.EntityChange) EntityChangeDAO(com.autentia.tnt.tracking.hibernate.dao.EntityChangeDAO) Test(org.junit.Test)

Example 9 with ContactDAO

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

Aggregations

ContactDAO (com.autentia.tnt.dao.hibernate.ContactDAO)9 PositionDAO (com.autentia.tnt.dao.hibernate.PositionDAO)6 AdvancedSearchContactSearch (com.autentia.tnt.dao.search.AdvancedSearchContactSearch)5 Test (org.junit.Test)5 Position (com.autentia.tnt.businessobject.Position)3 OfferDAO (com.autentia.tnt.dao.hibernate.OfferDAO)3 OrganizationDAO (com.autentia.tnt.dao.hibernate.OrganizationDAO)3 ProjectDAO (com.autentia.tnt.dao.hibernate.ProjectDAO)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 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 EntityChange (com.autentia.tnt.tracking.EntityChange)2 EntityChangeDAO (com.autentia.tnt.tracking.hibernate.dao.EntityChangeDAO)2 ContactInfo (com.autentia.tnt.businessobject.ContactInfo)1 Department (com.autentia.tnt.businessobject.Department)1 OfferRole (com.autentia.tnt.businessobject.OfferRole)1