### Question:
MetaInfRequireJson implements IRequireJsPackage { @Override public Map<String, Map<String, ?>> getConfig() { return Collections.unmodifiableMap( this.config ); } MetaInfRequireJson( Map<String, Object> requireJsonObject ); @Override String getName(); @Override String getVersion(); @Override String getWebRootPath(); @Override boolean preferGlobal(); @Override Map<String, String> getModules(); @Override String getModuleMainFile( String moduleId ); @Override Map<String, String> getDependencies(); @Override boolean hasScript( String name ); URL getScriptResource( String name ); @Override Map<String, Map<String, ?>> getConfig(); @Override Map<String, Map<String, String>> getMap(); @Override Map<String, Map<String, ?>> getShim(); boolean isAmdPackage(); String getExports();  }### Answer:
@Test public void getConfig() { MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, ?> config = requireJson.getConfig(); assertEquals( TEST_FILE_BASE_NUMBER_OF_CONFIGS, config.size() ); assertTrue( "Remove versioning from known modules", config.containsKey( "smart-table" ) ); assertTrue( "Leave as-is unknown modules", config.containsKey( "something-unknown@2.0.1" ) ); }
@Test public void testOverridesAddConfig() { final Map<String, Object> meta = (Map<String, Object>) requireMeta.get( "requirejs-osgi-meta" ); Map<String, Object> overrides = new HashMap<>(); final HashMap<String, Object> configOverrides = new HashMap<>(); overrides.put( "config", configOverrides ); configOverrides.put( "newConfig", new HashMap<>() ); meta.put( "overrides", overrides ); MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, Map<String, ?>> config = requireJson.getConfig(); assertEquals( TEST_FILE_BASE_NUMBER_OF_CONFIGS + 1, config.size() ); assertTrue( config.containsKey( "newConfig" ) ); }
@Test public void testOverridesRemoveConfig() { final Map<String, Object> meta = (Map<String, Object>) requireMeta.get( "requirejs-osgi-meta" ); Map<String, Object> overrides = new HashMap<>(); final HashMap<String, Object> configOverrides = new HashMap<>(); overrides.put( "config", configOverrides ); configOverrides.put( "smart-table", null ); meta.put( "overrides", overrides ); MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, Map<String, ?>> config = requireJson.getConfig(); assertEquals( TEST_FILE_BASE_NUMBER_OF_CONFIGS - 1, config.size() ); assertFalse( config.containsKey( "smart-table" ) ); }
@Test public void testOverridesReplacesConfig() { final Map<String, Object> meta = (Map<String, Object>) requireMeta.get( "requirejs-osgi-meta" ); Map<String, Object> overrides = new HashMap<>(); final HashMap<String, Object> configOverrides = new HashMap<>(); overrides.put( "config", configOverrides ); final HashMap<Object, Object> newConfig = new HashMap<>(); newConfig.put( "prop", "value" ); configOverrides.put( "smart-table", newConfig ); meta.put( "overrides", overrides ); MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, Map<String, ?>> config = requireJson.getConfig(); assertEquals( TEST_FILE_BASE_NUMBER_OF_CONFIGS, config.size() ); assertTrue( config.containsKey( "smart-table" ) ); assertTrue( config.get( "smart-table" ).containsKey( "prop" ) ); assertEquals( "value", config.get( "smart-table" ).get( "prop" ) ); }