mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestStreamProfileTrackerCustomizer.java
@SuppressWarnings("unchecked")
    @Test
    public void testAddingServiceStreamProfileException() 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_DataStreamService.getStreamProfiles()).thenReturn(new HashSet<StreamProfile>());
        when(m_DataStreamService.createStreamProfile(eq(TEST_PID), eq("StreamProfile1"), any(Map.class))).
            thenThrow(new StreamProfileException("problem"));
        
        StreamProfileTrackerCustomizer sut = new StreamProfileTrackerCustomizer(objectConfig, m_DataStreamService,
                m_Log, m_EventAdmin);
        sut.addingService(m_ServiceReference);
        
        verify(m_DataStreamService, times(1)).createStreamProfile(eq(TEST_PID), eq("StreamProfile1"), any(Map.class));
        verify(m_Log).log(eq(LogService.LOG_WARNING), any(FactoryException.class), anyString(), any());
    }
/**
     * Verify error handling if a stream profile cannot be created.
     */
Verify error handling if a stream profile cannot be created.
Verify error handling if a stream profile cannot be created .
@SuppressWarnings("unchecked")
    @Test
    public void testAddingServiceStreamProfileException() 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_DataStreamService.getStreamProfiles()).thenReturn(new HashSet<StreamProfile>());
        when(m_DataStreamService.createStreamProfile(eq(TEST_PID), eq("StreamProfile1"), any(Map.class))).
            thenThrow(new StreamProfileException("problem"));
        StreamProfileTrackerCustomizer sut = new StreamProfileTrackerCustomizer(objectConfig, m_DataStreamService,
                m_Log, m_EventAdmin);
        sut.addingService(m_ServiceReference);
        verify(m_DataStreamService, times(1)).createStreamProfile(eq(TEST_PID), eq("StreamProfile1"), any(Map.class));
        verify(m_Log).log(eq(LogService.LOG_WARNING), any(FactoryException.class), anyString(), any());
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testAddingServiceStreamProfileException ( ) 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_DataStreamService . getStreamProfiles ( ) ) . thenReturn ( new HashSet < StreamProfile > ( ) ) ; when ( m_DataStreamService . createStreamProfile ( eq ( TEST_PID ) , eq ( "StreamProfile1" ) , any ( Map . class ) ) ) . thenThrow ( new StreamProfileException ( "problem" ) ) ; StreamProfileTrackerCustomizer sut = new StreamProfileTrackerCustomizer ( objectConfig , m_DataStreamService , m_Log , m_EventAdmin ) ; sut . addingService ( m_ServiceReference ) ; verify ( m_DataStreamService , times ( 1 ) ) . createStreamProfile ( eq ( TEST_PID ) , eq ( "StreamProfile1" ) , any ( Map . class ) ) ; verify ( m_Log ) . log ( eq ( LogService . LOG_WARNING ) , any ( FactoryException . class ) , anyString ( ) , any ( ) ) ; }
Verify error handling if a stream profile cannot be created.
Verify error handling if a stream profile cannot be created .