mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetDirectoryMessageService.java
@Test
    public void testGetAssets() throws IOException
    {
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetAssetsRequest).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        
        Asset asset1 = FactoryObjectMocker.mockFactoryObject(Asset.class, "IamApid");
        Asset asset2 = FactoryObjectMocker.mockFactoryObject(Asset.class, "IamApidTOOO");
        Set<Asset> assetSet = new HashSet<Asset>();
        assetSet.add(asset1);
        assetSet.add(asset2);
        
        when(m_AssetDirectoryService.getAssets()).thenReturn(assetSet);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        ArgumentCaptor<GetAssetsResponseData> messageCaptor = ArgumentCaptor.forClass(GetAssetsResponseData.class); 
        verify(m_MessageFactory).createAssetDirectoryServiceResponseMessage(eq(message), 
                eq(AssetDirectoryServiceMessageType.GetAssetsResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetAssetsResponseData response = messageCaptor.getValue();
        assertThat(response.getAssetInfoCount(), is(2));
        for (FactoryObjectInfo info : response.getAssetInfoList())
        {
            if (info.getUuid().equals(SharedMessageUtils.convertUUIDToProtoUUID(asset1.getUuid())))
            {
                assertThat(info.getPid().equals("IamApid"), is(true));
            }
            else
            {
                assertThat(info.getPid().equals("IamApidTOOO"), is(true));
                assertThat(info.getUuid().equals(SharedMessageUtils.convertUUIDToProtoUUID(asset2.getUuid())), 
                        is(true));
            }
        }
    }
/**
     * Test get assets request/response remote message system for the asset directory service.
     * Specifically, the following behaviors are tested: 
     *      Verify list of assets are returned.
     *      Verify response (containing correct data) is sent after completing request.
     */
Test get assets request/response remote message system for the asset directory service.
Specifically, the following behaviors are tested:
Verify list of assets are returned.
Verify response (containing correct data) is sent after completing request.
Test get assets request / response remote message system for the asset directory service . Specifically the following behaviors are tested : Verify list of assets are returned . Verify response ( containing correct data ) is sent after completing request .
@Test
    public void testGetAssets() throws IOException
    {
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetAssetsRequest).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        Asset asset1 = FactoryObjectMocker.mockFactoryObject(Asset.class, "IamApid");
        Asset asset2 = FactoryObjectMocker.mockFactoryObject(Asset.class, "IamApidTOOO");
        Set<Asset> assetSet = new HashSet<Asset>();
        assetSet.add(asset1);
        assetSet.add(asset2);
        when(m_AssetDirectoryService.getAssets()).thenReturn(assetSet);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<GetAssetsResponseData> messageCaptor = ArgumentCaptor.forClass(GetAssetsResponseData.class); 
        verify(m_MessageFactory).createAssetDirectoryServiceResponseMessage(eq(message), 
                eq(AssetDirectoryServiceMessageType.GetAssetsResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetAssetsResponseData response = messageCaptor.getValue();
        assertThat(response.getAssetInfoCount(), is(2));
        for (FactoryObjectInfo info : response.getAssetInfoList())
        {
            if (info.getUuid().equals(SharedMessageUtils.convertUUIDToProtoUUID(asset1.getUuid())))
            {
                assertThat(info.getPid().equals("IamApid"), is(true));
            }
            else
            {
                assertThat(info.getPid().equals("IamApidTOOO"), is(true));
                assertThat(info.getUuid().equals(SharedMessageUtils.convertUUIDToProtoUUID(asset2.getUuid())), 
                        is(true));
            }
        }
    }
@ Test public void testGetAssets ( ) throws IOException { AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace . newBuilder ( ) . setType ( AssetDirectoryServiceMessageType . GetAssetsRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( assetDirMessage ) ; TerraHarvestMessage message = createMessage ( assetDirMessage ) ; Asset asset1 = FactoryObjectMocker . mockFactoryObject ( Asset . class , "IamApid" ) ; Asset asset2 = FactoryObjectMocker . mockFactoryObject ( Asset . class , "IamApidTOOO" ) ; Set < Asset > assetSet = new HashSet < Asset > ( ) ; assetSet . add ( asset1 ) ; assetSet . add ( asset2 ) ; when ( m_AssetDirectoryService . getAssets ( ) ) . thenReturn ( assetSet ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < GetAssetsResponseData > messageCaptor = ArgumentCaptor . forClass ( GetAssetsResponseData . class ) ; verify ( m_MessageFactory ) . createAssetDirectoryServiceResponseMessage ( eq ( message ) , eq ( AssetDirectoryServiceMessageType . GetAssetsResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetAssetsResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getAssetInfoCount ( ) , is ( 2 ) ) ; for ( FactoryObjectInfo info : response . getAssetInfoList ( ) ) { if ( info . getUuid ( ) . equals ( SharedMessageUtils . convertUUIDToProtoUUID ( asset1 . getUuid ( ) ) ) ) { assertThat ( info . getPid ( ) . equals ( "IamApid" ) , is ( true ) ) ; } else { assertThat ( info . getPid ( ) . equals ( "IamApidTOOO" ) , is ( true ) ) ; assertThat ( info . getUuid ( ) . equals ( SharedMessageUtils . convertUUIDToProtoUUID ( asset2 . getUuid ( ) ) ) , is ( true ) ) ; } } }
Test get assets request/response remote message system for the asset directory service.
Test get assets request / response remote message system for the asset directory service .
// mock the channel the message came from // replay