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());
}
}
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());
}
}
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());
}
}
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);
}
Aggregations