@Test
public void testHandleMessage() throws Exception
{

    Message message = InterceptorStateHelper.getMessage( InterceptorState.CLIENT_IN );
    Message outMessage = message.getExchange().getOutMessage();
    doReturn( String.format( "http://%s:%d/rest/v1/peer", Common.LOCAL_HOST_IP, PORT ) ).when( outMessage )
                                                                                        .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();
    interceptor.handleMessage( message );
    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( outMessage )
                                                                                       .get( Message
                                                                                               .ENDPOINT_ADDRESS );
    interceptor.handleMessage( message );
    verify( interceptor ).handleEnvironmentMessage( PEER_ID,ENV_ID, message );
}