resourceServer.setContactName("contact");
resourceServer.setScopes(Arrays.asList("read"));
resourceServer = repo.save(resourceServer);
// Create and save a client, associated with the resourceServer
Client c = new Client();
c.setName("name");
c.setClientId("clientid");
c.setSecret(UUID.randomUUID().toString());
c.setResourceServer(resourceServer);
resourceServer.setClients(new HashSet(Arrays.asList(c)));
c = clientRepo.save(c);
getEntityManager().getTransaction().commit();
// See that the client can be found
assertNotNull(clientRepo.findOne(c.getId()));
long resourceServerId = resourceServer.getId();
// Remove the resourceServer
getEntityManager().getTransaction().begin();
repo.delete(resourceServer);
getEntityManager().getTransaction().commit();
// Expect the resource server to be deleted
assertNull(repo.findOne(resourceServerId));
// Expect the client to be deleted as well.
final Client foundClient = clientRepo.findOne(c.getId());
assertNull(foundClient);
}