mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testGetTemplateNames() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException, InterruptedException, IllegalStateException, UnsupportedOperationException, 
           MissionProgramException
    {
        //activate the mission programming message service
        m_SUT.activate();
        
        //mock template manager
        final Set<String> names = new HashSet<String>();
        names.add("a");
        names.add("b");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(names);
        
        //create request
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetTemplateNamesRequest).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 contains the data message
        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.GetTemplateNamesRequest.toString()));
        
        //verify the contents of the response
        ArgumentCaptor<GetTemplateNamesResponseData> responseCaptor = 
                ArgumentCaptor.forClass(GetTemplateNamesResponseData.class);
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
                eq(MissionProgrammingMessageType.GetTemplateNamesResponse), responseCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        assertThat(responseCaptor.getValue().getTemplateNameCount(), is(2));
        assertThat(responseCaptor.getValue().getTemplateNameList(), hasItems("a", "b"));
    }
/**
     * Test the request to get template names.
     * Verify that all expected names are returned.
     */
Test the request to get template names.
Verify that all expected names are returned.
Test the request to get template names . Verify that all expected names are returned .
@Test
    public void testGetTemplateNames() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException, InterruptedException, IllegalStateException, UnsupportedOperationException, 
           MissionProgramException
    {
        m_SUT.activate();
        final Set<String> names = new HashSet<String>();
        names.add("a");
        names.add("b");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(names);
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetTemplateNamesRequest).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.GetTemplateNamesRequest.toString()));
        ArgumentCaptor<GetTemplateNamesResponseData> responseCaptor = 
                ArgumentCaptor.forClass(GetTemplateNamesResponseData.class);
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
                eq(MissionProgrammingMessageType.GetTemplateNamesResponse), responseCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        assertThat(responseCaptor.getValue().getTemplateNameCount(), is(2));
        assertThat(responseCaptor.getValue().getTemplateNameList(), hasItems("a", "b"));
    }
@ Test public void testGetTemplateNames ( ) throws IOException , ObjectConverterException , IllegalArgumentException , PersistenceFailedException , InterruptedException , IllegalStateException , UnsupportedOperationException , MissionProgramException { m_SUT . activate ( ) ; final Set < String > names = new HashSet < String > ( ) ; names . add ( "a" ) ; names . add ( "b" ) ; when ( m_TemplateManager . getMissionTemplateNames ( ) ) . thenReturn ( names ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . GetTemplateNamesRequest ) . 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 . GetTemplateNamesRequest . toString ( ) ) ) ; ArgumentCaptor < GetTemplateNamesResponseData > responseCaptor = ArgumentCaptor . forClass ( GetTemplateNamesResponseData . class ) ; verify ( m_MessageFactory ) . createMissionProgrammingResponseMessage ( eq ( message ) , eq ( MissionProgrammingMessageType . GetTemplateNamesResponse ) , responseCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; assertThat ( responseCaptor . getValue ( ) . getTemplateNameCount ( ) , is ( 2 ) ) ; assertThat ( responseCaptor . getValue ( ) . getTemplateNameList ( ) , hasItems ( "a" , "b" ) ) ; }
Test the request to get template names.
Test the request to get template names .
//activate the mission programming message service //mock template manager //create request // mock the channel the message came from // replay // verify the event contains the data message //verify the contents of the response