mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/datastream/TestDataStreamMessageService.java
@Test
    public void testEnableStreamProfile() throws IOException
    {       
        EnableStreamProfileRequestData request = EnableStreamProfileRequestData.newBuilder().
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testProfileUuid)).build();
        DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace.newBuilder().
                setType(DataStreamServiceMessageType.EnableStreamProfileRequest).
                setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(dataStreamMessage);
        TerraHarvestMessage message = createMessage(dataStreamMessage);
        
        StreamProfile profile = mock(StreamProfile.class);
        
        when(m_DataStreamService.getStreamProfile(testProfileUuid)).thenReturn(profile);
        
        // 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((EnableStreamProfileRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        verify(profile).setEnabled(true);
        verify(m_MessageFactory).createDataStreamServiceResponseMessage(eq(message),
                eq(DataStreamServiceMessageType.EnableStreamProfileResponse), Mockito.any(Message.class));
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test the enable stream profile request/response remote message system for the datastream service.
     * Specifically, the following behaviors are tested: 
     * Verify incoming request message is posted to event admin.
     * Verify stream profile is enabled on request.
     * Verify response is sent after completing request to enable stream profile. 
     */
Test the enable stream profile request/response remote message system for the datastream service.
Specifically, the following behaviors are tested:
Verify incoming request message is posted to event admin.
Verify stream profile is enabled on request.
Verify response is sent after completing request to enable stream profile.
Test the enable stream profile request / response remote message system for the datastream service . Specifically the following behaviors are tested : Verify incoming request message is posted to event admin . Verify stream profile is enabled on request . Verify response is sent after completing request to enable stream profile .
@Test
    public void testEnableStreamProfile() throws IOException
    {       
        EnableStreamProfileRequestData request = EnableStreamProfileRequestData.newBuilder().
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testProfileUuid)).build();
        DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace.newBuilder().
                setType(DataStreamServiceMessageType.EnableStreamProfileRequest).
                setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(dataStreamMessage);
        TerraHarvestMessage message = createMessage(dataStreamMessage);
        StreamProfile profile = mock(StreamProfile.class);
        when(m_DataStreamService.getStreamProfile(testProfileUuid)).thenReturn(profile);
        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((EnableStreamProfileRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        verify(profile).setEnabled(true);
        verify(m_MessageFactory).createDataStreamServiceResponseMessage(eq(message),
                eq(DataStreamServiceMessageType.EnableStreamProfileResponse), Mockito.any(Message.class));
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testEnableStreamProfile ( ) throws IOException { EnableStreamProfileRequestData request = EnableStreamProfileRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testProfileUuid ) ) . build ( ) ; DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace . newBuilder ( ) . setType ( DataStreamServiceMessageType . EnableStreamProfileRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( dataStreamMessage ) ; TerraHarvestMessage message = createMessage ( dataStreamMessage ) ; StreamProfile profile = mock ( StreamProfile . class ) ; when ( m_DataStreamService . getStreamProfile ( testProfileUuid ) ) . thenReturn ( profile ) ; 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 ( ( EnableStreamProfileRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; verify ( profile ) . setEnabled ( true ) ; verify ( m_MessageFactory ) . createDataStreamServiceResponseMessage ( eq ( message ) , eq ( DataStreamServiceMessageType . EnableStreamProfileResponse ) , Mockito . any ( Message . class ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test the enable stream profile request/response remote message system for the datastream service.
Test the enable stream profile request / response remote message system for the datastream service .
// mock the channel the message came from // replay // capture and verify event has been posted locally