mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetDirectoryMessageService.java
@Test
    public void testGetAssetTypes() throws IOException
    {
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetAssetTypesRequest).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        AssetFactory factory = mock(AssetFactory.class);
        doReturn(AssetProxy.class.getName()).when(factory).getProductType();
        when(factory.getProductName()).thenReturn("Asset");
        Set<AssetFactory> factorySet = new HashSet<>();
        factorySet.add(factory);
        when(this.m_AssetDirectoryService.getAssetFactories()).thenReturn(factorySet);
               
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        ArgumentCaptor<GetAssetTypesResponseData> messageCaptor = ArgumentCaptor.
                forClass(GetAssetTypesResponseData.class); 
        verify(m_MessageFactory).createAssetDirectoryServiceResponseMessage(eq(message), 
                eq(AssetDirectoryServiceMessageType.GetAssetTypesResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);

        GetAssetTypesResponseData response = messageCaptor.getValue();
        
        assertThat(response.getProductNameCount(), is(1));
        assertThat(response.getProductTypeCount(), is(1));
        assertThat(response.getProductName(0), is(Asset.class.getSimpleName()));
        assertThat(response.getProductType(0), is(AssetProxy.class.getName()));
    }
/**
     * Test the get asset types request/response remote message system for the asset directory service.  
     * Specifically, the following behaviors are tested: 
     *      Verify asset name and type are returned.
     *      Verify response (containing correct data) is sent after completing request.
     */
Test the get asset types request/response remote message system for the asset directory service.
Specifically, the following behaviors are tested:
Verify asset name and type are returned.
Verify response (containing correct data) is sent after completing request.
Test the get asset types request / response remote message system for the asset directory service . Specifically the following behaviors are tested : Verify asset name and type are returned . Verify response ( containing correct data ) is sent after completing request .
@Test
    public void testGetAssetTypes() throws IOException
    {
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetAssetTypesRequest).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        AssetFactory factory = mock(AssetFactory.class);
        doReturn(AssetProxy.class.getName()).when(factory).getProductType();
        when(factory.getProductName()).thenReturn("Asset");
        Set<AssetFactory> factorySet = new HashSet<>();
        factorySet.add(factory);
        when(this.m_AssetDirectoryService.getAssetFactories()).thenReturn(factorySet);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<GetAssetTypesResponseData> messageCaptor = ArgumentCaptor.
                forClass(GetAssetTypesResponseData.class); 
        verify(m_MessageFactory).createAssetDirectoryServiceResponseMessage(eq(message), 
                eq(AssetDirectoryServiceMessageType.GetAssetTypesResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetAssetTypesResponseData response = messageCaptor.getValue();
        assertThat(response.getProductNameCount(), is(1));
        assertThat(response.getProductTypeCount(), is(1));
        assertThat(response.getProductName(0), is(Asset.class.getSimpleName()));
        assertThat(response.getProductType(0), is(AssetProxy.class.getName()));
    }
@ Test public void testGetAssetTypes ( ) throws IOException { AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace . newBuilder ( ) . setType ( AssetDirectoryServiceMessageType . GetAssetTypesRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( assetDirMessage ) ; TerraHarvestMessage message = createMessage ( assetDirMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; AssetFactory factory = mock ( AssetFactory . class ) ; doReturn ( AssetProxy . class . getName ( ) ) . when ( factory ) . getProductType ( ) ; when ( factory . getProductName ( ) ) . thenReturn ( "Asset" ) ; Set < AssetFactory > factorySet = new HashSet < > ( ) ; factorySet . add ( factory ) ; when ( this . m_AssetDirectoryService . getAssetFactories ( ) ) . thenReturn ( factorySet ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < GetAssetTypesResponseData > messageCaptor = ArgumentCaptor . forClass ( GetAssetTypesResponseData . class ) ; verify ( m_MessageFactory ) . createAssetDirectoryServiceResponseMessage ( eq ( message ) , eq ( AssetDirectoryServiceMessageType . GetAssetTypesResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetAssetTypesResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getProductNameCount ( ) , is ( 1 ) ) ; assertThat ( response . getProductTypeCount ( ) , is ( 1 ) ) ; assertThat ( response . getProductName ( 0 ) , is ( Asset . class . getSimpleName ( ) ) ) ; assertThat ( response . getProductType ( 0 ) , is ( AssetProxy . class . getName ( ) ) ) ; }
Test the get asset types request/response remote message system for the asset directory service.
Test the get asset types request / response remote message system for the asset directory service .
// mock the channel the message came from // replay