mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@SuppressWarnings("unchecked")
    @Test
    public void testLoadParametersException() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        //activate the mission programming message service
        m_SUT.activate();
        //create a simple mission parameter object to send to the template program manager
        MissionProgramParametersGen.MissionProgramSchedule schedule = 
                MissionProgramParametersGen.MissionProgramSchedule.
                    newBuilder().setActive(true).setImmediately(false)
                    .setIndefiniteInterval(true).build();
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramParametersGen.MissionProgramParameters.newBuilder().setTemplateName("Sue").
                setSchedule(schedule).setProgramName("names").build();
        //construct a message        
        LoadParametersRequestData programMessage = MissionProgramMessages.LoadParametersRequestData.newBuilder().
            setParameters(params).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadParametersRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        //lay-out mocked behavior
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenReturn(mock(MissionProgramParameters.class));
        when(m_Manager.loadParameters(Mockito.any(MissionProgramParameters.class))).
            thenThrow(PersistenceFailedException.class);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        // verify loaded parameters response sent back, due to converter exception
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.PERSIST_ERROR, 
                "Failed to persist parameters from message. " + null);
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test that the load parameters exception that the object could not be converted.
     * 
     * Verify PERSIST_ERROR is part of the response message.
     */
Test that the load parameters exception that the object could not be converted.

Verify PERSIST_ERROR is part of the response message.
Test that the load parameters exception that the object could not be converted . Verify PERSIST_ERROR is part of the response message .
@SuppressWarnings("unchecked")
    @Test
    public void testLoadParametersException() throws IOException, ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        m_SUT.activate();
        MissionProgramParametersGen.MissionProgramSchedule schedule = 
                MissionProgramParametersGen.MissionProgramSchedule.
                    newBuilder().setActive(true).setImmediately(false)
                    .setIndefiniteInterval(true).build();
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramParametersGen.MissionProgramParameters.newBuilder().setTemplateName("Sue").
                setSchedule(schedule).setProgramName("names").build();
        LoadParametersRequestData programMessage = MissionProgramMessages.LoadParametersRequestData.newBuilder().
            setParameters(params).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadParametersRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenReturn(mock(MissionProgramParameters.class));
        when(m_Manager.loadParameters(Mockito.any(MissionProgramParameters.class))).
            thenThrow(PersistenceFailedException.class);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.PERSIST_ERROR, 
                "Failed to persist parameters from message. " + null);
        verify(m_ResponseWrapper).queue(channel);
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testLoadParametersException ( ) throws IOException , ObjectConverterException , IllegalArgumentException , PersistenceFailedException { m_SUT . activate ( ) ; MissionProgramParametersGen . MissionProgramSchedule schedule = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setActive ( true ) . setImmediately ( false ) . setIndefiniteInterval ( true ) . build ( ) ; MissionProgramParametersGen . MissionProgramParameters params = MissionProgramParametersGen . MissionProgramParameters . newBuilder ( ) . setTemplateName ( "Sue" ) . setSchedule ( schedule ) . setProgramName ( "names" ) . build ( ) ; LoadParametersRequestData programMessage = MissionProgramMessages . LoadParametersRequestData . newBuilder ( ) . setParameters ( params ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . LoadParametersRequest ) . setData ( programMessage . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( missionMessage ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( mock ( MissionProgramParameters . class ) ) ; when ( m_Manager . loadParameters ( Mockito . any ( MissionProgramParameters . class ) ) ) . thenThrow ( PersistenceFailedException . class ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . PERSIST_ERROR , "Failed to persist parameters from message. " + null ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test that the load parameters exception that the object could not be converted.
Test that the load parameters exception that the object could not be converted .
//activate the mission programming message service //create a simple mission parameter object to send to the template program manager //construct a message         //lay-out mocked behavior // mock the channel the message came from // replay // verify loaded parameters response sent back, due to converter exception