mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/messaging/TestMessageSenderImpl.java
@Test
    public void testQueueResponseWithEventChannel() throws IOException
    {
        // id to use for the request and response
        int messageId = 100;
        
        // construct fake request message that should be used by service to construct the response
        MissionProgrammingNamespace requestMessage = MissionProgrammingNamespace.newBuilder()
                .setType(MissionProgrammingMessageType.GetTemplatesRequest).build();
        TerraHarvestMessage request = 
                createMessageWithDestSource(m_RemoteId, m_LocalId, 0 , Namespace.MissionProgramming, requestMessage);
        
        // construct data message
        MissionProgramTemplate template = MissionProgramTemplate.newBuilder().setName("test").setSource("src").build();
        GetTemplatesResponseData getTemplateData = GetTemplatesResponseData.newBuilder().addTemplate(template).build();
        
        MissionProgrammingNamespace responseMessage = MissionProgrammingNamespace.newBuilder()
                .setType(MissionProgrammingMessageType.GetTemplatesResponse)
                .setData(getTemplateData.toByteString()).build();
        
        TerraHarvestMessage response = 
                createTerraHarvestMessage(messageId, Namespace.MissionProgramming, responseMessage, true);
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(response.getTerraHarvestPayload());
        
        when(m_EncryptService.encryptMessage(Mockito.any(Builder.class), Mockito.any(TerraHarvestPayload.class))).
            thenReturn(response);
        when(m_EventChannel.getRemoteSystemId()).thenReturn(m_RemoteId);
        when(m_EventChannel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        when(m_RemoteChannelLookup.getChannels(m_RemoteId)).thenReturn(new ArrayList<RemoteChannel>());
        
        boolean result = m_SUT.queueMessageResponse(request, payload, m_EventChannel);
        assertThat("message is queued as reported by channel", result, is(true));
        
        // verify message is sent to the associated channel with proper fields set
        verify(m_EventChannel).queueMessage(response);
    }
/**
     * Verifies that the event channel is used to queue the response message.
     */
Verifies that the event channel is used to queue the response message.
Verifies that the event channel is used to queue the response message .
@Test
    public void testQueueResponseWithEventChannel() throws IOException
    {
        int messageId = 100;
        MissionProgrammingNamespace requestMessage = MissionProgrammingNamespace.newBuilder()
                .setType(MissionProgrammingMessageType.GetTemplatesRequest).build();
        TerraHarvestMessage request = 
                createMessageWithDestSource(m_RemoteId, m_LocalId, 0 , Namespace.MissionProgramming, requestMessage);
        MissionProgramTemplate template = MissionProgramTemplate.newBuilder().setName("test").setSource("src").build();
        GetTemplatesResponseData getTemplateData = GetTemplatesResponseData.newBuilder().addTemplate(template).build();
        MissionProgrammingNamespace responseMessage = MissionProgrammingNamespace.newBuilder()
                .setType(MissionProgrammingMessageType.GetTemplatesResponse)
                .setData(getTemplateData.toByteString()).build();
        TerraHarvestMessage response = 
                createTerraHarvestMessage(messageId, Namespace.MissionProgramming, responseMessage, true);
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(response.getTerraHarvestPayload());
        when(m_EncryptService.encryptMessage(Mockito.any(Builder.class), Mockito.any(TerraHarvestPayload.class))).
            thenReturn(response);
        when(m_EventChannel.getRemoteSystemId()).thenReturn(m_RemoteId);
        when(m_EventChannel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        when(m_RemoteChannelLookup.getChannels(m_RemoteId)).thenReturn(new ArrayList<RemoteChannel>());
        boolean result = m_SUT.queueMessageResponse(request, payload, m_EventChannel);
        assertThat("message is queued as reported by channel", result, is(true));
        verify(m_EventChannel).queueMessage(response);
    }
@ Test public void testQueueResponseWithEventChannel ( ) throws IOException { int messageId = 100 ; MissionProgrammingNamespace requestMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . GetTemplatesRequest ) . build ( ) ; TerraHarvestMessage request = createMessageWithDestSource ( m_RemoteId , m_LocalId , 0 , Namespace . MissionProgramming , requestMessage ) ; MissionProgramTemplate template = MissionProgramTemplate . newBuilder ( ) . setName ( "test" ) . setSource ( "src" ) . build ( ) ; GetTemplatesResponseData getTemplateData = GetTemplatesResponseData . newBuilder ( ) . addTemplate ( template ) . build ( ) ; MissionProgrammingNamespace responseMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . GetTemplatesResponse ) . setData ( getTemplateData . toByteString ( ) ) . build ( ) ; TerraHarvestMessage response = createTerraHarvestMessage ( messageId , Namespace . MissionProgramming , responseMessage , true ) ; TerraHarvestPayload payload = TerraHarvestPayload . parseFrom ( response . getTerraHarvestPayload ( ) ) ; when ( m_EncryptService . encryptMessage ( Mockito . any ( Builder . class ) , Mockito . any ( TerraHarvestPayload . class ) ) ) . thenReturn ( response ) ; when ( m_EventChannel . getRemoteSystemId ( ) ) . thenReturn ( m_RemoteId ) ; when ( m_EventChannel . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( true ) ; when ( m_RemoteChannelLookup . getChannels ( m_RemoteId ) ) . thenReturn ( new ArrayList < RemoteChannel > ( ) ) ; boolean result = m_SUT . queueMessageResponse ( request , payload , m_EventChannel ) ; assertThat ( "message is queued as reported by channel" , result , is ( true ) ) ; verify ( m_EventChannel ) . queueMessage ( response ) ; }
Verifies that the event channel is used to queue the response message.
Verifies that the event channel is used to queue the response message .
// id to use for the request and response // construct fake request message that should be used by service to construct the response // construct data message // verify message is sent to the associated channel with proper fields set