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