@Test public void testFindAllWithClientServiceShouldPass() throws Exception { List<Client> clients = clientService.findAll(); clientService.create(client); List<Client> result = clientService.findAll(); assertThat(result.size(), is(clients.size() + 1)); }
@Test public void testFindByIdWithClientServiceShouldPass() throws Exception { client.setName("test findById"); clientService.create(client); Integer insertedId = client.getId(); Client result = clientService.findById(insertedId); assertThat(result.getName(), is("test findById")); }
@Test public void testDeleteWithClientServiceShouldPass() throws Exception { clientService.create(client); Integer insertedId = client.getId(); Client delete = clientService.findById(insertedId); clientService.delete(delete); Client result = clientService.findById(delete.getId()); assertNull(result); }
private Group createGroup(Client client) { Group group = new Group(); group.setName("Test Group" + RandomStringUtils.randomAlphanumeric(9)); group.setClient(clientService.reload(client)); groupService.save(group); return group; }
private Client createClient() { UserAdmin user = new UserAdmin(1l, 0); Client client = new Client(); client.setTier(new ClientTier(3l)); client.setContractEnd(LocalDate.now().plusYears(1)); client.setContractStart(LocalDate.now()); client.setRegion(new ClientRegion(1l)); client.setName("Test Client " + RandomStringUtils.randomAlphanumeric(18)); client.setType(new ClientType(1l)); client.setContractOwner(user); client.setActive(false); client.setSalesForceAccount(new SalesForce(RandomStringUtils.randomAlphanumeric(18))); clientService.create(client); return client; }