mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testLoadParameters() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        //activate the mission programming message service
        m_SUT.activate();
        //create a simple mission parameter object to send to the template program manager
        MissionProgramParametersGen.MissionProgramSchedule schedule = 
                MissionProgramParametersGen.MissionProgramSchedule.
            newBuilder().setActive(true).setImmediately(false).setIndefiniteInterval(true).build();
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramParametersGen.MissionProgramParameters.newBuilder().setTemplateName("Sue").
                setSchedule(schedule).setProgramName("name").build();
        //construct a message        
        LoadParametersRequestData programMessage = MissionProgramMessages.LoadParametersRequestData.newBuilder().
            setParameters(params).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadParametersRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        
        //mock converter behavior
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenReturn(mock(MissionProgramParameters.class));

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        // verify the event contains the data message
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((LoadParametersRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(programMessage));

        //verify that mission program manager is given parameters
        verify(m_Manager, times(1)).loadParameters(Mockito.any(MissionProgramParameters.class));
           
        // verify parameters loaded message is sent back from source requester
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(message, 
                MissionProgrammingMessageType.LoadParametersResponse, null);
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test that the load parameters call works and that a parameters loaded response is sent.
     */
Test that the load parameters call works and that a parameters loaded response is sent.
Test that the load parameters call works and that a parameters loaded response is sent .
@Test
    public void testLoadParameters() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        m_SUT.activate();
        MissionProgramParametersGen.MissionProgramSchedule schedule = 
                MissionProgramParametersGen.MissionProgramSchedule.
            newBuilder().setActive(true).setImmediately(false).setIndefiniteInterval(true).build();
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramParametersGen.MissionProgramParameters.newBuilder().setTemplateName("Sue").
                setSchedule(schedule).setProgramName("name").build();
        LoadParametersRequestData programMessage = MissionProgramMessages.LoadParametersRequestData.newBuilder().
            setParameters(params).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadParametersRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenReturn(mock(MissionProgramParameters.class));
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((LoadParametersRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(programMessage));
        verify(m_Manager, times(1)).loadParameters(Mockito.any(MissionProgramParameters.class));
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(message, 
                MissionProgrammingMessageType.LoadParametersResponse, null);
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testLoadParameters ( ) throws IOException , ObjectConverterException , IllegalArgumentException , PersistenceFailedException { m_SUT . activate ( ) ; MissionProgramParametersGen . MissionProgramSchedule schedule = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setActive ( true ) . setImmediately ( false ) . setIndefiniteInterval ( true ) . build ( ) ; MissionProgramParametersGen . MissionProgramParameters params = MissionProgramParametersGen . MissionProgramParameters . newBuilder ( ) . setTemplateName ( "Sue" ) . setSchedule ( schedule ) . setProgramName ( "name" ) . build ( ) ; LoadParametersRequestData programMessage = MissionProgramMessages . LoadParametersRequestData . newBuilder ( ) . setParameters ( params ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . LoadParametersRequest ) . setData ( programMessage . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( missionMessage ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( mock ( MissionProgramParameters . class ) ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( LoadParametersRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( programMessage ) ) ; verify ( m_Manager , times ( 1 ) ) . loadParameters ( Mockito . any ( MissionProgramParameters . class ) ) ; verify ( m_MessageFactory ) . createMissionProgrammingResponseMessage ( message , MissionProgrammingMessageType . LoadParametersResponse , null ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test that the load parameters call works and that a parameters loaded response is sent.
Test that the load parameters call works and that a parameters loaded response is sent .
//activate the mission programming message service //create a simple mission parameter object to send to the template program manager //construct a message         //mock converter behavior // mock the channel the message came from // replay // verify the event contains the data message //verify that mission program manager is given parameters // verify parameters loaded message is sent back from source requester