### Question:
MetaInfRequireJson implements IRequireJsPackage { @Override public Map<String, String> getModules() { return Collections.unmodifiableMap( this.modules ); } 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 getModules() { MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, String> modules = requireJson.getModules(); assertEquals( TEST_FILE_BASE_NUMBER_OF_MODULES, modules.size() ); assertTrue( "Remove versioning from known modules", modules.containsKey( "angular" ) ); assertTrue( "Remove versioning from known modules", modules.containsKey( "angular-ui-router.stateHelper" ) ); assertTrue( "Remove versioning from known modules", modules.containsKey( "smart-table-min" ) ); assertTrue( "Remove versioning from known modules", modules.containsKey( "smart-table" ) ); assertTrue( "Leave as-is unknown modules", modules.containsKey( "other" ) ); assertTrue( "Leave as-is unknown modules", modules.containsKey( "simple" ) ); assertEquals( "Resolve known locations", "/some-folder", modules.get( "other" ) ); }
@Test public void testOverridesAddPath() { final Map<String, Object> meta = (Map<String, Object>) requireMeta.get( "requirejs-osgi-meta" ); Map<String, Object> overrides = new HashMap<>(); final HashMap<String, Object> paths = new HashMap<>(); overrides.put( "paths", paths ); paths.put( "newPath", "asdsa" ); meta.put( "overrides", overrides ); MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, String> modules = requireJson.getModules(); assertEquals( TEST_FILE_BASE_NUMBER_OF_MODULES + 1, modules.size() ); assertTrue( modules.containsKey( "newPath" ) ); }
@Test public void testOverridesRemovePath() { final Map<String, Object> meta = (Map<String, Object>) requireMeta.get( "requirejs-osgi-meta" ); Map<String, Object> overrides = new HashMap<>(); final HashMap<String, Object> paths = new HashMap<>(); overrides.put( "paths", paths ); paths.put( "smart-table", null ); meta.put( "overrides", overrides ); MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, String> modules = requireJson.getModules(); assertEquals( TEST_FILE_BASE_NUMBER_OF_MODULES - 1, modules.size() ); assertFalse( modules.containsKey( "smart-table" ) ); }
@Test public void testOverridesReplacesPath() { final Map<String, Object> meta = (Map<String, Object>) requireMeta.get( "requirejs-osgi-meta" ); Map<String, Object> overrides = new HashMap<>(); final HashMap<String, Object> paths = new HashMap<>(); overrides.put( "paths", paths ); paths.put( "angular", "/some/new/path" ); meta.put( "overrides", overrides ); MetaInfRequireJson requireJson = new MetaInfRequireJson( requireMeta ); final Map<String, String> modules = requireJson.getModules(); assertEquals( TEST_FILE_BASE_NUMBER_OF_MODULES, modules.size() ); assertEquals( "/some/new/path", modules.get( "angular" ) ); }