mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testGetProgramInfoResponse() throws IllegalArgumentException, IOException
    {
        //response message
        MissionProgramParametersGen.MissionProgramSchedule protoSched = 
                MissionProgramParametersGen.MissionProgramSchedule.
                newBuilder().setActive(true).setAtReset(false).setImmediately(true).setIndefiniteInterval(true).build();
        ProgramInfo info = ProgramInfo.newBuilder().
                setMissionName("l").
                setMissionStatus(MissionStatus.EXECUTING).
                setTemplateName("m").setMissionSchedule(protoSched).
                addExecutionParam(MapEntry.newBuilder().
                        setKey("key").
                        setValue(Multitype.newBuilder().
                                setType(Type.STRING).
                                setStringValue("Golden").build()).build()).build();
        GetProgramInformationResponseData response = GetProgramInformationResponseData.newBuilder().
                addMissionInfo(info).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetProgramInformationResponse).
                setData(response.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.GetProgramInformationResponse.toString()));
        assertThat((GetProgramInformationResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(response));
    }
/**
     * Test an event from a response from a request to get program information.
     */
Test an event from a response from a request to get program information.
Test an event from a response from a request to get program information .
@Test
    public void testGetProgramInfoResponse() throws IllegalArgumentException, IOException
    {
        MissionProgramParametersGen.MissionProgramSchedule protoSched = 
                MissionProgramParametersGen.MissionProgramSchedule.
                newBuilder().setActive(true).setAtReset(false).setImmediately(true).setIndefiniteInterval(true).build();
        ProgramInfo info = ProgramInfo.newBuilder().
                setMissionName("l").
                setMissionStatus(MissionStatus.EXECUTING).
                setTemplateName("m").setMissionSchedule(protoSched).
                addExecutionParam(MapEntry.newBuilder().
                        setKey("key").
                        setValue(Multitype.newBuilder().
                                setType(Type.STRING).
                                setStringValue("Golden").build()).build()).build();
        GetProgramInformationResponseData response = GetProgramInformationResponseData.newBuilder().
                addMissionInfo(info).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetProgramInformationResponse).
                setData(response.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.GetProgramInformationResponse.toString()));
        assertThat((GetProgramInformationResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(response));
    }
@ Test public void testGetProgramInfoResponse ( ) throws IllegalArgumentException , IOException { MissionProgramParametersGen . MissionProgramSchedule protoSched = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setActive ( true ) . setAtReset ( false ) . setImmediately ( true ) . setIndefiniteInterval ( true ) . build ( ) ; ProgramInfo info = ProgramInfo . newBuilder ( ) . setMissionName ( "l" ) . setMissionStatus ( MissionStatus . EXECUTING ) . setTemplateName ( "m" ) . setMissionSchedule ( protoSched ) . addExecutionParam ( MapEntry . newBuilder ( ) . setKey ( "key" ) . setValue ( Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "Golden" ) . build ( ) ) . build ( ) ) . build ( ) ; GetProgramInformationResponseData response = GetProgramInformationResponseData . newBuilder ( ) . addMissionInfo ( info ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . GetProgramInformationResponse ) . setData ( response . 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 . GetProgramInformationResponse . toString ( ) ) ) ; assertThat ( ( GetProgramInformationResponseData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( response ) ) ; }
Test an event from a response from a request to get program information.
Test an event from a response from a request to get program information .
//response message // mock the channel the message came from // replay // verify the event