RequestManager implements AutoCloseable { @Override public void close() throws Exception { List<Request> requests = new ArrayList(outstandingRequests.values()); for (Request request : requests) { request.markDone(); } }  void markDone(Request request); Request<Message> createRequest(String id,
      ResponseTranslator translator); @Override void close(); Request getRequest(String correlationId);  }
@Test public void close() throws Exception{ RequestManager manager = new RequestManager(); ResponseTranslator translator = Mockito.mock(ResponseTranslator.class); String [] ids = new String[]{"1", "2", "3"}; manager.createRequest(ids[0], translator); manager.createRequest(ids[1], translator); manager.createRequest(ids[2], translator); manager.close(); assertNull(manager.getRequest(ids[0])); assertNull(manager.getRequest(ids[1])); assertNull(manager.getRequest(ids[2])); }