Search in sources :

Example 1 with OfferSearch

use of com.autentia.tnt.dao.search.OfferSearch 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)1 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 OfferDAO (com.autentia.tnt.dao.hibernate.OfferDAO)1 OfferSearch (com.autentia.tnt.dao.search.OfferSearch)1 OfferManager (com.autentia.tnt.manager.contacts.OfferManager)1 Test (org.junit.Test)1