Search in sources :

Example 46 with MockRequestPathInfo

use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.

the class ProductPageWithSkuAndUrlKeyTest method testParse.

@Test
public void testParse() {
    MockRequestPathInfo pathInfo = new MockRequestPathInfo();
    pathInfo.setResourcePath("/page/path");
    pathInfo.setSuffix("/foo-bar/next-generation-foo-bar2021.html");
    ProductUrlFormat.Params parameters = subject.parse(pathInfo, null);
    assertEquals("/page/path", parameters.getPage());
    assertEquals("foo-bar", parameters.getSku());
    assertEquals("next-generation-foo-bar2021", parameters.getUrlKey());
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) ProductUrlFormat(com.adobe.cq.commerce.core.components.services.urls.ProductUrlFormat) Test(org.junit.Test)

Example 47 with MockRequestPathInfo

use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.

the class ProductPageWithSkuAndUrlPathTest method testParseWithNestedCategory.

@Test
public void testParseWithNestedCategory() {
    MockRequestPathInfo pathInfo = new MockRequestPathInfo();
    pathInfo.setResourcePath("/page/path");
    pathInfo.setSuffix("/foo-bar/top-level-category/sub-category/next-generation-foo-bar2021.html");
    ProductUrlFormat.Params parameters = subject.parse(pathInfo, null);
    assertEquals("/page/path", parameters.getPage());
    assertEquals("foo-bar", parameters.getSku());
    assertEquals("next-generation-foo-bar2021", parameters.getUrlKey());
    assertEquals("top-level-category/sub-category/next-generation-foo-bar2021", parameters.getUrlPath());
    assertEquals("top-level-category/sub-category", parameters.getCategoryUrlParams().getUrlPath());
    assertEquals("sub-category", parameters.getCategoryUrlParams().getUrlKey());
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) ProductUrlFormat(com.adobe.cq.commerce.core.components.services.urls.ProductUrlFormat) Test(org.junit.Test)

Example 48 with MockRequestPathInfo

use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.

the class ProductPageWithSkuAndUrlPathTest method testParseNoCategory.

@Test
public void testParseNoCategory() {
    MockRequestPathInfo pathInfo = new MockRequestPathInfo();
    pathInfo.setResourcePath("/page/path");
    pathInfo.setSuffix("/foo-bar/next-generation-foo-bar2021.html");
    ProductUrlFormat.Params parameters = subject.parse(pathInfo, null);
    assertEquals("/page/path", parameters.getPage());
    assertEquals("foo-bar", parameters.getSku());
    assertEquals("next-generation-foo-bar2021", parameters.getUrlKey());
    assertEquals("next-generation-foo-bar2021", parameters.getUrlPath());
    assertNull(parameters.getCategoryUrlParams().getUrlPath());
    assertNull(parameters.getCategoryUrlParams().getUrlKey());
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) ProductUrlFormat(com.adobe.cq.commerce.core.components.services.urls.ProductUrlFormat) Test(org.junit.Test)

Example 49 with MockRequestPathInfo

use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.

the class ProductPageWithSkuAndUrlPathTest method testParse.

@Test
public void testParse() {
    MockRequestPathInfo pathInfo = new MockRequestPathInfo();
    pathInfo.setResourcePath("/page/path");
    pathInfo.setSuffix("/foo-bar/top-level-category/next-generation-foo-bar2021.html");
    ProductUrlFormat.Params parameters = subject.parse(pathInfo, null);
    assertEquals("/page/path", parameters.getPage());
    assertEquals("foo-bar", parameters.getSku());
    assertEquals("next-generation-foo-bar2021", parameters.getUrlKey());
    assertEquals("top-level-category/next-generation-foo-bar2021", parameters.getUrlPath());
    assertEquals("top-level-category", parameters.getCategoryUrlParams().getUrlPath());
    assertEquals("top-level-category", parameters.getCategoryUrlParams().getUrlKey());
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) ProductUrlFormat(com.adobe.cq.commerce.core.components.services.urls.ProductUrlFormat) Test(org.junit.Test)

Example 50 with MockRequestPathInfo

use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.

the class ProductPageWithSkuCategoryAndUrlKeyTest method testParseNoSuffix.

@Test
public void testParseNoSuffix() {
    MockRequestPathInfo pathInfo = new MockRequestPathInfo();
    pathInfo.setResourcePath("/page/path");
    ProductUrlFormat.Params parameters = subject.parse(pathInfo, null);
    assertEquals("/page/path", parameters.getPage());
    assertNull(parameters.getSku());
    assertNull(parameters.getUrlKey());
    assertNull(parameters.getCategoryUrlParams().getUrlKey());
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) ProductUrlFormat(com.adobe.cq.commerce.core.components.services.urls.ProductUrlFormat) Test(org.junit.Test)

Aggregations

MockRequestPathInfo (org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo)93 MockSlingHttpServletRequest (org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest)61 Test (org.junit.Test)45 Test (org.junit.jupiter.api.Test)38 MockSlingHttpServletResponse (org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse)25 ProductUrlFormat (com.adobe.cq.commerce.core.components.services.urls.ProductUrlFormat)23 AbstractImageTest (com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest)16 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)10 ImmutableMap (com.google.common.collect.ImmutableMap)8 Map (java.util.Map)8 Resource (org.apache.sling.api.resource.Resource)8 SlingBindings (org.apache.sling.api.scripting.SlingBindings)8 CategoryUrlFormat (com.adobe.cq.commerce.core.components.services.urls.CategoryUrlFormat)4 PageImageThumbnail (com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail)4 Page (com.day.cq.wcm.api.Page)3 ValueMap (org.apache.sling.api.resource.ValueMap)3 CloudConfigurationList (com.adobe.acs.commons.cloudconfig.CloudConfigurationList)2 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 CloudConfiguration (com.adobe.acs.commons.cloudconfig.CloudConfiguration)1