mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testAssetErrorHandler()
    {
        AssetExecuteErrorHandler assetErrorHandler = m_SUT.new AssetExecuteErrorHandler("name");
        
        GenericErrorResponseData errorResponse = GenericErrorResponseData.newBuilder().
                setError(ErrorCode.ASSET_ERROR).
                setErrorDescription("wow what an error").
                build();
        
        BaseNamespace nameResponse1 = BaseNamespace.newBuilder().
                setData(errorResponse.toByteString()).
                setType(BaseMessageType.GenericErrorResponse).build();
        
        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(nameResponse1.toByteString()).
                build();
        
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.Asset, 123, nameResponse1);
        
        assetErrorHandler.handleResponse(thMessage1, payload1, nameResponse1, errorResponse);
        
        //verify growl message
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_ERROR, "Asset Error Occurred", 
                String.format(
                        "Performing action ExecuteCommand for asset %s "
                        + "has resulted in the following error %n %s - %s", 
                        "name", ErrorCode.ASSET_ERROR, 
                        "wow what an error"));
        
        //verify that if namespace is not base then don't do anything
        TerraHarvestMessageHelper.handleAssetMessage(AssetMessageType.ExecuteCommandResponse, 
                ExecuteCommandResponseData.getDefaultInstance(), assetErrorHandler);
        
        //verify growl message
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_ERROR, "Asset Error Occurred", 
                String.format(
                        "Performing action ExecuteCommand for asset %s "
                        + "has resulted in the following error %n %s - %s", 
                        "name", ErrorCode.ASSET_ERROR, 
                        "wow what an error"));
        
        TerraHarvestMessageHelper.handleBaseMessage(BaseMessageType.GetControllerCapabilitiesResponse,
                GetControllerCapabilitiesResponseData.getDefaultInstance(), assetErrorHandler);
        
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_ERROR, "Asset Error Occurred", 
                String.format(
                        "Performing action ExecuteCommand for asset %s "
                        + "has resulted in the following error %n %s - %s", 
                        "name", ErrorCode.ASSET_ERROR, 
                        "wow what an error"));
    }
/**
     * Testing the asset error handler response handler class.
     * Verify proper message is handled.
     * Verify message of other namespace doesn't get handled.
     * Verify message of same namespace but different type does not get handled.
     */
Testing the asset error handler response handler class.
Verify proper message is handled.
Verify message of other namespace doesn't get handled.
Verify message of same namespace but different type does not get handled.
Testing the asset error handler response handler class . Verify proper message is handled . Verify message of other namespace doesn ' t get handled . Verify message of same namespace but different type does not get handled .
@Test
    public void testAssetErrorHandler()
    {
        AssetExecuteErrorHandler assetErrorHandler = m_SUT.new AssetExecuteErrorHandler("name");
        GenericErrorResponseData errorResponse = GenericErrorResponseData.newBuilder().
                setError(ErrorCode.ASSET_ERROR).
                setErrorDescription("wow what an error").
                build();
        BaseNamespace nameResponse1 = BaseNamespace.newBuilder().
                setData(errorResponse.toByteString()).
                setType(BaseMessageType.GenericErrorResponse).build();
        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(nameResponse1.toByteString()).
                build();
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.Asset, 123, nameResponse1);
        assetErrorHandler.handleResponse(thMessage1, payload1, nameResponse1, errorResponse);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_ERROR, "Asset Error Occurred", 
                String.format(
                        "Performing action ExecuteCommand for asset %s "
                        + "has resulted in the following error %n %s - %s", 
                        "name", ErrorCode.ASSET_ERROR, 
                        "wow what an error"));
        TerraHarvestMessageHelper.handleAssetMessage(AssetMessageType.ExecuteCommandResponse, 
                ExecuteCommandResponseData.getDefaultInstance(), assetErrorHandler);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_ERROR, "Asset Error Occurred", 
                String.format(
                        "Performing action ExecuteCommand for asset %s "
                        + "has resulted in the following error %n %s - %s", 
                        "name", ErrorCode.ASSET_ERROR, 
                        "wow what an error"));
        TerraHarvestMessageHelper.handleBaseMessage(BaseMessageType.GetControllerCapabilitiesResponse,
                GetControllerCapabilitiesResponseData.getDefaultInstance(), assetErrorHandler);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_ERROR, "Asset Error Occurred", 
                String.format(
                        "Performing action ExecuteCommand for asset %s "
                        + "has resulted in the following error %n %s - %s", 
                        "name", ErrorCode.ASSET_ERROR, 
                        "wow what an error"));
    }
@ Test public void testAssetErrorHandler ( ) { AssetExecuteErrorHandler assetErrorHandler = m_SUT . new AssetExecuteErrorHandler ( "name" ) ; GenericErrorResponseData errorResponse = GenericErrorResponseData . newBuilder ( ) . setError ( ErrorCode . ASSET_ERROR ) . setErrorDescription ( "wow what an error" ) . build ( ) ; BaseNamespace nameResponse1 = BaseNamespace . newBuilder ( ) . setData ( errorResponse . toByteString ( ) ) . setType ( BaseMessageType . GenericErrorResponse ) . build ( ) ; TerraHarvestPayload payload1 = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( nameResponse1 . toByteString ( ) ) . build ( ) ; TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . Asset , 123 , nameResponse1 ) ; assetErrorHandler . handleResponse ( thMessage1 , payload1 , nameResponse1 , errorResponse ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_ERROR , "Asset Error Occurred" , String . format ( "Performing action ExecuteCommand for asset %s " + "has resulted in the following error %n %s - %s" , "name" , ErrorCode . ASSET_ERROR , "wow what an error" ) ) ; TerraHarvestMessageHelper . handleAssetMessage ( AssetMessageType . ExecuteCommandResponse , ExecuteCommandResponseData . getDefaultInstance ( ) , assetErrorHandler ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_ERROR , "Asset Error Occurred" , String . format ( "Performing action ExecuteCommand for asset %s " + "has resulted in the following error %n %s - %s" , "name" , ErrorCode . ASSET_ERROR , "wow what an error" ) ) ; TerraHarvestMessageHelper . handleBaseMessage ( BaseMessageType . GetControllerCapabilitiesResponse , GetControllerCapabilitiesResponseData . getDefaultInstance ( ) , assetErrorHandler ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_ERROR , "Asset Error Occurred" , String . format ( "Performing action ExecuteCommand for asset %s " + "has resulted in the following error %n %s - %s" , "name" , ErrorCode . ASSET_ERROR , "wow what an error" ) ) ; }
Testing the asset error handler response handler class.
Testing the asset error handler response handler class .
//verify growl message //verify that if namespace is not base then don't do anything //verify growl message