@Test
public void testHandleMessage() throws Exception
{

    Message message = InterceptorStateHelper.getMessage( InterceptorState.CLIENT_OUT );
    doReturn( String.format( "http://%s:%d/rest/v1/peer", Common.LOCAL_HOST_IP, PORT ) ).when( message )
                                                                                        .get( Message
                                                                                                .ENDPOINT_ADDRESS );
    doReturn( PEER_ID ).when( interceptor ).getPeerIdByIp( Common.LOCAL_HOST_IP );
    doReturn( peer ).when( peerManager ).getPeer( PEER_ID );
    doReturn( peerInfo ).when( peer ).getPeerInfo();
    doReturn( PORT ).when( peerInfo ).getPublicSecurePort();
    doReturn( localPeer ).when( peerManager ).getLocalPeer();
    //        doNothing().when( interceptor ).handlePeerMessage( PEER_ID, message );
    try
    {
        interceptor.handleMessage( message );
    }
    catch ( RuntimeException e )
    {
    }
    verify( interceptor ).getPeerIdByIp( Common.LOCAL_HOST_IP );
    verify( interceptor ).handlePeerMessage( PEER_ID, message );
    doReturn( String.format( "http://%s:%d/rest/v1/env/%s/", Common.LOCAL_HOST_IP, PORT, ENV_ID ) ).when( message )
                                                                                                   .get( Message
                                                                                                           .ENDPOINT_ADDRESS );
    // doNothing().when( interceptor ).handleEnvironmentMessage( PEER_ID, ENV_ID, message );
    try
    {
        interceptor.handleMessage( message );
    }
    catch ( RuntimeException e )
    {
    }
    verify( interceptor ).handleEnvironmentMessage( PEER_ID, ENV_ID, message );
}