private void insertData() { viajero = factory.manufacturePojo(ViajeroEntity.class); em.persist(viajero); for (int i = 0; i < 3; i++) { ItinerarioEntity entity = factory.manufacturePojo(ItinerarioEntity.class); entity.setViajero(viajero); em.persist(entity); data.add(entity); } for (int i = 0; i < 3; i++) { FotoEntity fotos = factory.manufacturePojo(FotoEntity.class); DiaEntity dias = factory.manufacturePojo(DiaEntity.class); fotos.setItinerario(data.get(0)); dias.setItinerario(data.get(0)); em.persist(dias); diaData.add(dias); em.persist(fotos); fotoData.add(fotos); } }
@Test public void addPhotosTest() throws BusinessLogicException { ItinerarioEntity entity = data.get(0); FotoEntity fotoEntity = factory.manufacturePojo(FotoEntity.class); FotoEntity response = itinerarioLogic.addPhoto(viajero.getId(), entity.getId(), fotoEntity); Assert.assertNotNull(response); Assert.assertEquals(fotoEntity.getId(), response.getId()); }
@Test public void getPhotoTest() { ItinerarioEntity entity = data.get(0); FotoEntity fotoEntity = fotoData.get(0); FotoEntity response = itinerarioLogic.getPhoto(viajero.getId(), entity.getId(), fotoEntity.getId()); Assert.assertEquals(fotoEntity.getId(), response.getId()); Assert.assertEquals(fotoEntity.getName(), response.getName()); Assert.assertEquals(fotoEntity.getSrc(), response.getSrc()); }