mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/base/TestBaseMessageService.java
@Test
    public void testRequestSystemInfo() throws IOException
    {
        //build info map
        Map<String, String> props = new HashMap<String, String>();
        props.put("key", "info");
        // mock system interface
        when(m_TerraHarvestController.getName()).thenReturn("system-name");
        when(m_TerraHarvestController.getVersion()).thenReturn("1.0");
        when(m_TerraHarvestController.getBuildInfo()).thenReturn(props);
        
        // construct the request system info message
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.RequestControllerInfo)
                .build();
     
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        // verify system info message is sent back to source requester
        ArgumentCaptor<ControllerInfoData> messageCaptor = ArgumentCaptor.forClass(ControllerInfoData.class);
        verify(m_MessageFactory).createBaseMessageResponse(eq(message), eq(BaseMessageType.ControllerInfo),
                messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        // verify content of message
        assertThat(messageCaptor.getValue().getName(), is("system-name"));
        assertThat(messageCaptor.getValue().getVersion(), is("1.0"));
        assertThat(messageCaptor.getValue().getBuildInfoList().get(0).getKey(), is("key"));
        assertThat(messageCaptor.getValue().getBuildInfoList().get(0).getValue().getStringValue(), is("info"));
        assertThat(messageCaptor.getValue().getCurrentSystemTime(), lessThanOrEqualTo(System.currentTimeMillis()));
    }
/**
     * Verify handling of RequestSystemInfo, should send SystemInfo
     */
Verify handling of RequestSystemInfo, should send SystemInfo
Verify handling of RequestSystemInfo should send SystemInfo
@Test
    public void testRequestSystemInfo() throws IOException
    {
        Map<String, String> props = new HashMap<String, String>();
        props.put("key", "info");
        when(m_TerraHarvestController.getName()).thenReturn("system-name");
        when(m_TerraHarvestController.getVersion()).thenReturn("1.0");
        when(m_TerraHarvestController.getBuildInfo()).thenReturn(props);
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.RequestControllerInfo)
                .build();
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<ControllerInfoData> messageCaptor = ArgumentCaptor.forClass(ControllerInfoData.class);
        verify(m_MessageFactory).createBaseMessageResponse(eq(message), eq(BaseMessageType.ControllerInfo),
                messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        assertThat(messageCaptor.getValue().getName(), is("system-name"));
        assertThat(messageCaptor.getValue().getVersion(), is("1.0"));
        assertThat(messageCaptor.getValue().getBuildInfoList().get(0).getKey(), is("key"));
        assertThat(messageCaptor.getValue().getBuildInfoList().get(0).getValue().getStringValue(), is("info"));
        assertThat(messageCaptor.getValue().getCurrentSystemTime(), lessThanOrEqualTo(System.currentTimeMillis()));
    }
@ Test public void testRequestSystemInfo ( ) throws IOException { Map < String , String > props = new HashMap < String , String > ( ) ; props . put ( "key" , "info" ) ; when ( m_TerraHarvestController . getName ( ) ) . thenReturn ( "system-name" ) ; when ( m_TerraHarvestController . getVersion ( ) ) . thenReturn ( "1.0" ) ; when ( m_TerraHarvestController . getBuildInfo ( ) ) . thenReturn ( props ) ; BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . RequestControllerInfo ) . build ( ) ; TerraHarvestMessage message = createBaseMessage ( baseNamespaceMessage ) ; TerraHarvestPayload payload = createPayload ( baseNamespaceMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < ControllerInfoData > messageCaptor = ArgumentCaptor . forClass ( ControllerInfoData . class ) ; verify ( m_MessageFactory ) . createBaseMessageResponse ( eq ( message ) , eq ( BaseMessageType . ControllerInfo ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; assertThat ( messageCaptor . getValue ( ) . getName ( ) , is ( "system-name" ) ) ; assertThat ( messageCaptor . getValue ( ) . getVersion ( ) , is ( "1.0" ) ) ; assertThat ( messageCaptor . getValue ( ) . getBuildInfoList ( ) . get ( 0 ) . getKey ( ) , is ( "key" ) ) ; assertThat ( messageCaptor . getValue ( ) . getBuildInfoList ( ) . get ( 0 ) . getValue ( ) . getStringValue ( ) , is ( "info" ) ) ; assertThat ( messageCaptor . getValue ( ) . getCurrentSystemTime ( ) , lessThanOrEqualTo ( System . currentTimeMillis ( ) ) ) ; }
Verify handling of RequestSystemInfo, should send SystemInfo
Verify handling of RequestSystemInfo should send SystemInfo
//build info map // mock system interface // construct the request system info message // mock the channel the message came from // replay // verify system info message is sent back to source requester // verify content of message