mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/datastream/TestDataStreamMessageService.java
@Test
    public void testGetStreamProfiles() throws IOException, URISyntaxException
    {
        DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace.newBuilder()
                .setType(DataStreamServiceMessageType.GetStreamProfilesRequest).build();
        
        TerraHarvestPayload payload = createPayload(dataStreamMessage);
        TerraHarvestMessage message = createMessage(dataStreamMessage);
        
        Asset testAsset = FactoryObjectMocker.mockFactoryObject(Asset.class, "testAssetPid");
        StreamProfile streamProfile1 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid1");
        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"));
        StreamProfile streamProfile2 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid2");
        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"));
        Set<StreamProfile> streamProfileSet = new HashSet<StreamProfile>();
        streamProfileSet.add(streamProfile1);
        streamProfileSet.add(streamProfile2);
        
        when(m_DataStreamService.getStreamProfiles()).thenReturn(streamProfileSet);
        
        // 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())
        {
            if (profile.getInfo().getUuid().equals(
                    SharedMessageUtils.convertUUIDToProtoUUID(streamProfile1.getUuid())))
            {
                assertThat(profile.getInfo().getPid().equals("pid1"), is(true));
            }
            else
            {
                assertThat(profile.getInfo().getPid().equals("pid2"), is(true));
                assertThat(profile.getInfo().getUuid().equals(
                        SharedMessageUtils.convertUUIDToProtoUUID(streamProfile2.getUuid())), is(true));
            }
        }
    }
/**
     * Test get stream profiles request/response remote message system for the DataStream service.
     * Specifically, the following behaviors are tested: 
     *      Verify list of stream profiles are returned.
     *      Verify response (containing correct data) is sent after completing request.
     */
Test get stream profiles request/response remote message system for the DataStream service.
Specifically, the following behaviors are tested:
Verify list of stream profiles are returned.
Verify response (containing correct data) is sent after completing request.
Test get stream profiles request / response remote message system for the DataStream service . Specifically the following behaviors are tested : Verify list of stream profiles are returned . Verify response ( containing correct data ) is sent after completing request .
@Test
    public void testGetStreamProfiles() throws IOException, URISyntaxException
    {
        DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace.newBuilder()
                .setType(DataStreamServiceMessageType.GetStreamProfilesRequest).build();
        TerraHarvestPayload payload = createPayload(dataStreamMessage);
        TerraHarvestMessage message = createMessage(dataStreamMessage);
        Asset testAsset = FactoryObjectMocker.mockFactoryObject(Asset.class, "testAssetPid");
        StreamProfile streamProfile1 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid1");
        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"));
        StreamProfile streamProfile2 = FactoryObjectMocker.mockFactoryObject(StreamProfile.class, "pid2");
        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"));
        Set<StreamProfile> streamProfileSet = new HashSet<StreamProfile>();
        streamProfileSet.add(streamProfile1);
        streamProfileSet.add(streamProfile2);
        when(m_DataStreamService.getStreamProfiles()).thenReturn(streamProfileSet);
        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())
        {
            if (profile.getInfo().getUuid().equals(
                    SharedMessageUtils.convertUUIDToProtoUUID(streamProfile1.getUuid())))
            {
                assertThat(profile.getInfo().getPid().equals("pid1"), is(true));
            }
            else
            {
                assertThat(profile.getInfo().getPid().equals("pid2"), is(true));
                assertThat(profile.getInfo().getUuid().equals(
                        SharedMessageUtils.convertUUIDToProtoUUID(streamProfile2.getUuid())), is(true));
            }
        }
    }
@ Test public void testGetStreamProfiles ( ) throws IOException , URISyntaxException { DataStreamServiceNamespace dataStreamMessage = DataStreamServiceNamespace . newBuilder ( ) . setType ( DataStreamServiceMessageType . GetStreamProfilesRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( dataStreamMessage ) ; TerraHarvestMessage message = createMessage ( dataStreamMessage ) ; Asset testAsset = FactoryObjectMocker . mockFactoryObject ( Asset . class , "testAssetPid" ) ; StreamProfile streamProfile1 = FactoryObjectMocker . mockFactoryObject ( StreamProfile . class , "pid1" ) ; 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" ) ) ; StreamProfile streamProfile2 = FactoryObjectMocker . mockFactoryObject ( StreamProfile . class , "pid2" ) ; 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" ) ) ; Set < StreamProfile > streamProfileSet = new HashSet < StreamProfile > ( ) ; streamProfileSet . add ( streamProfile1 ) ; streamProfileSet . add ( streamProfile2 ) ; when ( m_DataStreamService . getStreamProfiles ( ) ) . thenReturn ( streamProfileSet ) ; 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 ( ) ) { if ( profile . getInfo ( ) . getUuid ( ) . equals ( SharedMessageUtils . convertUUIDToProtoUUID ( streamProfile1 . getUuid ( ) ) ) ) { assertThat ( profile . getInfo ( ) . getPid ( ) . equals ( "pid1" ) , is ( true ) ) ; } else { assertThat ( profile . getInfo ( ) . getPid ( ) . equals ( "pid2" ) , is ( true ) ) ; assertThat ( profile . getInfo ( ) . getUuid ( ) . equals ( SharedMessageUtils . convertUUIDToProtoUUID ( streamProfile2 . getUuid ( ) ) ) , is ( true ) ) ; } } }
Test get stream profiles request/response remote message system for the DataStream service.
Test get stream profiles request / response remote message system for the DataStream service .
// mock the channel the message came from // replay