mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionProgramMgrImpl.java
@Test
    public void testMissionErrorHandler()
    {
        MissionProgramParametersGen.MissionProgramSchedule sched = MissionProgramParametersGen.MissionProgramSchedule.
                newBuilder().setAtReset(true).setImmediately(true).setIndefiniteInterval(true).build();
        
        Multitype type = Multitype.newBuilder().setType(Type.STRING).setStringValue("value").build();
        
        MapEntry entry = MapEntry.newBuilder().setKey("key").setValue(type).build();
        
        MissionProgramParametersGen.MissionProgramParameters params = MissionProgramParametersGen.
                MissionProgramParameters.newBuilder().setProgramName("program1").setTemplateName("tName").
                setSchedule(sched).addParameters(entry).build();
        
        m_SUT.queueMessage(1, LoadParametersRequestData.newBuilder().setParameters(params).build(), 
                MissionProgrammingMessageType.LoadParametersRequest);
        
        ArgumentCaptor<MissionErrorHandler> argumentCaptor = ArgumentCaptor.forClass(MissionErrorHandler.class);
        
        verify(m_MessageWrapper).queue(eq(1), argumentCaptor.capture());
        
        //build the data first
        final GenericErrorResponseData genericErrorResponseMessage = GenericErrorResponseData.newBuilder().
            setError(ErrorCode.ILLEGAL_STATE).
            setErrorDescription("Error desc").
            build();
        
        // build a base namespace message
        final BaseNamespace baseMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.GenericErrorResponse).
                setData(genericErrorResponseMessage.toByteString()).
                build();
        //build a TerraHarvestPayLoad message
        final TerraHarvestPayload payLoad = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(baseMessage.toByteString()).
                build();
        // build a terra harvest message
        final TerraHarvestMessage fullMessage = TerraHarvestMessage.newBuilder().
                setVersion(RemoteConstants.SPEC_VERSION).
                setSourceId(1).
                // send message back to source
                setDestId(0).
                setMessageId(22).
                setTerraHarvestPayload(payLoad.toByteString()).
                build();
        
        MissionErrorHandler errorHandler = argumentCaptor.getValue();
        assertThat(errorHandler, notNullValue());
        
        errorHandler.handleResponse(fullMessage, payLoad, baseMessage, genericErrorResponseMessage);
        
        verify(m_GrowlUtil).createGlobalFacesMessage(eq(FacesMessage.SEVERITY_ERROR), 
                eq("Mission Loading Error Occurred"), Mockito.anyString());
    }
/**
     * Verify mission error handler response handler outputs a proper error message.
     */
Verify mission error handler response handler outputs a proper error message.
Verify mission error handler response handler outputs a proper error message .
@Test
    public void testMissionErrorHandler()
    {
        MissionProgramParametersGen.MissionProgramSchedule sched = MissionProgramParametersGen.MissionProgramSchedule.
                newBuilder().setAtReset(true).setImmediately(true).setIndefiniteInterval(true).build();
        Multitype type = Multitype.newBuilder().setType(Type.STRING).setStringValue("value").build();
        MapEntry entry = MapEntry.newBuilder().setKey("key").setValue(type).build();
        MissionProgramParametersGen.MissionProgramParameters params = MissionProgramParametersGen.
                MissionProgramParameters.newBuilder().setProgramName("program1").setTemplateName("tName").
                setSchedule(sched).addParameters(entry).build();
        m_SUT.queueMessage(1, LoadParametersRequestData.newBuilder().setParameters(params).build(), 
                MissionProgrammingMessageType.LoadParametersRequest);
        ArgumentCaptor<MissionErrorHandler> argumentCaptor = ArgumentCaptor.forClass(MissionErrorHandler.class);
        verify(m_MessageWrapper).queue(eq(1), argumentCaptor.capture());
        final GenericErrorResponseData genericErrorResponseMessage = GenericErrorResponseData.newBuilder().
            setError(ErrorCode.ILLEGAL_STATE).
            setErrorDescription("Error desc").
            build();
        final BaseNamespace baseMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.GenericErrorResponse).
                setData(genericErrorResponseMessage.toByteString()).
                build();
        final TerraHarvestPayload payLoad = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(baseMessage.toByteString()).
                build();
        final TerraHarvestMessage fullMessage = TerraHarvestMessage.newBuilder().
                setVersion(RemoteConstants.SPEC_VERSION).
                setSourceId(1).
                setDestId(0).
                setMessageId(22).
                setTerraHarvestPayload(payLoad.toByteString()).
                build();
        MissionErrorHandler errorHandler = argumentCaptor.getValue();
        assertThat(errorHandler, notNullValue());
        errorHandler.handleResponse(fullMessage, payLoad, baseMessage, genericErrorResponseMessage);
        verify(m_GrowlUtil).createGlobalFacesMessage(eq(FacesMessage.SEVERITY_ERROR), 
                eq("Mission Loading Error Occurred"), Mockito.anyString());
    }
@ Test public void testMissionErrorHandler ( ) { MissionProgramParametersGen . MissionProgramSchedule sched = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setAtReset ( true ) . setImmediately ( true ) . setIndefiniteInterval ( true ) . build ( ) ; Multitype type = Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "value" ) . build ( ) ; MapEntry entry = MapEntry . newBuilder ( ) . setKey ( "key" ) . setValue ( type ) . build ( ) ; MissionProgramParametersGen . MissionProgramParameters params = MissionProgramParametersGen . MissionProgramParameters . newBuilder ( ) . setProgramName ( "program1" ) . setTemplateName ( "tName" ) . setSchedule ( sched ) . addParameters ( entry ) . build ( ) ; m_SUT . queueMessage ( 1 , LoadParametersRequestData . newBuilder ( ) . setParameters ( params ) . build ( ) , MissionProgrammingMessageType . LoadParametersRequest ) ; ArgumentCaptor < MissionErrorHandler > argumentCaptor = ArgumentCaptor . forClass ( MissionErrorHandler . class ) ; verify ( m_MessageWrapper ) . queue ( eq ( 1 ) , argumentCaptor . capture ( ) ) ; final GenericErrorResponseData genericErrorResponseMessage = GenericErrorResponseData . newBuilder ( ) . setError ( ErrorCode . ILLEGAL_STATE ) . setErrorDescription ( "Error desc" ) . build ( ) ; final BaseNamespace baseMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GenericErrorResponse ) . setData ( genericErrorResponseMessage . toByteString ( ) ) . build ( ) ; final TerraHarvestPayload payLoad = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( baseMessage . toByteString ( ) ) . build ( ) ; final TerraHarvestMessage fullMessage = TerraHarvestMessage . newBuilder ( ) . setVersion ( RemoteConstants . SPEC_VERSION ) . setSourceId ( 1 ) . setDestId ( 0 ) . setMessageId ( 22 ) . setTerraHarvestPayload ( payLoad . toByteString ( ) ) . build ( ) ; MissionErrorHandler errorHandler = argumentCaptor . getValue ( ) ; assertThat ( errorHandler , notNullValue ( ) ) ; errorHandler . handleResponse ( fullMessage , payLoad , baseMessage , genericErrorResponseMessage ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( eq ( FacesMessage . SEVERITY_ERROR ) , eq ( "Mission Loading Error Occurred" ) , Mockito . anyString ( ) ) ; }
Verify mission error handler response handler outputs a proper error message.
Verify mission error handler response handler outputs a proper error message .
//build the data first // build a base namespace message //build a TerraHarvestPayLoad message // build a terra harvest message // send message back to source