mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testTestExecuteIllegalState() 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);
        when(program.executeTest()).thenThrow(new IllegalStateException("Utah"));

        //activate the mission programming message service
        m_SUT.activate();
        
        //create request
        ExecuteTestRequestData request = ExecuteTestRequestData.newBuilder().setMissionName(name).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.ExecuteTestRequest).
                setData(request.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 that mission program manager is given parameters
        verify(m_Manager, times(1)).getProgram(name);
        
        // verify response
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INTERNAL_ERROR, 
                "Utah");
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test that requesting to test execute a mission that is not in a legal state.
     */
Test that requesting to test execute a mission that is not in a legal state.
Test that requesting to test execute a mission that is not in a legal state .
@Test
    public void testTestExecuteIllegalState() 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);
        when(program.executeTest()).thenThrow(new IllegalStateException("Utah"));
        m_SUT.activate();
        ExecuteTestRequestData request = ExecuteTestRequestData.newBuilder().setMissionName(name).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.ExecuteTestRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, createPayload(missionMessage), channel);
        verify(m_Manager, times(1)).getProgram(name);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INTERNAL_ERROR, 
                "Utah");
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testTestExecuteIllegalState ( ) 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 ) ; when ( program . executeTest ( ) ) . thenThrow ( new IllegalStateException ( "Utah" ) ) ; m_SUT . activate ( ) ; ExecuteTestRequestData request = ExecuteTestRequestData . newBuilder ( ) . setMissionName ( name ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . ExecuteTestRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , createPayload ( missionMessage ) , channel ) ; verify ( m_Manager , times ( 1 ) ) . getProgram ( name ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . INTERNAL_ERROR , "Utah" ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test that requesting to test execute a mission that is not in a legal state.
Test that requesting to test execute a mission that is not in a legal state .
//mocks //activate the mission programming message service //create request // mock the channel the message came from // replay //verify that mission program manager is given parameters // verify response