mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestAssetDirectoryServiceNamespace.java
@Test
    public final void testGetAssets() throws IOException
    {      
        SharedMessages.UUID asset1uuid = AssetNamespaceUtils.createAsset(socket, ExampleAsset.class.getName(), "asset1",
                null).getInfo().getUuid();
        SharedMessages.UUID asset2uuid = AssetNamespaceUtils.createAsset(socket, ExampleAsset.class.getName(), "asset2",
                null).getInfo().getUuid();
        MessageListener listener = new MessageListener(socket);        
        
        TerraHarvestMessage message = AssetNamespaceUtils.createAssetDirSvcNamespaceMessage(
                AssetDirectoryServiceMessageType.GetAssetsRequest, null);        
        message.writeDelimitedTo(socket.getOutputStream());
        
        //listen for messages for a specific time interval
        AssetDirectoryServiceNamespace response = (AssetDirectoryServiceNamespace)listener.waitForMessage(
                Namespace.AssetDirectoryService, AssetDirectoryServiceMessageType.GetAssetsResponse, 500);
        
        GetAssetsResponseData dataResponse = GetAssetsResponseData.
                parseFrom(response.getData()); 
        
        //Get assets by name and check for any that contain AssetNamespaceUtils.DO_NOT_REMOVE String. These
        //should be excluded
        List<SharedMessages.UUID> includedUuidList = new ArrayList<>();
        
        for(FactoryObjectInfo type: dataResponse.getAssetInfoList())
        {           
            MessageListener assetMsgListener = new MessageListener(socket);
            GetNameRequestData getNameRequest = GetNameRequestData.newBuilder().
                    setUuid(type.getUuid()).build();
                    
            TerraHarvestMessage assetMsg = AssetNamespaceUtils.createAssetMessage(
                    AssetMessageType.GetNameRequest, getNameRequest);
            assetMsg.writeDelimitedTo(socket.getOutputStream());
            
            AssetNamespace assetResponse = (AssetNamespace)assetMsgListener.waitForMessage(
                    Namespace.Asset, AssetMessageType.GetNameResponse, 500);
            
            GetNameResponseData nameResponse = GetNameResponseData.parseFrom(assetResponse.getData());
            
            if (!nameResponse.getAssetName().contains(AssetNamespaceUtils.DO_NOT_REMOVE))
            {
                includedUuidList.add(type.getUuid());
            }         
        }

        assertThat(includedUuidList.size(), is(2));
        List<SharedMessages.UUID> myUuids = new ArrayList<SharedMessages.UUID>();
        myUuids.add(includedUuidList.get(0));
        myUuids.add(includedUuidList.get(1));    

        assertThat(myUuids, hasItems(asset1uuid, asset2uuid));
    }
/**
     * Verifies the ability of the system to handle a remote request to get all assets known to the service.   
     */
Verifies the ability of the system to handle a remote request to get all assets known to the service.
Verifies the ability of the system to handle a remote request to get all assets known to the service .
@Test
    public final void testGetAssets() throws IOException
    {      
        SharedMessages.UUID asset1uuid = AssetNamespaceUtils.createAsset(socket, ExampleAsset.class.getName(), "asset1",
                null).getInfo().getUuid();
        SharedMessages.UUID asset2uuid = AssetNamespaceUtils.createAsset(socket, ExampleAsset.class.getName(), "asset2",
                null).getInfo().getUuid();
        MessageListener listener = new MessageListener(socket);        
        TerraHarvestMessage message = AssetNamespaceUtils.createAssetDirSvcNamespaceMessage(
                AssetDirectoryServiceMessageType.GetAssetsRequest, null);        
        message.writeDelimitedTo(socket.getOutputStream());
        AssetDirectoryServiceNamespace response = (AssetDirectoryServiceNamespace)listener.waitForMessage(
                Namespace.AssetDirectoryService, AssetDirectoryServiceMessageType.GetAssetsResponse, 500);
        GetAssetsResponseData dataResponse = GetAssetsResponseData.
                parseFrom(response.getData()); 
        List<SharedMessages.UUID> includedUuidList = new ArrayList<>();
        for(FactoryObjectInfo type: dataResponse.getAssetInfoList())
        {           
            MessageListener assetMsgListener = new MessageListener(socket);
            GetNameRequestData getNameRequest = GetNameRequestData.newBuilder().
                    setUuid(type.getUuid()).build();
            TerraHarvestMessage assetMsg = AssetNamespaceUtils.createAssetMessage(
                    AssetMessageType.GetNameRequest, getNameRequest);
            assetMsg.writeDelimitedTo(socket.getOutputStream());
            AssetNamespace assetResponse = (AssetNamespace)assetMsgListener.waitForMessage(
                    Namespace.Asset, AssetMessageType.GetNameResponse, 500);
            GetNameResponseData nameResponse = GetNameResponseData.parseFrom(assetResponse.getData());
            if (!nameResponse.getAssetName().contains(AssetNamespaceUtils.DO_NOT_REMOVE))
            {
                includedUuidList.add(type.getUuid());
            }         
        }
        assertThat(includedUuidList.size(), is(2));
        List<SharedMessages.UUID> myUuids = new ArrayList<SharedMessages.UUID>();
        myUuids.add(includedUuidList.get(0));
        myUuids.add(includedUuidList.get(1));    
        assertThat(myUuids, hasItems(asset1uuid, asset2uuid));
    }
@ Test public final void testGetAssets ( ) throws IOException { SharedMessages . UUID asset1uuid = AssetNamespaceUtils . createAsset ( socket , ExampleAsset . class . getName ( ) , "asset1" , null ) . getInfo ( ) . getUuid ( ) ; SharedMessages . UUID asset2uuid = AssetNamespaceUtils . createAsset ( socket , ExampleAsset . class . getName ( ) , "asset2" , null ) . getInfo ( ) . getUuid ( ) ; MessageListener listener = new MessageListener ( socket ) ; TerraHarvestMessage message = AssetNamespaceUtils . createAssetDirSvcNamespaceMessage ( AssetDirectoryServiceMessageType . GetAssetsRequest , null ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; AssetDirectoryServiceNamespace response = ( AssetDirectoryServiceNamespace ) listener . waitForMessage ( Namespace . AssetDirectoryService , AssetDirectoryServiceMessageType . GetAssetsResponse , 500 ) ; GetAssetsResponseData dataResponse = GetAssetsResponseData . parseFrom ( response . getData ( ) ) ; List < SharedMessages . UUID > includedUuidList = new ArrayList < > ( ) ; for ( FactoryObjectInfo type : dataResponse . getAssetInfoList ( ) ) { MessageListener assetMsgListener = new MessageListener ( socket ) ; GetNameRequestData getNameRequest = GetNameRequestData . newBuilder ( ) . setUuid ( type . getUuid ( ) ) . build ( ) ; TerraHarvestMessage assetMsg = AssetNamespaceUtils . createAssetMessage ( AssetMessageType . GetNameRequest , getNameRequest ) ; assetMsg . writeDelimitedTo ( socket . getOutputStream ( ) ) ; AssetNamespace assetResponse = ( AssetNamespace ) assetMsgListener . waitForMessage ( Namespace . Asset , AssetMessageType . GetNameResponse , 500 ) ; GetNameResponseData nameResponse = GetNameResponseData . parseFrom ( assetResponse . getData ( ) ) ; if ( ! nameResponse . getAssetName ( ) . contains ( AssetNamespaceUtils . DO_NOT_REMOVE ) ) { includedUuidList . add ( type . getUuid ( ) ) ; } } assertThat ( includedUuidList . size ( ) , is ( 2 ) ) ; List < SharedMessages . UUID > myUuids = new ArrayList < SharedMessages . UUID > ( ) ; myUuids . add ( includedUuidList . get ( 0 ) ) ; myUuids . add ( includedUuidList . get ( 1 ) ) ; assertThat ( myUuids , hasItems ( asset1uuid , asset2uuid ) ) ; }
Verifies the ability of the system to handle a remote request to get all assets known to the service.
Verifies the ability of the system to handle a remote request to get all assets known to the service .
//listen for messages for a specific time interval //Get assets by name and check for any that contain AssetNamespaceUtils.DO_NOT_REMOVE String. These //should be excluded