@Test public void getViajeroTest() { ViajeroEntity entity = data.get(0); ViajeroEntity newEntity = viajeroPersistence.find(entity.getId()); Assert.assertNotNull(newEntity); Assert.assertEquals(entity.getName(), newEntity.getName()); }
@Test public void deleteViajeroTest() { ViajeroEntity entity = data.get(0); viajeroPersistence.delete(entity.getId()); ViajeroEntity deleted = em.find(ViajeroEntity.class, entity.getId()); Assert.assertNull(deleted); }
@Test public void getViajerosTest() { List<ViajeroEntity> list = viajeroPersistence.findAll(); Assert.assertEquals(data.size(), list.size()); for (ViajeroEntity ent : list) { boolean found = false; for (ViajeroEntity entity : data) { if (ent.getId().equals(entity.getId())) { found = true; } } Assert.assertTrue(found); } }
@Test public void updateViajeroTest() { ViajeroEntity entity = data.get(0); ViajeroEntity newEntity = factory.manufacturePojo(ViajeroEntity.class); newEntity.setId(entity.getId()); viajeroPersistence.update(newEntity); ViajeroEntity resp = em.find(ViajeroEntity.class, entity.getId()); Assert.assertEquals(newEntity.getName(), resp.getName()); }
@Test public void createViajeroTest() { ViajeroEntity newEntity = factory.manufacturePojo(ViajeroEntity.class); ViajeroEntity result = viajeroPersistence.create(newEntity); Assert.assertNotNull(result); ViajeroEntity entity = em.find(ViajeroEntity.class, result.getId()); Assert.assertEquals(newEntity.getName(), entity.getName()); }