RequestManager implements AutoCloseable { public Request<Message> createRequest(String id, ResponseTranslator translator) { Request<Message> ret = new Request<>(this, id, translator); if (this.outstandingRequests.get(id) != null) { throw new IllegalArgumentException("Already have a request with id: " + id); } this.outstandingRequests.put(id, ret); return ret; }  void markDone(Request request); Request<Message> createRequest(String id,
      ResponseTranslator translator); @Override void close(); Request getRequest(String correlationId);  }
@Test public void createDuplicates() throws Exception{ RequestManager manager = new RequestManager(); ResponseTranslator translator = Mockito.mock(ResponseTranslator.class); String id = "1"; manager.createRequest(id, translator); try { manager.createRequest(id, translator); fail("Should not be able to create the same request twice"); }catch (Exception e){ } }