### Question:
FuturePublishCallback extends CompletableFuture<Long> implements PublishCallback { @Override public void onComplete(long offset, Throwable error) { if (error != null) { completeExceptionally(error); } else { complete(offset); } }  @Override void onComplete(long offset, Throwable error);  }### Answer:
@Test public void testWithSuccess() throws InterruptedException, ExecutionException { final FuturePublishCallback f = new FuturePublishCallback(); f.onComplete(10, null); assertEquals(10, (long) f.get()); }
@Test(expected=ExecutionException.class) public void testWithError() throws InterruptedException, ExecutionException { final FuturePublishCallback f = new FuturePublishCallback(); f.onComplete(Record.UNASSIGNED_OFFSET, new Exception("simulated error")); f.get(); }