mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testExecuteMPException() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException, InterruptedException, IllegalStateException, UnsupportedOperationException, 
           MissionProgramException
    {
        String name = "wicked";
        //mocks
        Program program = mock(Program.class);
        when(program.getProgramName()).thenReturn(name);
        when(m_Manager.getProgram(name)).thenReturn(program);
        doThrow(new MissionProgramException(new Exception("red"))).when(program).execute();

        //activate the mission programming message service
        m_SUT.activate();
        
        //create request
        ExecuteRequestData request = ExecuteRequestData.newBuilder().setMissionName(name).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.ExecuteRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        try
        {
            m_SUT.handleMessage(message, createPayload(missionMessage), channel);
            fail("Expecting exception");
        }
        catch(IllegalStateException e)
        {
            //expected
        }
    }
/**
     * Test that requesting to execute a program and the execution throws a Mission Program Exception
     * that a new illegal state exception is thrown.
     */
Test that requesting to execute a program and the execution throws a Mission Program Exception
that a new illegal state exception is thrown.
Test that requesting to execute a program and the execution throws a Mission Program Exception that a new illegal state exception is thrown .
@Test
    public void testExecuteMPException() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException, InterruptedException, IllegalStateException, UnsupportedOperationException, 
           MissionProgramException
    {
        String name = "wicked";
        Program program = mock(Program.class);
        when(program.getProgramName()).thenReturn(name);
        when(m_Manager.getProgram(name)).thenReturn(program);
        doThrow(new MissionProgramException(new Exception("red"))).when(program).execute();
        m_SUT.activate();
        ExecuteRequestData request = ExecuteRequestData.newBuilder().setMissionName(name).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.ExecuteRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        try
        {
            m_SUT.handleMessage(message, createPayload(missionMessage), channel);
            fail("Expecting exception");
        }
        catch(IllegalStateException e)
        {
        }
    }
@ Test public void testExecuteMPException ( ) throws IOException , ObjectConverterException , IllegalArgumentException , PersistenceFailedException , InterruptedException , IllegalStateException , UnsupportedOperationException , MissionProgramException { String name = "wicked" ; Program program = mock ( Program . class ) ; when ( program . getProgramName ( ) ) . thenReturn ( name ) ; when ( m_Manager . getProgram ( name ) ) . thenReturn ( program ) ; doThrow ( new MissionProgramException ( new Exception ( "red" ) ) ) . when ( program ) . execute ( ) ; m_SUT . activate ( ) ; ExecuteRequestData request = ExecuteRequestData . newBuilder ( ) . setMissionName ( name ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . ExecuteRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; try { m_SUT . handleMessage ( message , createPayload ( missionMessage ) , channel ) ; fail ( "Expecting exception" ) ; } catch ( IllegalStateException e ) { } }
Test that requesting to execute a program and the execution throws a Mission Program Exception
 that a new illegal state exception is thrown.
Test that requesting to execute a program and the execution throws a Mission Program Exception that a new illegal state exception is thrown .
//mocks //activate the mission programming message service //create request // mock the channel the message came from // replay //expected