mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestStreamProfileTrackerCustomizer.java
@SuppressWarnings("unchecked")
    @Test
    public void testAddingServiceExists() throws IllegalArgumentException, StreamProfileException
    {
        FactoryObjectConfig objectConfig = new FactoryObjectConfig()
            .withFactoryType(FactoryTypeEnum.STREAM_PROFILE)
            .withProperties(m_Properties)
            .withProductType(TEST_PID)
            .withCreatePolicy(CreatePolicyEnum.FIRST_RUN)
            .withName("StreamProfile1");
        
        when(m_StreamProfile.getName()).thenReturn("StreamProfile1");
        
        Set<StreamProfile> profiles = new HashSet<>();
        profiles.add(m_StreamProfile);
        when(m_DataStreamService.getStreamProfiles()).thenReturn(profiles);
        
        StreamProfileTrackerCustomizer sut = new StreamProfileTrackerCustomizer(objectConfig,
                m_DataStreamService, m_Log, m_EventAdmin);
        sut.addingService(m_ServiceReference);
        verify(m_DataStreamService, never()).createStreamProfile(eq(TEST_PID), eq("StreamProfile1"), any(Map.class));
    }
/**
     * Verify that if a service is added and the stream profile already exists, it is not recreated.
     */
Verify that if a service is added and the stream profile already exists, it is not recreated.
Verify that if a service is added and the stream profile already exists it is not recreated .
@SuppressWarnings("unchecked")
    @Test
    public void testAddingServiceExists() throws IllegalArgumentException, StreamProfileException
    {
        FactoryObjectConfig objectConfig = new FactoryObjectConfig()
            .withFactoryType(FactoryTypeEnum.STREAM_PROFILE)
            .withProperties(m_Properties)
            .withProductType(TEST_PID)
            .withCreatePolicy(CreatePolicyEnum.FIRST_RUN)
            .withName("StreamProfile1");
        when(m_StreamProfile.getName()).thenReturn("StreamProfile1");
        Set<StreamProfile> profiles = new HashSet<>();
        profiles.add(m_StreamProfile);
        when(m_DataStreamService.getStreamProfiles()).thenReturn(profiles);
        StreamProfileTrackerCustomizer sut = new StreamProfileTrackerCustomizer(objectConfig,
                m_DataStreamService, m_Log, m_EventAdmin);
        sut.addingService(m_ServiceReference);
        verify(m_DataStreamService, never()).createStreamProfile(eq(TEST_PID), eq("StreamProfile1"), any(Map.class));
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testAddingServiceExists ( ) throws IllegalArgumentException , StreamProfileException { FactoryObjectConfig objectConfig = new FactoryObjectConfig ( ) . withFactoryType ( FactoryTypeEnum . STREAM_PROFILE ) . withProperties ( m_Properties ) . withProductType ( TEST_PID ) . withCreatePolicy ( CreatePolicyEnum . FIRST_RUN ) . withName ( "StreamProfile1" ) ; when ( m_StreamProfile . getName ( ) ) . thenReturn ( "StreamProfile1" ) ; Set < StreamProfile > profiles = new HashSet < > ( ) ; profiles . add ( m_StreamProfile ) ; when ( m_DataStreamService . getStreamProfiles ( ) ) . thenReturn ( profiles ) ; StreamProfileTrackerCustomizer sut = new StreamProfileTrackerCustomizer ( objectConfig , m_DataStreamService , m_Log , m_EventAdmin ) ; sut . addingService ( m_ServiceReference ) ; verify ( m_DataStreamService , never ( ) ) . createStreamProfile ( eq ( TEST_PID ) , eq ( "StreamProfile1" ) , any ( Map . class ) ) ; }
Verify that if a service is added and the stream profile already exists, it is not recreated.
Verify that if a service is added and the stream profile already exists it is not recreated .