mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/datastream/TestDataStreamMessageService.java
@Test
    public void testGetStreamProfilesByAssetUuid() throws IOException, URISyntaxException
    {
        
        Asset testAsset = FactoryObjectMocker.mockFactoryObject(Asset.class, "testAssetPid");
        Asset otherTestAsset = FactoryObjectMocker.mockFactoryObject(Asset.class, "otherAssetPid");
        
        GetStreamProfilesRequestData request = GetStreamProfilesRequestData.newBuilder()
                .setAssetUuid(SharedMessageUtils.convertUUIDToProtoUUID(testAsset.getUuid())).build();
        
        DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace.newBuilder()
                .setType(DataStreamServiceMessageType.GetStreamProfilesRequest)
                .setData(request.toByteString()).build();
        
        TerraHarvestPayload payload = createPayload(dataStreamMessage);
        TerraHarvestMessage message = createMessage(dataStreamMessage);

        StreamProfile streamProfile1 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid1");
        StreamProfile streamProfile2 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid2");
        StreamProfile streamProfile3 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid3");
        
        when(streamProfile1.getAsset()).thenReturn(testAsset);
        when(streamProfile1.getFormat()).thenReturn("video/mpeg");
        when(streamProfile1.getSensorId()).thenReturn("testSensor");
        when(streamProfile1.getStreamPort()).thenReturn(new URI("rtp://225.1.2.3:10000"));
        
        when(streamProfile2.getAsset()).thenReturn(testAsset);
        when(streamProfile2.getFormat()).thenReturn("video/mpeg");
        when(streamProfile2.getSensorId()).thenReturn("testSensor");
        when(streamProfile2.getStreamPort()).thenReturn(new URI("rtp://225.1.2.3:20000"));
        
        when(streamProfile3.getAsset()).thenReturn(otherTestAsset);
        when(streamProfile3.getFormat()).thenReturn("video/mpeg");
        when(streamProfile3.getSensorId()).thenReturn("testSensor");
        when(streamProfile3.getStreamPort()).thenReturn(new URI("rtp://225.1.2.3:30000"));
        
        Set<StreamProfile> allStreamProfileSet = new HashSet<StreamProfile>();
        allStreamProfileSet.add(streamProfile1);
        allStreamProfileSet.add(streamProfile2);
        allStreamProfileSet.add(streamProfile3);
        
        Set<StreamProfile> testAssetStreamProfileSet = new HashSet<StreamProfile>();
        testAssetStreamProfileSet.add(streamProfile1);
        testAssetStreamProfileSet.add(streamProfile2);
        
        when(m_AssetDirectoryService.getAssetByUuid(testAsset.getUuid())).thenReturn(testAsset);
        when(m_DataStreamService.getStreamProfiles()).thenReturn(allStreamProfileSet);
        when(m_DataStreamService.getStreamProfiles(testAsset)).thenReturn(testAssetStreamProfileSet);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        ArgumentCaptor<GetStreamProfilesResponseData> messageCaptor = 
                ArgumentCaptor.forClass(GetStreamProfilesResponseData.class);
        verify(m_MessageFactory).createDataStreamServiceResponseMessage(eq(message), 
                eq(DataStreamServiceMessageType.GetStreamProfilesResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetStreamProfilesResponseData response = messageCaptor.getValue();
        assertThat(response.getStreamProfileCount(), is(2));
        for (DataStreamServiceMessages.StreamProfile profile : response.getStreamProfileList())
        {
            // Assert that each stream profile returned is associated with testAsset
            assertThat(profile.getAssetUuid(), 
                    is(SharedMessageUtils.convertUUIDToProtoUUID(testAsset.getUuid())));            
        }
    }
/**
     * Test get stream profile request/response for the case where only those stream profiles associated
     * with a particular asset should be returned.
     */
Test get stream profile request/response for the case where only those stream profiles associated
with a particular asset should be returned.
Test get stream profile request / response for the case where only those stream profiles associated with a particular asset should be returned .
@Test
    public void testGetStreamProfilesByAssetUuid() throws IOException, URISyntaxException
    {
        Asset testAsset = FactoryObjectMocker.mockFactoryObject(Asset.class, "testAssetPid");
        Asset otherTestAsset = FactoryObjectMocker.mockFactoryObject(Asset.class, "otherAssetPid");
        GetStreamProfilesRequestData request = GetStreamProfilesRequestData.newBuilder()
                .setAssetUuid(SharedMessageUtils.convertUUIDToProtoUUID(testAsset.getUuid())).build();
        DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace.newBuilder()
                .setType(DataStreamServiceMessageType.GetStreamProfilesRequest)
                .setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(dataStreamMessage);
        TerraHarvestMessage message = createMessage(dataStreamMessage);
        StreamProfile streamProfile1 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid1");
        StreamProfile streamProfile2 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid2");
        StreamProfile streamProfile3 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid3");
        when(streamProfile1.getAsset()).thenReturn(testAsset);
        when(streamProfile1.getFormat()).thenReturn("video/mpeg");
        when(streamProfile1.getSensorId()).thenReturn("testSensor");
        when(streamProfile1.getStreamPort()).thenReturn(new URI("rtp://225.1.2.3:10000"));
        when(streamProfile2.getAsset()).thenReturn(testAsset);
        when(streamProfile2.getFormat()).thenReturn("video/mpeg");
        when(streamProfile2.getSensorId()).thenReturn("testSensor");
        when(streamProfile2.getStreamPort()).thenReturn(new URI("rtp://225.1.2.3:20000"));
        when(streamProfile3.getAsset()).thenReturn(otherTestAsset);
        when(streamProfile3.getFormat()).thenReturn("video/mpeg");
        when(streamProfile3.getSensorId()).thenReturn("testSensor");
        when(streamProfile3.getStreamPort()).thenReturn(new URI("rtp://225.1.2.3:30000"));
        Set<StreamProfile> allStreamProfileSet = new HashSet<StreamProfile>();
        allStreamProfileSet.add(streamProfile1);
        allStreamProfileSet.add(streamProfile2);
        allStreamProfileSet.add(streamProfile3);
        Set<StreamProfile> testAssetStreamProfileSet = new HashSet<StreamProfile>();
        testAssetStreamProfileSet.add(streamProfile1);
        testAssetStreamProfileSet.add(streamProfile2);
        when(m_AssetDirectoryService.getAssetByUuid(testAsset.getUuid())).thenReturn(testAsset);
        when(m_DataStreamService.getStreamProfiles()).thenReturn(allStreamProfileSet);
        when(m_DataStreamService.getStreamProfiles(testAsset)).thenReturn(testAssetStreamProfileSet);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<GetStreamProfilesResponseData> messageCaptor = 
                ArgumentCaptor.forClass(GetStreamProfilesResponseData.class);
        verify(m_MessageFactory).createDataStreamServiceResponseMessage(eq(message), 
                eq(DataStreamServiceMessageType.GetStreamProfilesResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetStreamProfilesResponseData response = messageCaptor.getValue();
        assertThat(response.getStreamProfileCount(), is(2));
        for (DataStreamServiceMessages.StreamProfile profile : response.getStreamProfileList())
        {
            assertThat(profile.getAssetUuid(), 
                    is(SharedMessageUtils.convertUUIDToProtoUUID(testAsset.getUuid())));            
        }
    }
@ Test public void testGetStreamProfilesByAssetUuid ( ) throws IOException , URISyntaxException { Asset testAsset = FactoryObjectMocker . mockFactoryObject ( Asset . class , "testAssetPid" ) ; Asset otherTestAsset = FactoryObjectMocker . mockFactoryObject ( Asset . class , "otherAssetPid" ) ; GetStreamProfilesRequestData request = GetStreamProfilesRequestData . newBuilder ( ) . setAssetUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testAsset . getUuid ( ) ) ) . build ( ) ; DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace . newBuilder ( ) . setType ( DataStreamServiceMessageType . GetStreamProfilesRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( dataStreamMessage ) ; TerraHarvestMessage message = createMessage ( dataStreamMessage ) ; StreamProfile streamProfile1 = FactoryObjectMocker . mockFactoryObject ( StreamProfile . class , "pid1" ) ; StreamProfile streamProfile2 = FactoryObjectMocker . mockFactoryObject ( StreamProfile . class , "pid2" ) ; StreamProfile streamProfile3 = FactoryObjectMocker . mockFactoryObject ( StreamProfile . class , "pid3" ) ; when ( streamProfile1 . getAsset ( ) ) . thenReturn ( testAsset ) ; when ( streamProfile1 . getFormat ( ) ) . thenReturn ( "video/mpeg" ) ; when ( streamProfile1 . getSensorId ( ) ) . thenReturn ( "testSensor" ) ; when ( streamProfile1 . getStreamPort ( ) ) . thenReturn ( new URI ( "rtp://225.1.2.3:10000" ) ) ; when ( streamProfile2 . getAsset ( ) ) . thenReturn ( testAsset ) ; when ( streamProfile2 . getFormat ( ) ) . thenReturn ( "video/mpeg" ) ; when ( streamProfile2 . getSensorId ( ) ) . thenReturn ( "testSensor" ) ; when ( streamProfile2 . getStreamPort ( ) ) . thenReturn ( new URI ( "rtp://225.1.2.3:20000" ) ) ; when ( streamProfile3 . getAsset ( ) ) . thenReturn ( otherTestAsset ) ; when ( streamProfile3 . getFormat ( ) ) . thenReturn ( "video/mpeg" ) ; when ( streamProfile3 . getSensorId ( ) ) . thenReturn ( "testSensor" ) ; when ( streamProfile3 . getStreamPort ( ) ) . thenReturn ( new URI ( "rtp://225.1.2.3:30000" ) ) ; Set < StreamProfile > allStreamProfileSet = new HashSet < StreamProfile > ( ) ; allStreamProfileSet . add ( streamProfile1 ) ; allStreamProfileSet . add ( streamProfile2 ) ; allStreamProfileSet . add ( streamProfile3 ) ; Set < StreamProfile > testAssetStreamProfileSet = new HashSet < StreamProfile > ( ) ; testAssetStreamProfileSet . add ( streamProfile1 ) ; testAssetStreamProfileSet . add ( streamProfile2 ) ; when ( m_AssetDirectoryService . getAssetByUuid ( testAsset . getUuid ( ) ) ) . thenReturn ( testAsset ) ; when ( m_DataStreamService . getStreamProfiles ( ) ) . thenReturn ( allStreamProfileSet ) ; when ( m_DataStreamService . getStreamProfiles ( testAsset ) ) . thenReturn ( testAssetStreamProfileSet ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < GetStreamProfilesResponseData > messageCaptor = ArgumentCaptor . forClass ( GetStreamProfilesResponseData . class ) ; verify ( m_MessageFactory ) . createDataStreamServiceResponseMessage ( eq ( message ) , eq ( DataStreamServiceMessageType . GetStreamProfilesResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetStreamProfilesResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getStreamProfileCount ( ) , is ( 2 ) ) ; for ( DataStreamServiceMessages . StreamProfile profile : response . getStreamProfileList ( ) ) { assertThat ( profile . getAssetUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( testAsset . getUuid ( ) ) ) ) ; } }
Test get stream profile request/response for the case where only those stream profiles associated
 with a particular asset should be returned.
Test get stream profile request / response for the case where only those stream profiles associated with a particular asset should be returned .
// mock the channel the message came from // replay // Assert that each stream profile returned is associated with testAsset