@Test
public void testHandleRequest__Asynchronous() throws Exception {
Request request = createMock(Request.class);
RequestBody body = createNiceMock(RequestBody.class);
ResourceInstance resource = createMock(ResourceInstance.class);
PersistenceManager pm = createStrictMock(PersistenceManager.class);
RequestStatus status = createMock(RequestStatus.class);
Resource resource1 = createMock(Resource.class);
Resource resource2 = createMock(Resource.class);
Resource requestResource = createMock(Resource.class);
Predicate userPredicate = createNiceMock(Predicate.class);
Query query = createNiceMock(Query.class);
Renderer renderer = new DefaultRenderer();
Set<Resource> setResources = new HashSet<Resource>();
setResources.add(resource1);
setResources.add(resource2);
// expectations
expect(request.getResource()).andReturn(resource).anyTimes();
expect(request.getBody()).andReturn(body).anyTimes();
expect(request.getQueryPredicate()).andReturn(userPredicate).atLeastOnce();
expect(request.getRenderer()).andReturn(renderer);
expect(resource.getQuery()).andReturn(query).atLeastOnce();
query.setRenderer(renderer);
query.setUserPredicate(userPredicate);
expect(pm.update(resource, body)).andReturn(status);
expect(status.getStatus()).andReturn(RequestStatus.Status.Accepted);