mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetMessageService.java
@Test
    public void testDeactivateAsset() throws IOException
    {
        DeactivateRequestData request = DeactivateRequestData.newBuilder().
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        AssetNamespace assetDirMessage = AssetNamespace.newBuilder().
                setType(AssetMessageType.DeactivateRequest).
                setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        
        Asset asset = mock(Asset.class);
        when(m_AssetDirectoryService.getAssetByUuid(testUuid)).thenReturn(asset);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // 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((DeactivateRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        verify(asset).deactivateAsync();
        verify(m_MessageFactory).createAssetResponseMessage(eq(message), 
                eq(AssetMessageType.DeactivateResponse), 
                Mockito.any(Message.class));
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test the deactivate asset request/response remote message system for the asset directory service.
     * Specifically, the following behaviors are tested: 
     *      Verify incoming request message is posted to event admin.
     *      Verify asset is deactivated upon request.
     *      Verify response is sent after completing request.
     */
Test the deactivate asset request/response remote message system for the asset directory service.
Specifically, the following behaviors are tested:
Verify incoming request message is posted to event admin.
Verify asset is deactivated upon request.
Verify response is sent after completing request.
Test the deactivate asset request / response remote message system for the asset directory service . Specifically the following behaviors are tested : Verify incoming request message is posted to event admin . Verify asset is deactivated upon request . Verify response is sent after completing request .
@Test
    public void testDeactivateAsset() throws IOException
    {
        DeactivateRequestData request = DeactivateRequestData.newBuilder().
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        AssetNamespace assetDirMessage = AssetNamespace.newBuilder().
                setType(AssetMessageType.DeactivateRequest).
                setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        Asset asset = mock(Asset.class);
        when(m_AssetDirectoryService.getAssetByUuid(testUuid)).thenReturn(asset);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((DeactivateRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        verify(asset).deactivateAsync();
        verify(m_MessageFactory).createAssetResponseMessage(eq(message), 
                eq(AssetMessageType.DeactivateResponse), 
                Mockito.any(Message.class));
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testDeactivateAsset ( ) throws IOException { DeactivateRequestData request = DeactivateRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; AssetNamespace assetDirMessage = AssetNamespace . newBuilder ( ) . setType ( AssetMessageType . DeactivateRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( assetDirMessage ) ; TerraHarvestMessage message = createMessage ( assetDirMessage ) ; Asset asset = mock ( Asset . class ) ; when ( m_AssetDirectoryService . getAssetByUuid ( testUuid ) ) . thenReturn ( asset ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( DeactivateRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; verify ( asset ) . deactivateAsync ( ) ; verify ( m_MessageFactory ) . createAssetResponseMessage ( eq ( message ) , eq ( AssetMessageType . DeactivateResponse ) , Mockito . any ( Message . class ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test the deactivate asset request/response remote message system for the asset directory service.
Test the deactivate asset request / response remote message system for the asset directory service .
// mock the channel the message came from // replay //capture and verify event has been posted locally