ModuleNameUtil { public static String getPackagePath(String moduleName) { if (isLocalModuleName(moduleName)) { return null; } int i = moduleName.indexOf(StringPool.SLASH); if ((moduleName.charAt(0) == CharPool.AT) && (i != -1)) { i = moduleName.indexOf(StringPool.SLASH, i + 1); } if (i == -1) { return null; } return moduleName.substring(i + 1); }  static String getDependencyPath(
		String moduleName, String dependency); static String getModuleId(JSPackage jsPackage, String moduleName); static String getModuleResolvedId(
		JSPackage jsPackage, String moduleName); static String getPackageName(String moduleName); static String getPackagePath(String moduleName); static boolean isLocalModuleName(String moduleName); static boolean isReservedModuleName(String moduleName); static String toFileName(String moduleName); static String toModuleName(String fileName);  }
@Test public void testGetPackagePath() { Assert.assertNull(ModuleNameUtil.getPackagePath("a-package")); Assert.assertEquals( "a-module", ModuleNameUtil.getPackagePath("a-package/a-module")); Assert.assertEquals( "a-module.js", ModuleNameUtil.getPackagePath("a-package/a-module.js")); Assert.assertEquals( "a-folder/a-module", ModuleNameUtil.getPackagePath("a-package/a-folder/a-module")); Assert.assertEquals( "a-folder/a-module.js", ModuleNameUtil.getPackagePath("a-package/a-folder/a-module.js")); Assert.assertNull(ModuleNameUtil.getPackagePath("./a-module")); }
@Test public void testGetPackagePathNoModule() throws Exception { Assert.assertNull(ModuleNameUtil.getPackagePath("mypackage")); }
@Test public void testGetPackagePathScoped() throws Exception { String packagePath = ModuleNameUtil.getPackagePath( "@myscope/mypackage/lib/mymodule"); Assert.assertEquals("lib/mymodule", packagePath); }
@Test public void testGetPackagePathScopedNoModule() throws Exception { String packagePath = ModuleNameUtil.getPackagePath( "@myscope/mypackage"); Assert.assertNull(packagePath); }