mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetDirectoryMessageService.java
@Test
    public void testGetScannableAssetTypes() throws IOException
    {
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetScannableAssetTypesRequest).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        //mock out the asset dir svc response
        Set<String> clazzes = new HashSet<>();
        clazzes.add(AssetProxy.class.getName());
        when(m_AssetDirectoryService.getScannableAssetTypes()).thenReturn(clazzes);
    
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        //capture and verify event has been posted locally
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(AssetDirectoryServiceMessageType.GetScannableAssetTypesRequest.toString()));
        verify(m_AssetDirectoryService).getScannableAssetTypes();
        
        //capture and verify response
        ArgumentCaptor<GetScannableAssetTypesResponseData> messageCap = ArgumentCaptor.
                forClass(GetScannableAssetTypesResponseData.class);
        verify(m_MessageFactory).createAssetDirectoryServiceResponseMessage(eq(message), 
                eq(AssetDirectoryServiceMessageType.GetScannableAssetTypesResponse), messageCap.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        GetScannableAssetTypesResponseData responseData = messageCap.getValue();
        List<String> classes = responseData.getScannableAssetTypeList();
        assertThat(classes, hasItem(AssetProxy.class.getName()));
    }
/**
     * Verify handling of request for scannable asset types.
     * Verify event posted when message is received.
     * Verify response with list of product types.
     */
Verify handling of request for scannable asset types.
Verify event posted when message is received.
Verify response with list of product types.
Verify handling of request for scannable asset types . Verify event posted when message is received . Verify response with list of product types .
@Test
    public void testGetScannableAssetTypes() throws IOException
    {
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetScannableAssetTypesRequest).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        Set<String> clazzes = new HashSet<>();
        clazzes.add(AssetProxy.class.getName());
        when(m_AssetDirectoryService.getScannableAssetTypes()).thenReturn(clazzes);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(AssetDirectoryServiceMessageType.GetScannableAssetTypesRequest.toString()));
        verify(m_AssetDirectoryService).getScannableAssetTypes();
        ArgumentCaptor<GetScannableAssetTypesResponseData> messageCap = ArgumentCaptor.
                forClass(GetScannableAssetTypesResponseData.class);
        verify(m_MessageFactory).createAssetDirectoryServiceResponseMessage(eq(message), 
                eq(AssetDirectoryServiceMessageType.GetScannableAssetTypesResponse), messageCap.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetScannableAssetTypesResponseData responseData = messageCap.getValue();
        List<String> classes = responseData.getScannableAssetTypeList();
        assertThat(classes, hasItem(AssetProxy.class.getName()));
    }
@ Test public void testGetScannableAssetTypes ( ) throws IOException { AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace . newBuilder ( ) . setType ( AssetDirectoryServiceMessageType . GetScannableAssetTypesRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( assetDirMessage ) ; TerraHarvestMessage message = createMessage ( assetDirMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; Set < String > clazzes = new HashSet < > ( ) ; clazzes . add ( AssetProxy . class . getName ( ) ) ; when ( m_AssetDirectoryService . getScannableAssetTypes ( ) ) . thenReturn ( clazzes ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( AssetDirectoryServiceMessageType . GetScannableAssetTypesRequest . toString ( ) ) ) ; verify ( m_AssetDirectoryService ) . getScannableAssetTypes ( ) ; ArgumentCaptor < GetScannableAssetTypesResponseData > messageCap = ArgumentCaptor . forClass ( GetScannableAssetTypesResponseData . class ) ; verify ( m_MessageFactory ) . createAssetDirectoryServiceResponseMessage ( eq ( message ) , eq ( AssetDirectoryServiceMessageType . GetScannableAssetTypesResponse ) , messageCap . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetScannableAssetTypesResponseData responseData = messageCap . getValue ( ) ; List < String > classes = responseData . getScannableAssetTypeList ( ) ; assertThat ( classes , hasItem ( AssetProxy . class . getName ( ) ) ) ; }
Verify handling of request for scannable asset types.
Verify handling of request for scannable asset types .
// mock the channel the message came from //mock out the asset dir svc response // replay //capture and verify event has been posted locally //capture and verify response