Example usage for com.liferay.portal.kernel.exception LayoutFriendlyURLException getKeywordConflict

List of usage examples for com.liferay.portal.kernel.exception LayoutFriendlyURLException getKeywordConflict

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.exception LayoutFriendlyURLException getKeywordConflict.

Prototype

public String getKeywordConflict() 

Source Link

Usage

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());
    }
}