mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/base/TestBaseMessageService.java
@Test
    public void testSetSystemStatus() throws IOException, BundleException
    {
        // construct the set system mode message
        SetOperationModeRequestData request = SetOperationModeRequestData.newBuilder()
                .setMode(BaseMessages.OperationMode.OPERATIONAL_MODE).build();
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.SetOperationModeRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
     
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

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

        // verify response message is sent back to source requester
        verify(m_MessageFactory).createBaseMessageResponse(eq(message), eq(BaseMessageType.SetOperationModeResponse), 
            eq((Message)null));
        verify(m_ResponseWrapper).queue(channel);
        
        verify(m_TerraHarvestController).setOperationMode(OperationMode.OPERATIONAL_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 set system status request to operational mode.
     */
Verify handling of set system status request to operational mode.
Verify handling of set system status request to operational mode .
@Test
    public void testSetSystemStatus() throws IOException, BundleException
    {
        SetOperationModeRequestData request = SetOperationModeRequestData.newBuilder()
                .setMode(BaseMessages.OperationMode.OPERATIONAL_MODE).build();
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.SetOperationModeRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseMessageResponse(eq(message), eq(BaseMessageType.SetOperationModeResponse), 
            eq((Message)null));
        verify(m_ResponseWrapper).queue(channel);
        verify(m_TerraHarvestController).setOperationMode(OperationMode.OPERATIONAL_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 testSetSystemStatus ( ) throws IOException , BundleException { SetOperationModeRequestData request = SetOperationModeRequestData . newBuilder ( ) . setMode ( BaseMessages . OperationMode . OPERATIONAL_MODE ) . build ( ) ; BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . SetOperationModeRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( baseNamespaceMessage ) ; TerraHarvestMessage message = createBaseMessage ( baseNamespaceMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseMessageResponse ( eq ( message ) , eq ( BaseMessageType . SetOperationModeResponse ) , eq ( ( Message ) null ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; verify ( m_TerraHarvestController ) . setOperationMode ( OperationMode . OPERATIONAL_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 set system status request to operational mode.
Verify handling of set system status request to operational mode .
// construct the set system mode message // mock the channel the message came from // replay // verify response message is sent back to source requester // verify event is posted