ResetP2pKeyTask implements Callable<Object> { @Override public Object call() throws Exception { final RegistrationStatus status = peer.getStatus(); if ( status == RegistrationStatus.APPROVED ) { peer.resetSwarmSecretKey( p2PCredentials ); } else { trackerOperation.addLog( String.format( "Resetting p2p secret key on peer %s skipped due to peer status %s", peer.getId(), status ) ); } return null; } ResetP2pKeyTask( final Peer peer, final P2PCredentials p2PCredentials,
                            final TrackerOperation trackerOperation ); @Override Object call();  }
@Test public void testCall() throws Exception { doReturn( RegistrationStatus.APPROVED ).when( peer ).getStatus(); task.call(); verify( peer ).resetSwarmSecretKey( p2PCredentials ); doReturn( RegistrationStatus.CANCELLED ).when( peer ).getStatus(); task.call(); verify( trackerOperation ).addLog( anyString() ); }