mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestConfigurationMgr.java
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testFrameworkEventStarted_FirstRunAlreadySet() throws IOException, UnmarshalException
    {
        when(m_ConfigAdmin.getConfiguration(ConfigurationMgr.class.getName())).thenReturn(m_OSGiConfiguration);
        Dictionary<String, Object> properties = new Hashtable<>();
        properties.put(ConfigurationMgrConfig.FIRST_RUN_PROPERTY, false);
        when(m_OSGiConfiguration.getProperties()).thenReturn(properties);
        
        List<FactoryObjectConfig> fConfigs = new ArrayList<>();
        FactoryObjectConfig config = mock(FactoryObjectConfig.class);
        fConfigs.add(config);
        
        List<PidConfig> pConfigs = new ArrayList<>();
        PidConfig pconfig = mock(PidConfig.class);
        pConfigs.add(pconfig);
        
        List<AddressConfig> aConfigs = new ArrayList<>();
        AddressConfig aconfig = mock(AddressConfig.class);
        aConfigs.add(aconfig);
        
        List<EventConfig> eConfigs = new ArrayList<>();
        EventConfig eConfig = mock(EventConfig.class);
        eConfigs.add(eConfig);
        
        List<SocketChannelConfig> sConfigs = new ArrayList<>();
        SocketChannelConfig sConfig = mock(SocketChannelConfig.class);
        sConfigs.add(sConfig);
        
        List<TransportChannelConfig> tConfigs = new ArrayList<>();
        TransportChannelConfig tConfig = mock(TransportChannelConfig.class);
        tConfigs.add(tConfig);
        
        when(m_XmlConfiguration.getFactoryObjects()).thenReturn(fConfigs);
        when(m_XmlConfiguration.getOsgiConfigs()).thenReturn(pConfigs);
        when(m_XmlConfiguration.getAddresses()).thenReturn(aConfigs);
        when(m_XmlConfiguration.getEventRegs()).thenReturn(eConfigs);
        when(m_XmlConfiguration.getSocketChannels()).thenReturn(sConfigs);
        when(m_XmlConfiguration.getTransportChannels()).thenReturn(tConfigs);
        
        m_SUT.activate(m_BundleContext);
        
        ArgumentCaptor<List> fCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_FactoryObjLoader).process(fCaptor.capture(), eq(false));
        
        assertThat(fCaptor.getValue().size(), is(1));
        assertThat((FactoryObjectConfig)fCaptor.getValue().get(0), is(config));
        
        ArgumentCaptor<List> pCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_OsgiConfigLoader).process(pCaptor.capture(), eq(false));
        
        assertThat(pCaptor.getValue().size(), is(1));
        assertThat((PidConfig)pCaptor.getValue().get(0), is(pconfig));
        
        ArgumentCaptor<List> aCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_AddrConfigLoader).process(aCaptor.capture(), eq(false));
        
        assertThat(aCaptor.getValue().size(), is(1));
        assertThat((AddressConfig)aCaptor.getValue().get(0), is(aconfig));
        
        ArgumentCaptor<List> eCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_EventConfigLoader).process(eCaptor.capture());
        assertThat(eCaptor.getValue().size(), is(1));
        assertThat((EventConfig)eCaptor.getValue().get(0), is(eConfig));
        
        ArgumentCaptor<List> sCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processSocketChannels(sCaptor.capture());
        assertThat(sCaptor.getValue().size(), is(1));
        assertThat((SocketChannelConfig)sCaptor.getValue().get(0), is(sConfig));
        
        ArgumentCaptor<List> tCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processTransportChannels(tCaptor.capture());
        assertThat(tCaptor.getValue().size(), is(1));
        assertThat((TransportChannelConfig)tCaptor.getValue().get(0), is(tConfig));
        
        verify(m_OSGiConfiguration, never()).update(Mockito.any(Dictionary.class));

        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin,
            ConfigLoadingConstants.TOPIC_CONFIG_PROCESSING_COMPLETE_EVENT);
    }
/**
     * Verify that on framework started event with configuration property already set that correct firstRun flag is
     * passed on.
     */
Verify that on framework started event with configuration property already set that correct firstRun flag is
passed on.
Verify that on framework started event with configuration property already set that correct firstRun flag is passed on .
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testFrameworkEventStarted_FirstRunAlreadySet() throws IOException, UnmarshalException
    {
        when(m_ConfigAdmin.getConfiguration(ConfigurationMgr.class.getName())).thenReturn(m_OSGiConfiguration);
        Dictionary<String, Object> properties = new Hashtable<>();
        properties.put(ConfigurationMgrConfig.FIRST_RUN_PROPERTY, false);
        when(m_OSGiConfiguration.getProperties()).thenReturn(properties);
        List<FactoryObjectConfig> fConfigs = new ArrayList<>();
        FactoryObjectConfig config = mock(FactoryObjectConfig.class);
        fConfigs.add(config);
        List<PidConfig> pConfigs = new ArrayList<>();
        PidConfig pconfig = mock(PidConfig.class);
        pConfigs.add(pconfig);
        List<AddressConfig> aConfigs = new ArrayList<>();
        AddressConfig aconfig = mock(AddressConfig.class);
        aConfigs.add(aconfig);
        List<EventConfig> eConfigs = new ArrayList<>();
        EventConfig eConfig = mock(EventConfig.class);
        eConfigs.add(eConfig);
        List<SocketChannelConfig> sConfigs = new ArrayList<>();
        SocketChannelConfig sConfig = mock(SocketChannelConfig.class);
        sConfigs.add(sConfig);
        List<TransportChannelConfig> tConfigs = new ArrayList<>();
        TransportChannelConfig tConfig = mock(TransportChannelConfig.class);
        tConfigs.add(tConfig);
        when(m_XmlConfiguration.getFactoryObjects()).thenReturn(fConfigs);
        when(m_XmlConfiguration.getOsgiConfigs()).thenReturn(pConfigs);
        when(m_XmlConfiguration.getAddresses()).thenReturn(aConfigs);
        when(m_XmlConfiguration.getEventRegs()).thenReturn(eConfigs);
        when(m_XmlConfiguration.getSocketChannels()).thenReturn(sConfigs);
        when(m_XmlConfiguration.getTransportChannels()).thenReturn(tConfigs);
        m_SUT.activate(m_BundleContext);
        ArgumentCaptor<List> fCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_FactoryObjLoader).process(fCaptor.capture(), eq(false));
        assertThat(fCaptor.getValue().size(), is(1));
        assertThat((FactoryObjectConfig)fCaptor.getValue().get(0), is(config));
        ArgumentCaptor<List> pCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_OsgiConfigLoader).process(pCaptor.capture(), eq(false));
        assertThat(pCaptor.getValue().size(), is(1));
        assertThat((PidConfig)pCaptor.getValue().get(0), is(pconfig));
        ArgumentCaptor<List> aCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_AddrConfigLoader).process(aCaptor.capture(), eq(false));
        assertThat(aCaptor.getValue().size(), is(1));
        assertThat((AddressConfig)aCaptor.getValue().get(0), is(aconfig));
        ArgumentCaptor<List> eCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_EventConfigLoader).process(eCaptor.capture());
        assertThat(eCaptor.getValue().size(), is(1));
        assertThat((EventConfig)eCaptor.getValue().get(0), is(eConfig));
        ArgumentCaptor<List> sCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processSocketChannels(sCaptor.capture());
        assertThat(sCaptor.getValue().size(), is(1));
        assertThat((SocketChannelConfig)sCaptor.getValue().get(0), is(sConfig));
        ArgumentCaptor<List> tCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processTransportChannels(tCaptor.capture());
        assertThat(tCaptor.getValue().size(), is(1));
        assertThat((TransportChannelConfig)tCaptor.getValue().get(0), is(tConfig));
        verify(m_OSGiConfiguration, never()).update(Mockito.any(Dictionary.class));
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin,
            ConfigLoadingConstants.TOPIC_CONFIG_PROCESSING_COMPLETE_EVENT);
    }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ Test public void testFrameworkEventStarted_FirstRunAlreadySet ( ) throws IOException , UnmarshalException { when ( m_ConfigAdmin . getConfiguration ( ConfigurationMgr . class . getName ( ) ) ) . thenReturn ( m_OSGiConfiguration ) ; Dictionary < String , Object > properties = new Hashtable < > ( ) ; properties . put ( ConfigurationMgrConfig . FIRST_RUN_PROPERTY , false ) ; when ( m_OSGiConfiguration . getProperties ( ) ) . thenReturn ( properties ) ; List < FactoryObjectConfig > fConfigs = new ArrayList < > ( ) ; FactoryObjectConfig config = mock ( FactoryObjectConfig . class ) ; fConfigs . add ( config ) ; List < PidConfig > pConfigs = new ArrayList < > ( ) ; PidConfig pconfig = mock ( PidConfig . class ) ; pConfigs . add ( pconfig ) ; List < AddressConfig > aConfigs = new ArrayList < > ( ) ; AddressConfig aconfig = mock ( AddressConfig . class ) ; aConfigs . add ( aconfig ) ; List < EventConfig > eConfigs = new ArrayList < > ( ) ; EventConfig eConfig = mock ( EventConfig . class ) ; eConfigs . add ( eConfig ) ; List < SocketChannelConfig > sConfigs = new ArrayList < > ( ) ; SocketChannelConfig sConfig = mock ( SocketChannelConfig . class ) ; sConfigs . add ( sConfig ) ; List < TransportChannelConfig > tConfigs = new ArrayList < > ( ) ; TransportChannelConfig tConfig = mock ( TransportChannelConfig . class ) ; tConfigs . add ( tConfig ) ; when ( m_XmlConfiguration . getFactoryObjects ( ) ) . thenReturn ( fConfigs ) ; when ( m_XmlConfiguration . getOsgiConfigs ( ) ) . thenReturn ( pConfigs ) ; when ( m_XmlConfiguration . getAddresses ( ) ) . thenReturn ( aConfigs ) ; when ( m_XmlConfiguration . getEventRegs ( ) ) . thenReturn ( eConfigs ) ; when ( m_XmlConfiguration . getSocketChannels ( ) ) . thenReturn ( sConfigs ) ; when ( m_XmlConfiguration . getTransportChannels ( ) ) . thenReturn ( tConfigs ) ; m_SUT . activate ( m_BundleContext ) ; ArgumentCaptor < List > fCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_FactoryObjLoader ) . process ( fCaptor . capture ( ) , eq ( false ) ) ; assertThat ( fCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( FactoryObjectConfig ) fCaptor . getValue ( ) . get ( 0 ) , is ( config ) ) ; ArgumentCaptor < List > pCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_OsgiConfigLoader ) . process ( pCaptor . capture ( ) , eq ( false ) ) ; assertThat ( pCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( PidConfig ) pCaptor . getValue ( ) . get ( 0 ) , is ( pconfig ) ) ; ArgumentCaptor < List > aCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_AddrConfigLoader ) . process ( aCaptor . capture ( ) , eq ( false ) ) ; assertThat ( aCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( AddressConfig ) aCaptor . getValue ( ) . get ( 0 ) , is ( aconfig ) ) ; ArgumentCaptor < List > eCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_EventConfigLoader ) . process ( eCaptor . capture ( ) ) ; assertThat ( eCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( EventConfig ) eCaptor . getValue ( ) . get ( 0 ) , is ( eConfig ) ) ; ArgumentCaptor < List > sCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_ChannelConfigLoader ) . processSocketChannels ( sCaptor . capture ( ) ) ; assertThat ( sCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( SocketChannelConfig ) sCaptor . getValue ( ) . get ( 0 ) , is ( sConfig ) ) ; ArgumentCaptor < List > tCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_ChannelConfigLoader ) . processTransportChannels ( tCaptor . capture ( ) ) ; assertThat ( tCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( TransportChannelConfig ) tCaptor . getValue ( ) . get ( 0 ) , is ( tConfig ) ) ; verify ( m_OSGiConfiguration , never ( ) ) . update ( Mockito . any ( Dictionary . class ) ) ; EventAdminVerifier . assertEventByTopicOnly ( m_EventAdmin , ConfigLoadingConstants . TOPIC_CONFIG_PROCESSING_COMPLETE_EVENT ) ; }
Verify that on framework started event with configuration property already set that correct firstRun flag is
 passed on.
Verify that on framework started event with configuration property already set that correct firstRun flag is passed on .