@SuppressWarnings("unchecked") protected void setPendingResultValue(final Result result) { doAnswer(invocation -> { ((ResultCallback)invocation.getArguments()[0]).onResult(result); return null; }).when(pendingResult).setResultCallback(Matchers.<ResultCallback>any()); }