mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testRemoveProgram() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException, InterruptedException, IllegalStateException, UnsupportedOperationException, 
           MissionProgramException
    {
        //activate the mission programming message service
        m_SUT.activate();
        
        //mock mission program manager behavior
        Program program = mock(Program.class);
        when(program.getProgramName()).thenReturn("a");
        when(m_Manager.getProgram("a")).thenReturn(program);
        
        //create request
        RemoveMissionProgramRequestData data = RemoveMissionProgramRequestData.newBuilder().
                setMissionName("a").build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.RemoveMissionProgramRequest).
                setData(data.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.RemoveMissionProgramRequest.toString()));
        
        //verify interaction
        verify(program).remove();
        
        //verify response
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
            eq(MissionProgrammingMessageType.RemoveMissionProgramResponse), Mockito.any(Message.class));
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test requesting to remove a program.
     * Verify correct program is removed.
     */
Test requesting to remove a program.
Verify correct program is removed.
Test requesting to remove a program . Verify correct program is removed .
@Test
    public void testRemoveProgram() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException, InterruptedException, IllegalStateException, UnsupportedOperationException, 
           MissionProgramException
    {
        m_SUT.activate();
        Program program = mock(Program.class);
        when(program.getProgramName()).thenReturn("a");
        when(m_Manager.getProgram("a")).thenReturn(program);
        RemoveMissionProgramRequestData data = RemoveMissionProgramRequestData.newBuilder().
                setMissionName("a").build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.RemoveMissionProgramRequest).
                setData(data.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.RemoveMissionProgramRequest.toString()));
        verify(program).remove();
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
            eq(MissionProgrammingMessageType.RemoveMissionProgramResponse), Mockito.any(Message.class));
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testRemoveProgram ( ) throws IOException , ObjectConverterException , IllegalArgumentException , PersistenceFailedException , InterruptedException , IllegalStateException , UnsupportedOperationException , MissionProgramException { m_SUT . activate ( ) ; Program program = mock ( Program . class ) ; when ( program . getProgramName ( ) ) . thenReturn ( "a" ) ; when ( m_Manager . getProgram ( "a" ) ) . thenReturn ( program ) ; RemoveMissionProgramRequestData data = RemoveMissionProgramRequestData . newBuilder ( ) . setMissionName ( "a" ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . RemoveMissionProgramRequest ) . setData ( data . 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 . RemoveMissionProgramRequest . toString ( ) ) ) ; verify ( program ) . remove ( ) ; verify ( m_MessageFactory ) . createMissionProgrammingResponseMessage ( eq ( message ) , eq ( MissionProgrammingMessageType . RemoveMissionProgramResponse ) , Mockito . any ( Message . class ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test requesting to remove a program.
Test requesting to remove a program .
//activate the mission programming message service //mock mission program manager behavior //create request // mock the channel the message came from // replay // verify the event //verify interaction //verify response