@Test
public void testIdempotentPersist() throws Exception {

  Request request = createNiceMock(Request.class);
  RequestBody body = createNiceMock(RequestBody.class);
  ResourceInstance resource = createNiceMock(ResourceInstance.class);
  PersistenceManager pm = createNiceMock(PersistenceManager.class);
  RequestStatus status = createNiceMock(RequestStatus.class);
  Resource resource1 = createNiceMock(Resource.class);
  Resource requestResource = createNiceMock(Resource.class);
  ConfigGroupNotFoundException configGroupNotFoundException = createNiceMock(ConfigGroupNotFoundException.class); 
  Query query = createNiceMock(Query.class);
  // expectations
  expect(request.getResource()).andReturn(resource).anyTimes();
  expect(request.getBody()).andReturn(body).atLeastOnce();
  expect(pm.delete(resource, body)).andThrow(
      new NoSuchResourceException("Configgroup not exist", configGroupNotFoundException));    
  
  replay(request, body, resource, pm, status, resource1, requestResource, query);
  Result result = new TestDeleteHandler(pm).persist(resource, body);
  assertNotNull(result);
  assertEquals(ResultStatus.STATUS.ACCEPTED, result.getStatus().getStatus());
}