CommitHandler { void complete(CommitResponse response) { CompletableFuture<Boolean> result; synchronized (commits) { result = commits.remove(response.getCorrelationId()); } if (result != null) { result.complete(response.isSuccess()); } else { throw new IllegalStateException("Received response for unknown commit: " + response); } }    }
@Test(expected = IllegalStateException.class) public void unknownCommit() throws Exception { underTest.complete(new CommitResponse(correlationId, true)); }