FrontendTokenDefinitionRegistryImpl implements FrontendTokenDefinitionRegistry { protected String getServletContextName(Bundle bundle) { Dictionary<String, String> headers = bundle.getHeaders( StringPool.BLANK); String webContextPath = headers.get("Web-ContextPath"); if (webContextPath == null) { return null; } if (webContextPath.startsWith(StringPool.SLASH)) { webContextPath = webContextPath.substring(1); } return webContextPath; }  @Override FrontendTokenDefinition getFrontendTokenDefinition(String themeId); @Override Collection<FrontendTokenDefinition> getFrontendTokenDefinitions();  }
@Test public void testGetServletContextName() { FrontendTokenDefinitionRegistryImpl frontendTokenDefinitionRegistryImpl = new FrontendTokenDefinitionRegistryImpl(); Bundle bundle = Mockito.mock(Bundle.class); Dictionary<String, String> headers = new HashMapDictionary<>(); headers.put("Web-ContextPath", "/my-theme"); Mockito.when( bundle.getHeaders(Mockito.anyString()) ).thenReturn( headers ); Assert.assertEquals( "my-theme", frontendTokenDefinitionRegistryImpl.getServletContextName(bundle)); }