Search in sources :

Example 1 with OfferManager

use of com.autentia.tnt.manager.contacts.OfferManager 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() + "'");
    }
}
Also used : 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 2 with OfferManager

use of com.autentia.tnt.manager.contacts.OfferManager 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)

Aggregations

Offer (com.autentia.tnt.businessobject.Offer)2 OfferDAO (com.autentia.tnt.dao.hibernate.OfferDAO)2 OfferManager (com.autentia.tnt.manager.contacts.OfferManager)2 Test (org.junit.Test)2 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 OfferSearch (com.autentia.tnt.dao.search.OfferSearch)1