@Test(expected = InternalServerErrorException.class)
 public void testAddResourceServerAlreadyExists() throws Exception {
   try {
     resource.add(ResourceServerDataGenerator.generateResourceServerDTO(NAME));
     resource.add(ResourceServerDataGenerator.generateResourceServerDTO(NAME));
   } finally {
     resource.delete(NAME);
   }
 }
 @Test
 public void testGetResourceServer() throws Exception {
   try {
     resource.add(ResourceServerDataGenerator.generateResourceServerDTO(NAME));
     ResourceServerDTO result = resource.get(NAME);
     assertResourceServer(result);
   } finally {
     resource.delete(NAME);
   }
 }
 @Test
 public void testUpdateResourceServer() throws Exception {
   try {
     resource.add(ResourceServerDataGenerator.generateResourceServerDTO(NAME));
     Set<String> groupFilter = new HashSet<String>(Arrays.asList("a", "b"));
     ResourceServerDTO rsToUpdate =
         ResourceServerDTO.builder().withName(NAME).withGroupFilter(groupFilter).build();
     ResourceServerDTO updatedRS = resource.update(NAME, rsToUpdate);
     assertEquals(groupFilter, updatedRS.getGroupFilter());
   } finally {
     resource.delete(NAME);
   }
 }
 @Before
 public void setUp() {
   request = EasyMock.createMock(ContainerRequestContext.class);
   EasyMock.expect(request.getLanguage()).andReturn(Locale.getDefault()).anyTimes();
   EasyMock.expect(request.getHeaderString(Config.CORRELATION_ID_HEADER))
       .andReturn("test")
       .anyTimes();
   EasyMock.replay(request);
   resource = new ResourceServerResource(DEFAULT_TENANT, request, null);
   resource.setIDMClient(idmClient);
 }
 @Test
 public void testGetAllResourceServers() throws Exception {
   try {
     resource.add(ResourceServerDataGenerator.generateResourceServerDTO(NAME));
     Collection<ResourceServerDTO> result = resource.getAll();
     assertEquals(1, result.size());
     resource.add(
         ResourceServerDataGenerator.generateResourceServerDTO("rs_another_resource_server"));
     result = resource.getAll();
     assertEquals(2, result.size());
   } finally {
     resource.delete(NAME);
     resource.delete("rs_another_resource_server");
   }
 }
 @Test(expected = NotFoundException.class)
 public void testUpdateResourceServerDoesNotExist() throws Exception {
   ResourceServerDTO rsToUpdate = ResourceServerDTO.builder().withName(NAME_NON_EXISTENT).build();
   resource.update(NAME_NON_EXISTENT, rsToUpdate);
 }
 @Test(expected = NotFoundException.class)
 public void testDeleteResourceServerDoesNotExist() throws Exception {
   resource.delete(NAME_NON_EXISTENT);
 }
 public void testDeleteResourceServer() throws Exception {
   resource.add(ResourceServerDataGenerator.generateResourceServerDTO(NAME));
   resource.delete(NAME);
   Collection<ResourceServerDTO> result = resource.getAll();
   assertEquals(0, result.size());
 }
 @Test(expected = NotFoundException.class)
 public void testGetResourceServerDoesNotExist() throws Exception {
   ResourceServerDTO result = resource.get(NAME_NON_EXISTENT);
 }