mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testRemoteSetAssetNameHandler()
    {
        //verify no assets exist for the system
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(0));

        //get a handler
        RemoteSetAssetNameHandler handler = m_SUT.createRemoteAssetNameHandler(uuid1);
        
        //error message
        GenericErrorResponseData errorResponse = GenericErrorResponseData.newBuilder().
             setError(ErrorCode.INVALID_VALUE).setErrorDescription("Bad bad name").build();

        BaseNamespace namespace = BaseNamespace.newBuilder().
             setType(BaseMessageType.GenericErrorResponse).
             setData(errorResponse.toByteString()).build();

        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.Base).
                setNamespaceMessage(namespace.toByteString()).build();
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.
            createTerraHarvestMessage(systemId1, 0, Namespace.Base, 123, namespace);

        //handle response
        handler.handleResponse(thMessage1, payload1, namespace, errorResponse);

        //verify growl message
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Asset name change failed", 
                String.format("Asset with UUID " + uuid1.toString() + " from controller 0x%08x failed to " 
                    + "update its name, because: " + ErrorCode.INVALID_VALUE.toString() + " - " 
                        + "Bad bad name", systemId1));
        
        //verify that if namespace is not base then don't do anything
        TerraHarvestMessageHelper.handleAssetMessage(AssetMessageType.ExecuteCommandResponse, 
                ExecuteCommandResponseData.getDefaultInstance(), handler);

        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Asset name change failed", 
                String.format("Asset with UUID " + uuid1.toString() + " from controller 0x%08x failed to " 
                    + "update its name, because: " + ErrorCode.INVALID_VALUE.toString() + " - " 
                        + "Bad bad name", systemId1));
        
        TerraHarvestMessageHelper.handleBaseMessage(BaseMessageType.GetControllerCapabilitiesResponse,
                GetControllerCapabilitiesResponseData.getDefaultInstance(), handler);

        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Asset name change failed", 
                String.format("Asset with UUID " + uuid1.toString() + " from controller 0x%08x failed to " 
                    + "update its name, because: " + ErrorCode.INVALID_VALUE.toString() + " - " 
                        + "Bad bad name", systemId1));
    }
/**
     * Test the handling of the remote response handler for asset set name requests.
     * Verify that a growl message is posted if there the message is invalid.
     */
Test the handling of the remote response handler for asset set name requests.
Verify that a growl message is posted if there the message is invalid.
Test the handling of the remote response handler for asset set name requests . Verify that a growl message is posted if there the message is invalid .
@Test
    public void testRemoteSetAssetNameHandler()
    {
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(0));
        RemoteSetAssetNameHandler handler = m_SUT.createRemoteAssetNameHandler(uuid1);
        GenericErrorResponseData errorResponse = GenericErrorResponseData.newBuilder().
             setError(ErrorCode.INVALID_VALUE).setErrorDescription("Bad bad name").build();
        BaseNamespace namespace = BaseNamespace.newBuilder().
             setType(BaseMessageType.GenericErrorResponse).
             setData(errorResponse.toByteString()).build();
        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.Base).
                setNamespaceMessage(namespace.toByteString()).build();
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.
            createTerraHarvestMessage(systemId1, 0, Namespace.Base, 123, namespace);
        handler.handleResponse(thMessage1, payload1, namespace, errorResponse);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Asset name change failed", 
                String.format("Asset with UUID " + uuid1.toString() + " from controller 0x%08x failed to " 
                    + "update its name, because: " + ErrorCode.INVALID_VALUE.toString() + " - " 
                        + "Bad bad name", systemId1));
        TerraHarvestMessageHelper.handleAssetMessage(AssetMessageType.ExecuteCommandResponse, 
                ExecuteCommandResponseData.getDefaultInstance(), handler);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Asset name change failed", 
                String.format("Asset with UUID " + uuid1.toString() + " from controller 0x%08x failed to " 
                    + "update its name, because: " + ErrorCode.INVALID_VALUE.toString() + " - " 
                        + "Bad bad name", systemId1));
        TerraHarvestMessageHelper.handleBaseMessage(BaseMessageType.GetControllerCapabilitiesResponse,
                GetControllerCapabilitiesResponseData.getDefaultInstance(), handler);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Asset name change failed", 
                String.format("Asset with UUID " + uuid1.toString() + " from controller 0x%08x failed to " 
                    + "update its name, because: " + ErrorCode.INVALID_VALUE.toString() + " - " 
                        + "Bad bad name", systemId1));
    }
@ Test public void testRemoteSetAssetNameHandler ( ) { assertThat ( m_SUT . getAssetsForControllerAsync ( systemId1 ) . size ( ) , is ( 0 ) ) ; RemoteSetAssetNameHandler handler = m_SUT . createRemoteAssetNameHandler ( uuid1 ) ; GenericErrorResponseData errorResponse = GenericErrorResponseData . newBuilder ( ) . setError ( ErrorCode . INVALID_VALUE ) . setErrorDescription ( "Bad bad name" ) . build ( ) ; BaseNamespace namespace = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GenericErrorResponse ) . setData ( errorResponse . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload1 = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( namespace . toByteString ( ) ) . build ( ) ; TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . Base , 123 , namespace ) ; handler . handleResponse ( thMessage1 , payload1 , namespace , errorResponse ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , "Asset name change failed" , String . format ( "Asset with UUID " + uuid1 . toString ( ) + " from controller 0x%08x failed to " + "update its name, because: " + ErrorCode . INVALID_VALUE . toString ( ) + " - " + "Bad bad name" , systemId1 ) ) ; TerraHarvestMessageHelper . handleAssetMessage ( AssetMessageType . ExecuteCommandResponse , ExecuteCommandResponseData . getDefaultInstance ( ) , handler ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , "Asset name change failed" , String . format ( "Asset with UUID " + uuid1 . toString ( ) + " from controller 0x%08x failed to " + "update its name, because: " + ErrorCode . INVALID_VALUE . toString ( ) + " - " + "Bad bad name" , systemId1 ) ) ; TerraHarvestMessageHelper . handleBaseMessage ( BaseMessageType . GetControllerCapabilitiesResponse , GetControllerCapabilitiesResponseData . getDefaultInstance ( ) , handler ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , "Asset name change failed" , String . format ( "Asset with UUID " + uuid1 . toString ( ) + " from controller 0x%08x failed to " + "update its name, because: " + ErrorCode . INVALID_VALUE . toString ( ) + " - " + "Bad bad name" , systemId1 ) ) ; }
Test the handling of the remote response handler for asset set name requests.
Test the handling of the remote response handler for asset set name requests .
//verify no assets exist for the system //get a handler //error message //handle response //verify growl message //verify that if namespace is not base then don't do anything