SoyPortletHelper { public String getJavaScriptLoaderModule(String mvcCommandName) throws Exception { String loaderModule = _javaScriptLoaderModulesMap.get(mvcCommandName); if (loaderModule != null) { return loaderModule; } String controllerName = getJavaScriptControllerName(mvcCommandName); String packageName = getJavaScriptPackageName(mvcCommandName); if (packageName == null) { throw new Exception("Unable to get package name"); } if (!controllerName.startsWith(StringPool.SLASH)) { packageName = packageName.concat(StringPool.SLASH); } loaderModule = packageName.concat(controllerName); _javaScriptLoaderModulesMap.put(mvcCommandName, loaderModule); return loaderModule; } SoyPortletHelper(
			Bundle bundle, MVCCommandCache<?> mvcRenderCommandCache,
			FriendlyURLMapper friendlyURLMapper); String getJavaScriptLoaderModule(String mvcCommandName); String getRouterJavaScript(
			String elementId, String portletId, String portletNamespace,
			String portletWrapperId, Template template); String serializeTemplate(Template template);  }
@Test(expected = Exception.class) public void testGetJavaScriptControllerModuleWithoutPackageJSON() throws Exception { Bundle bundle = _mockBundleWithoutPackage(); MVCCommandCache<?> mvcCommandCache = _mockEmptyMVCCommandCache(); FriendlyURLMapper friendlyURLMapper = Mockito.mock( FriendlyURLMapper.class); SoyPortletHelper soyPortletHelper = new SoyPortletHelper( bundle, mvcCommandCache, friendlyURLMapper); soyPortletHelper.getJavaScriptLoaderModule("Path"); }
@Test public void testGetJavaScriptLoaderModule() throws Exception { Bundle bundle = _mockBundleWithPackageFile(); MVCCommandCache<?> mvcCommandCache = _mockEmptyMVCCommandCache(); FriendlyURLMapper friendlyURLMapper = Mockito.mock( FriendlyURLMapper.class); SoyPortletHelper soyPortletHelper = new SoyPortletHelper( bundle, mvcCommandCache, friendlyURLMapper); Assert.assertEquals( "package-with-version@1.0.0/JavaScriptCommand", soyPortletHelper.getJavaScriptLoaderModule("JavaScriptCommand")); }
@Test public void testGetJavaScriptLoaderModuleForES6() throws Exception { Bundle bundle = _mockBundleWithPackageFile(); MVCCommandCache<?> mvcCommandCache = _mockEmptyMVCCommandCache(); FriendlyURLMapper friendlyURLMapper = Mockito.mock( FriendlyURLMapper.class); SoyPortletHelper soyPortletHelper = new SoyPortletHelper( bundle, mvcCommandCache, friendlyURLMapper); Assert.assertEquals( "package-with-version@1.0.0/ES6Command.es", soyPortletHelper.getJavaScriptLoaderModule("ES6Command")); }
@Test public void testGetJavaScriptLoaderModuleForSoy() throws Exception { Bundle bundle = _mockBundleWithPackageFile(); MVCCommandCache<?> mvcCommandCache = _mockEmptyMVCCommandCache(); FriendlyURLMapper friendlyURLMapper = Mockito.mock( FriendlyURLMapper.class); SoyPortletHelper soyPortletHelper = new SoyPortletHelper( bundle, mvcCommandCache, friendlyURLMapper); Assert.assertEquals( "package-with-version@1.0.0/SoyCommand.soy", soyPortletHelper.getJavaScriptLoaderModule("SoyCommand")); }