mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/base/TestBaseMessageService.java
@Test
    public void testGetSystemStatus() throws IOException, BundleException
    {
        // construct the message
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.GetOperationModeRequest)
                .build();
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
     
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        //terra harvest controller
        when(m_TerraHarvestController.getOperationMode()).thenReturn(OperationMode.TEST_MODE);

        // replay
        m_SUT.handleMessage(message, payload, channel);

        // verify response message is sent back to source requester
        ArgumentCaptor<GetOperationModeReponseData> messageCaptor = 
            ArgumentCaptor.forClass(GetOperationModeReponseData.class);
        verify(m_MessageFactory).createBaseMessageResponse(eq(message), eq(BaseMessageType.GetOperationModeResponse), 
            messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);

        //inspect message
        GetOperationModeReponseData response = messageCaptor.getValue();
        assertThat(response.getMode(), is(BaseMessages.OperationMode.TEST_MODE));

        // verify event is posted
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        assertThat((String)eventCaptor.getValue().getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
            is(baseNamespaceMessage.getType().toString()));
    }
/**
     * Verify handling of get system status request when the mode is test.
     */
Verify handling of get system status request when the mode is test.
Verify handling of get system status request when the mode is test .
@Test
    public void testGetSystemStatus() throws IOException, BundleException
    {
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.GetOperationModeRequest)
                .build();
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        when(m_TerraHarvestController.getOperationMode()).thenReturn(OperationMode.TEST_MODE);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<GetOperationModeReponseData> messageCaptor = 
            ArgumentCaptor.forClass(GetOperationModeReponseData.class);
        verify(m_MessageFactory).createBaseMessageResponse(eq(message), eq(BaseMessageType.GetOperationModeResponse), 
            messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetOperationModeReponseData response = messageCaptor.getValue();
        assertThat(response.getMode(), is(BaseMessages.OperationMode.TEST_MODE));
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        assertThat((String)eventCaptor.getValue().getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
            is(baseNamespaceMessage.getType().toString()));
    }
@ Test public void testGetSystemStatus ( ) throws IOException , BundleException { BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GetOperationModeRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( baseNamespaceMessage ) ; TerraHarvestMessage message = createBaseMessage ( baseNamespaceMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; when ( m_TerraHarvestController . getOperationMode ( ) ) . thenReturn ( OperationMode . TEST_MODE ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < GetOperationModeReponseData > messageCaptor = ArgumentCaptor . forClass ( GetOperationModeReponseData . class ) ; verify ( m_MessageFactory ) . createBaseMessageResponse ( eq ( message ) , eq ( BaseMessageType . GetOperationModeResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetOperationModeReponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getMode ( ) , is ( BaseMessages . OperationMode . TEST_MODE ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; assertThat ( ( String ) eventCaptor . getValue ( ) . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( baseNamespaceMessage . getType ( ) . toString ( ) ) ) ; }
Verify handling of get system status request when the mode is test.
Verify handling of get system status request when the mode is test .
// construct the message // mock the channel the message came from //terra harvest controller // replay // verify response message is sent back to source requester //inspect message // verify event is posted