use of com.autentia.tnt.dao.hibernate.OfferDAO in project TNTConcept by autentia.
the class DuplicateOfferTest method testDuplicateOfferWithRolesAndCosts.
/**
* Comprobacion de que se duplique la oferta con relaciones con costes, personal e interacciones
*/
@Test
public void testDuplicateOfferWithRolesAndCosts() {
final OfferManager offerManager = (OfferManager) SpringUtilsForTesting.getSpringBean("managerOffer");
final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
insertInitialData();
insertOfferCosts();
insertOfferRoles();
insertOfferInteraction();
final Offer duplicated = offerManager.duplicateOffer(offer);
duplicated.setNumber("123456");
offerDAO.insert(duplicated);
if (duplicated.getCosts().size() != 2) {
fail("deberia haber 2 costes por materiales en el duplicado en vez de '" + duplicated.getCosts().size() + "'");
}
if (duplicated.getRoles().size() != 2) {
fail("deberia haber 2 costes por roles en el duplicado en vez de '" + duplicated.getRoles().size() + "'");
}
if (duplicated.getInteractions().size() != 1) {
fail("deberia haber 1 interacciones en el duplicado en vez de '" + duplicated.getInteractions().size() + "'");
}
}
use of com.autentia.tnt.dao.hibernate.OfferDAO 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);
}
use of com.autentia.tnt.dao.hibernate.OfferDAO in project TNTConcept by autentia.
the class OfferTest method testOfferRoleNameLength.
@Test
public void testOfferRoleNameLength() {
final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
insertInitialData();
insertOfferRoles();
chapista.setName(VERY_LARGE_TEXT);
offerDAO.update(offer);
if (!chapista.getName().equals(MAX_TEXT)) {
fail("el nombre del rol deberia tener una longitud de " + Offer.MAX_LENGTH + " caracteres, pero tiene " + chapista.getName().length());
}
}
use of com.autentia.tnt.dao.hibernate.OfferDAO in project TNTConcept by autentia.
the class OfferTest method testOfferDescriptionLength.
@Test
public void testOfferDescriptionLength() {
final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
insertInitialData();
offer.setDescription(VERY_LARGE_TEXT);
offerDAO.update(offer);
if (!offer.getDescription().equals(MAX_TEXT)) {
fail("la descripcion deberia tener una longitud de " + Offer.MAX_LENGTH + " caracteres, pero tiene " + offer.getDescription().length());
}
}
use of com.autentia.tnt.dao.hibernate.OfferDAO in project TNTConcept by autentia.
the class FromOfferToBillTest 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");
contact.setName("Sergio Hermida");
contactDAO.insert(contact);
projectDAO.insert(project);
organizationDAO.insert(organization);
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());
offerDAO.insert(offer);
}
Aggregations