DelApiKeyTask extends DefaultTask<Boolean> implements UserTask { @Override public Boolean call() throws Exception { Boolean result = apiKeyRepository.delete(user); if (result) { logger.info("key for user {} has been deleted", user.id); } else { logger.info("no key for user {}", user.id); } return result; } @Inject  DelApiKeyTask(ApiKeyRepository apiKeyRepository,@Assisted User user); @Override Boolean call(); @Override User getUser();  }
@Test public void test_call() throws Exception { ArgumentCaptor<User> user = forClass(User.class); assertThat(new DelApiKeyTask(apiKeyRepository, User.local()).call()).isNotNull(); verify(apiKeyRepository).delete(user.capture()); assertThat(user.getValue()).isEqualTo(User.local()); }