List of usage examples for com.liferay.portal.kernel.exception LayoutFriendlyURLException getKeywordConflict
public String getKeywordConflict()
From source file:com.liferay.layout.test.LayoutFriendlyURLTest.java
License:Open Source License
@Test public void testInvalidFriendlyURLMapperURLInDefaultLocale() throws Exception { Map<Locale, String> friendlyURLMap = new HashMap<>(); friendlyURLMap.put(LocaleUtil.US, "/tags"); try {//from w ww .ja va2 s .co m addLayout(_group.getGroupId(), false, friendlyURLMap); Assert.fail(); } catch (LayoutFriendlyURLsException lfurle) { Map<Locale, Exception> localizedExceptionsMap = lfurle.getLocalizedExceptionsMap(); List<Exception> layoutFriendlyURLExceptions = ListUtil.fromCollection(localizedExceptionsMap.values()); Assert.assertEquals(layoutFriendlyURLExceptions.toString(), 1, layoutFriendlyURLExceptions.size()); LayoutFriendlyURLException layoutFriendlyURLException = (LayoutFriendlyURLException) layoutFriendlyURLExceptions .get(0); Assert.assertEquals("tags", layoutFriendlyURLException.getKeywordConflict()); } friendlyURLMap = new HashMap<>(); friendlyURLMap.put(LocaleUtil.US, "/home/tags"); try { addLayout(_group.getGroupId(), false, friendlyURLMap); Assert.fail(); } catch (LayoutFriendlyURLsException lfurle) { Map<Locale, Exception> localizedExceptionsMap = lfurle.getLocalizedExceptionsMap(); List<Exception> layoutFriendlyURLExceptions = ListUtil.fromCollection(localizedExceptionsMap.values()); Assert.assertEquals(layoutFriendlyURLExceptions.toString(), 1, layoutFriendlyURLExceptions.size()); LayoutFriendlyURLException layoutFriendlyURLException = (LayoutFriendlyURLException) layoutFriendlyURLExceptions .get(0); Assert.assertEquals("tags", layoutFriendlyURLException.getKeywordConflict()); } friendlyURLMap = new HashMap<>(); friendlyURLMap.put(LocaleUtil.US, "/tags/home"); try { addLayout(_group.getGroupId(), false, friendlyURLMap); Assert.fail(); } catch (LayoutFriendlyURLsException lfurle) { Map<Locale, Exception> localizedExceptionsMap = lfurle.getLocalizedExceptionsMap(); List<Exception> layoutFriendlyURLExceptions = ListUtil.fromCollection(localizedExceptionsMap.values()); Assert.assertEquals(layoutFriendlyURLExceptions.toString(), 1, layoutFriendlyURLExceptions.size()); LayoutFriendlyURLException layoutFriendlyURLException = (LayoutFriendlyURLException) layoutFriendlyURLExceptions .get(0); Assert.assertEquals("tags", layoutFriendlyURLException.getKeywordConflict()); } friendlyURLMap = new HashMap<>(); friendlyURLMap.put(LocaleUtil.US, "/blogs/-/home"); try { addLayout(_group.getGroupId(), false, friendlyURLMap); Assert.fail(); } catch (LayoutFriendlyURLsException lfurle) { Map<Locale, Exception> localizedExceptionsMap = lfurle.getLocalizedExceptionsMap(); List<Exception> layoutFriendlyURLExceptions = ListUtil.fromCollection(localizedExceptionsMap.values()); Assert.assertEquals(layoutFriendlyURLExceptions.toString(), 1, layoutFriendlyURLExceptions.size()); LayoutFriendlyURLException layoutFriendlyURLException = (LayoutFriendlyURLException) layoutFriendlyURLExceptions .get(0); Assert.assertEquals("/-/", layoutFriendlyURLException.getKeywordConflict()); } }