@Override @Transactional public void remove(ApprovedSite approvedSite) { ApprovedSite found = manager.find(ApprovedSite.class, approvedSite.getId()); if (found != null) { manager.remove(found); } else { throw new IllegalArgumentException(); } }
@Override @Transactional public ApprovedSite save(ApprovedSite approvedSite) { return saveOrUpdate(approvedSite.getId(), manager, approvedSite); }
/** * Prepares a collection of ApprovedSite mocks to be returned from the approvedSiteService and a * collection of ClientDetailEntity mocks to be returned from the clientService. */ @Before public void prepare() { Mockito.reset(approvedSiteService, clientService); Mockito.when(ap1.getUserId()).thenReturn(userId1); Mockito.when(ap1.getClientId()).thenReturn(clientId1); Mockito.when(ap2.getUserId()).thenReturn(userId1); Mockito.when(ap2.getClientId()).thenReturn(clientId1); Mockito.when(ap3.getUserId()).thenReturn(userId2); Mockito.when(ap3.getClientId()).thenReturn(clientId2); Mockito.when(ap4.getUserId()).thenReturn(userId2); Mockito.when(ap4.getClientId()).thenReturn(clientId3); Mockito.when(ap5.getUserId()).thenReturn(userId2); Mockito.when(ap5.getClientId()).thenReturn(clientId1); Mockito.when(ap6.getUserId()).thenReturn(userId1); Mockito.when(ap6.getClientId()).thenReturn(clientId4); Mockito.when(approvedSiteService.getAll()).thenReturn(Sets.newHashSet(ap1, ap2, ap3, ap4)); Mockito.when(client1.getId()).thenReturn(1L); Mockito.when(client2.getId()).thenReturn(2L); Mockito.when(client3.getId()).thenReturn(3L); Mockito.when(client4.getId()).thenReturn(4L); Mockito.when(clientService.getAllClients()) .thenReturn(Sets.newHashSet(client1, client2, client3, client4)); Mockito.when(clientService.loadClientByClientId(clientId1)).thenReturn(client1); Mockito.when(clientService.loadClientByClientId(clientId2)).thenReturn(client2); Mockito.when(clientService.loadClientByClientId(clientId3)).thenReturn(client3); Mockito.when(clientService.loadClientByClientId(clientId4)).thenReturn(client4); }