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