mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testGetExecutionParamsResult() throws IllegalArgumentException, IOException
    {
        //mock the program
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("asset", "asset1");
        Program program = mock(Program.class);
        when(program.getExecutionParameters()).thenReturn(params);
        when(m_Manager.getProgram("man")).thenReturn(program);
        
        //request
        GetExecutionParametersRequestData request = GetExecutionParametersRequestData.newBuilder().
                setMissionName("man").build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetExecutionParametersRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, createPayload(missionMessage), channel);
        
        // verify the event
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(MissionProgrammingMessageType.GetExecutionParametersRequest.toString()));
        assertThat((GetExecutionParametersRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        ArgumentCaptor<GetExecutionParametersResponseData> responseCaptor = 
                ArgumentCaptor.forClass(GetExecutionParametersResponseData.class);
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
            eq(MissionProgrammingMessageType.GetExecutionParametersResponse), responseCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        GetExecutionParametersResponseData response = responseCaptor.getValue();
        assertThat(response.getMissionName(), is("man"));
        assertThat(response.getExecutionParamCount(), is(1));
        assertThat(response.getExecutionParamList().get(0).getKey(), is("asset"));
        assertThat(response.getExecutionParamList().get(0).getValue().getStringValue(), is("asset1"));
    }
/**
     * Test the handling of a request to get a program's execution parameters.
     * Verify event is posted when the message is received
     */
Test the handling of a request to get a program's execution parameters.
Verify event is posted when the message is received
Test the handling of a request to get a program ' s execution parameters . Verify event is posted when the message is received
@Test
    public void testGetExecutionParamsResult() throws IllegalArgumentException, IOException
    {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("asset", "asset1");
        Program program = mock(Program.class);
        when(program.getExecutionParameters()).thenReturn(params);
        when(m_Manager.getProgram("man")).thenReturn(program);
        GetExecutionParametersRequestData request = GetExecutionParametersRequestData.newBuilder().
                setMissionName("man").build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetExecutionParametersRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, createPayload(missionMessage), channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(MissionProgrammingMessageType.GetExecutionParametersRequest.toString()));
        assertThat((GetExecutionParametersRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        ArgumentCaptor<GetExecutionParametersResponseData> responseCaptor = 
                ArgumentCaptor.forClass(GetExecutionParametersResponseData.class);
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
            eq(MissionProgrammingMessageType.GetExecutionParametersResponse), responseCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetExecutionParametersResponseData response = responseCaptor.getValue();
        assertThat(response.getMissionName(), is("man"));
        assertThat(response.getExecutionParamCount(), is(1));
        assertThat(response.getExecutionParamList().get(0).getKey(), is("asset"));
        assertThat(response.getExecutionParamList().get(0).getValue().getStringValue(), is("asset1"));
    }
@ Test public void testGetExecutionParamsResult ( ) throws IllegalArgumentException , IOException { Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "asset" , "asset1" ) ; Program program = mock ( Program . class ) ; when ( program . getExecutionParameters ( ) ) . thenReturn ( params ) ; when ( m_Manager . getProgram ( "man" ) ) . thenReturn ( program ) ; GetExecutionParametersRequestData request = GetExecutionParametersRequestData . newBuilder ( ) . setMissionName ( "man" ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . GetExecutionParametersRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , createPayload ( missionMessage ) , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( MissionProgrammingMessageType . GetExecutionParametersRequest . toString ( ) ) ) ; assertThat ( ( GetExecutionParametersRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; ArgumentCaptor < GetExecutionParametersResponseData > responseCaptor = ArgumentCaptor . forClass ( GetExecutionParametersResponseData . class ) ; verify ( m_MessageFactory ) . createMissionProgrammingResponseMessage ( eq ( message ) , eq ( MissionProgrammingMessageType . GetExecutionParametersResponse ) , responseCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetExecutionParametersResponseData response = responseCaptor . getValue ( ) ; assertThat ( response . getMissionName ( ) , is ( "man" ) ) ; assertThat ( response . getExecutionParamCount ( ) , is ( 1 ) ) ; assertThat ( response . getExecutionParamList ( ) . get ( 0 ) . getKey ( ) , is ( "asset" ) ) ; assertThat ( response . getExecutionParamList ( ) . get ( 0 ) . getValue ( ) . getStringValue ( ) , is ( "asset1" ) ) ; }
Test the handling of a request to get a program's execution parameters.
Test the handling of a request to get a program ' s execution parameters .
//mock the program //request // mock the channel the message came from // replay // verify the event