mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestOSGiConfigLoaderImpl.java
@Test
    @SuppressWarnings({"unchecked", "rawtypes"})
    public void testProcessNoMetaTypeData() throws IOException
    {
        final List<StringMapEntry> configProps = new ArrayList<StringMapEntry>();
        configProps.add(new StringMapEntry("someInt", "32"));
        configProps.add(new StringMapEntry("someString", "value"));
        configProps.add(new StringMapEntry("someShort", "16"));

        final PidConfig configMissing = new PidConfig(null, "some.nonexistent.config", configProps);

        final List<PidConfig> configs = createConfigList();

        configs.add(configMissing);
        
        m_SUT.process(configs, true);
        
        // Verify configs that were processed immediately
        final ArgumentCaptor<Dictionary> propsCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_ConfigOverride).update(propsCaptor.capture());
        verify(m_ConfigNoOverride).update(propsCaptor.capture());
        verify(m_FactoryConfig).update(propsCaptor.capture());
        
        assertThat(propsCaptor.getAllValues().size(), is(3));
        
        Dictionary<String, Object> propList = propsCaptor.getAllValues().get(0);
        assertThat(propList.get("someInt"), is((Object)10));
        assertThat(propList.get("someString"), is((Object)"value"));
        assertThat(propList.get("someShort"), is((Object)(short)89));
        
        propList = propsCaptor.getAllValues().get(1);
        assertThat(propList.get("someFloat"), is((Object)12.5F));
        assertThat(propList.get("someByte"), is((Object)(byte)127));
        assertThat(propList.get("someChar"), is((Object)'A'));
        
        propList = propsCaptor.getAllValues().get(2);
        assertThat(propList.get("someDouble"), is((Object)15.55));
        assertThat(propList.get("someBool"), is((Object)true));
        assertThat(propList.get("someLong"), is((Object)1234567890L));
        
        // Post metatype available event and verify the missing config
        List<String> pidList = new ArrayList<>();
        pidList.add("some.nonexistent.config");
        Map<String, Object> props = new HashMap<>();
        props.put("service.pids", pidList);
        Event metaTypeAvailEvent = new Event(RemoteMetatypeConstants.TOPIC_METATYPE_INFORMATION_AVAILABLE, props);
        m_EventAdmin.postEvent(metaTypeAvailEvent);
    }
/**
     * Verify a configuration with missing metatype data is processed later after receiving the metatype available
     * event.
     */
Verify a configuration with missing metatype data is processed later after receiving the metatype available
event.
Verify a configuration with missing metatype data is processed later after receiving the metatype available event .
@Test
    @SuppressWarnings({"unchecked", "rawtypes"})
    public void testProcessNoMetaTypeData() throws IOException
    {
        final List<StringMapEntry> configProps = new ArrayList<StringMapEntry>();
        configProps.add(new StringMapEntry("someInt", "32"));
        configProps.add(new StringMapEntry("someString", "value"));
        configProps.add(new StringMapEntry("someShort", "16"));
        final PidConfig configMissing = new PidConfig(null, "some.nonexistent.config", configProps);
        final List<PidConfig> configs = createConfigList();
        configs.add(configMissing);
        m_SUT.process(configs, true);
        final ArgumentCaptor<Dictionary> propsCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_ConfigOverride).update(propsCaptor.capture());
        verify(m_ConfigNoOverride).update(propsCaptor.capture());
        verify(m_FactoryConfig).update(propsCaptor.capture());
        assertThat(propsCaptor.getAllValues().size(), is(3));
        Dictionary<String, Object> propList = propsCaptor.getAllValues().get(0);
        assertThat(propList.get("someInt"), is((Object)10));
        assertThat(propList.get("someString"), is((Object)"value"));
        assertThat(propList.get("someShort"), is((Object)(short)89));
        propList = propsCaptor.getAllValues().get(1);
        assertThat(propList.get("someFloat"), is((Object)12.5F));
        assertThat(propList.get("someByte"), is((Object)(byte)127));
        assertThat(propList.get("someChar"), is((Object)'A'));
        propList = propsCaptor.getAllValues().get(2);
        assertThat(propList.get("someDouble"), is((Object)15.55));
        assertThat(propList.get("someBool"), is((Object)true));
        assertThat(propList.get("someLong"), is((Object)1234567890L));
        List<String> pidList = new ArrayList<>();
        pidList.add("some.nonexistent.config");
        Map<String, Object> props = new HashMap<>();
        props.put("service.pids", pidList);
        Event metaTypeAvailEvent = new Event(RemoteMetatypeConstants.TOPIC_METATYPE_INFORMATION_AVAILABLE, props);
        m_EventAdmin.postEvent(metaTypeAvailEvent);
    }
@ Test @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public void testProcessNoMetaTypeData ( ) throws IOException { final List < StringMapEntry > configProps = new ArrayList < StringMapEntry > ( ) ; configProps . add ( new StringMapEntry ( "someInt" , "32" ) ) ; configProps . add ( new StringMapEntry ( "someString" , "value" ) ) ; configProps . add ( new StringMapEntry ( "someShort" , "16" ) ) ; final PidConfig configMissing = new PidConfig ( null , "some.nonexistent.config" , configProps ) ; final List < PidConfig > configs = createConfigList ( ) ; configs . add ( configMissing ) ; m_SUT . process ( configs , true ) ; final ArgumentCaptor < Dictionary > propsCaptor = ArgumentCaptor . forClass ( Dictionary . class ) ; verify ( m_ConfigOverride ) . update ( propsCaptor . capture ( ) ) ; verify ( m_ConfigNoOverride ) . update ( propsCaptor . capture ( ) ) ; verify ( m_FactoryConfig ) . update ( propsCaptor . capture ( ) ) ; assertThat ( propsCaptor . getAllValues ( ) . size ( ) , is ( 3 ) ) ; Dictionary < String , Object > propList = propsCaptor . getAllValues ( ) . get ( 0 ) ; assertThat ( propList . get ( "someInt" ) , is ( ( Object ) 10 ) ) ; assertThat ( propList . get ( "someString" ) , is ( ( Object ) "value" ) ) ; assertThat ( propList . get ( "someShort" ) , is ( ( Object ) ( short ) 89 ) ) ; propList = propsCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( propList . get ( "someFloat" ) , is ( ( Object ) 12.5F ) ) ; assertThat ( propList . get ( "someByte" ) , is ( ( Object ) ( byte ) 127 ) ) ; assertThat ( propList . get ( "someChar" ) , is ( ( Object ) 'A' ) ) ; propList = propsCaptor . getAllValues ( ) . get ( 2 ) ; assertThat ( propList . get ( "someDouble" ) , is ( ( Object ) 15.55 ) ) ; assertThat ( propList . get ( "someBool" ) , is ( ( Object ) true ) ) ; assertThat ( propList . get ( "someLong" ) , is ( ( Object ) 1234567890L ) ) ; List < String > pidList = new ArrayList < > ( ) ; pidList . add ( "some.nonexistent.config" ) ; Map < String , Object > props = new HashMap < > ( ) ; props . put ( "service.pids" , pidList ) ; Event metaTypeAvailEvent = new Event ( RemoteMetatypeConstants . TOPIC_METATYPE_INFORMATION_AVAILABLE , props ) ; m_EventAdmin . postEvent ( metaTypeAvailEvent ) ; }
Verify a configuration with missing metatype data is processed later after receiving the metatype available
 event.
Verify a configuration with missing metatype data is processed later after receiving the metatype available event .
// Verify configs that were processed immediately // Post metatype available event and verify the missing config