mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testLoadTemplate() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        //activate the mission programming message service
        m_SUT.activate();
        //create a simple mission template to send
        MissionProgramTemplateGen.MissionProgramTemplate template = MissionProgramTemplateGen.MissionProgramTemplate.
            newBuilder().setName("IamATest").setSource("TheSource!@@#(*&$^%_@##$").build();
        //construct a message        
        LoadTemplateRequestData programMessage = MissionProgramMessages.LoadTemplateRequestData.newBuilder().
            setMission(template).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadTemplateRequest).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(MissionProgramTemplate.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((LoadTemplateRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(programMessage));

        //verify the interaction with the template manager
        verify(m_TemplateManager, times(1)).loadMissionTemplate(Mockito.any(MissionProgramTemplate.class));
           
        // verify program loaded response is sent back from source requester
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(message,
                MissionProgrammingMessageType.LoadTemplateResponse, null);
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Verify that the loaded template response is sent after the load program message is processed.
     */
Verify that the loaded template response is sent after the load program message is processed.
Verify that the loaded template response is sent after the load program message is processed .
@Test
    public void testLoadTemplate() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        m_SUT.activate();
        MissionProgramTemplateGen.MissionProgramTemplate template = MissionProgramTemplateGen.MissionProgramTemplate.
            newBuilder().setName("IamATest").setSource("TheSource!@@#(*&$^%_@##$").build();
        LoadTemplateRequestData programMessage = MissionProgramMessages.LoadTemplateRequestData.newBuilder().
            setMission(template).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadTemplateRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenReturn(mock(MissionProgramTemplate.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((LoadTemplateRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(programMessage));
        verify(m_TemplateManager, times(1)).loadMissionTemplate(Mockito.any(MissionProgramTemplate.class));
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(message,
                MissionProgrammingMessageType.LoadTemplateResponse, null);
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testLoadTemplate ( ) throws IOException , ObjectConverterException , IllegalArgumentException , PersistenceFailedException { m_SUT . activate ( ) ; MissionProgramTemplateGen . MissionProgramTemplate template = MissionProgramTemplateGen . MissionProgramTemplate . newBuilder ( ) . setName ( "IamATest" ) . setSource ( "TheSource!@@#(*&$^%_@##$" ) . build ( ) ; LoadTemplateRequestData programMessage = MissionProgramMessages . LoadTemplateRequestData . newBuilder ( ) . setMission ( template ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . LoadTemplateRequest ) . setData ( programMessage . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( missionMessage ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( mock ( MissionProgramTemplate . 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 ( ( LoadTemplateRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( programMessage ) ) ; verify ( m_TemplateManager , times ( 1 ) ) . loadMissionTemplate ( Mockito . any ( MissionProgramTemplate . class ) ) ; verify ( m_MessageFactory ) . createMissionProgrammingResponseMessage ( message , MissionProgrammingMessageType . LoadTemplateResponse , null ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Verify that the loaded template response is sent after the load program message is processed.
Verify that the loaded template response is sent after the load program message is processed .
//activate the mission programming message service //create a simple mission template to send //construct a message         //mock converter behavior // mock the channel the message came from // replay // verify the event contains the data message //verify the interaction with the template manager // verify program loaded response is sent back from source requester