/** @generated */ @Test public void getClientPaginationTest() { // Page 1 List<ClientEntity> ent1 = clientPersistence.findAll(1, 2); Assert.assertNotNull(ent1); Assert.assertEquals(2, ent1.size()); // Page 2 List<ClientEntity> ent2 = clientPersistence.findAll(2, 2); Assert.assertNotNull(ent2); Assert.assertEquals(1, ent2.size()); for (ClientEntity ent : ent1) { boolean found = false; for (ClientEntity entity : data) { if (ent.getId().equals(entity.getId())) { found = true; } } Assert.assertTrue(found); } for (ClientEntity ent : ent2) { boolean found = false; for (ClientEntity entity : data) { if (ent.getId().equals(entity.getId())) { found = true; } } Assert.assertTrue(found); } }
/** @generated */ @Test public void findByName() { String name = data.get(0).getName(); List<ClientEntity> cache = new ArrayList<ClientEntity>(); List<ClientEntity> list = clientPersistence.findByName(name); for (ClientEntity entity : data) { if (entity.getName().equals(name)) { cache.add(entity); } } Assert.assertEquals(list.size(), cache.size()); for (ClientEntity ent : list) { boolean found = false; for (ClientEntity cacheEntity : cache) { if (cacheEntity.getName().equals(ent.getName())) { found = true; break; } } if (!found) { Assert.fail(); } } }
/** @generated */ @Test public void deleteClientTest() { ClientEntity entity = data.get(0); clientPersistence.delete(entity.getId()); ClientEntity deleted = em.find(ClientEntity.class, entity.getId()); Assert.assertNull(deleted); }
/** @generated */ @Test public void getClientTest() { ClientEntity entity = data.get(0); ClientEntity newEntity = clientPersistence.find(entity.getId()); Assert.assertNotNull(newEntity); Assert.assertEquals(entity.getName(), newEntity.getName()); Assert.assertEquals(entity.getUserId(), newEntity.getUserId()); }
/** @generated */ @Test public void getClientsTest() { List<ClientEntity> list = clientPersistence.findAll(null, null); Assert.assertEquals(data.size(), list.size()); for (ClientEntity ent : list) { boolean found = false; for (ClientEntity entity : data) { if (ent.getId().equals(entity.getId())) { found = true; } } Assert.assertTrue(found); } }
/** @generated */ @Test public void createClientTest() { ClientEntity newEntity = new ClientEntity(); newEntity.setName(generateRandom(String.class)); newEntity.setUserId(generateRandom(String.class)); ClientEntity result = clientPersistence.create(newEntity); Assert.assertNotNull(result); ClientEntity entity = em.find(ClientEntity.class, result.getId()); Assert.assertEquals(newEntity.getName(), entity.getName()); Assert.assertEquals(newEntity.getUserId(), entity.getUserId()); }
/** @generated */ @Test public void updateClientTest() { ClientEntity entity = data.get(0); ClientEntity newEntity = new ClientEntity(); newEntity.setId(entity.getId()); newEntity.setName(generateRandom(String.class)); newEntity.setUserId(generateRandom(String.class)); clientPersistence.update(newEntity); ClientEntity resp = em.find(ClientEntity.class, entity.getId()); Assert.assertEquals(newEntity.getName(), resp.getName()); Assert.assertEquals(newEntity.getUserId(), resp.getUserId()); }