use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project acs-aem-commons by Adobe-Consulting-Services.
the class CloudConfigurationListImplTest method valid.
@SuppressWarnings("unchecked")
@Test
public void valid() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo();
requestPathInfo.setSuffix("/apps/core/wcm/templates/marketocloudconfig");
CloudConfigurationList list = new CloudConfigurationListImpl(context.request());
assertNotNull(list);
Field field = list.getClass().getDeclaredField("configs");
field.setAccessible(true);
assertNotNull(field.get(list));
CloudConfiguration config = new CloudConfigurationImpl(context.resourceResolver().getResource("/conf/test"));
((List<CloudConfiguration>) field.get(list)).add(config);
assertNotNull(list.getCloudConfigurations());
assertEquals(1, list.getCloudConfigurations().size());
config = list.getCloudConfigurations().get(0);
assertNotNull(config);
assertEquals("/conf/test", config.getItemPath());
assertEquals("/", config.getConfigPath());
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project acs-aem-commons by Adobe-Consulting-Services.
the class GQLToQueryBuilderConverterTest method addPathFromSuffix.
@Test
public void addPathFromSuffix() {
Map<String, String> map = new HashMap<>();
MockSlingHttpServletRequest request = context.request();
MockRequestPathInfo pathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
pathInfo.setSuffix("/foo");
GQLToQueryBuilderConverter.addPath(request, map);
assertThat(map, hasEntry("path", "/foo"));
assertEquals(1, map.size());
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project acs-aem-commons by Adobe-Consulting-Services.
the class PathInfoUtilTest method testGetSelector.
/**
* Test of getSelector method, of class PathInfoUtil.
*/
@Test
public void testGetSelector() {
ResourceResolver resourceResolver = context.resourceResolver();
MockSlingHttpServletRequest request = context.request();
request.setResource(resourceResolver.getResource("/apple/macbookair"));
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setSelectorString("show.test");
requestPathInfo.setExtension("html");
request.setQueryString("cpu=i7&ghz=2.4");
String expResult = "show";
String result = PathInfoUtil.getSelector(request, 0);
assertEquals(expResult, result);
expResult = "test";
result = PathInfoUtil.getSelector(request, 1);
assertEquals(expResult, result);
result = PathInfoUtil.getSelector(request, -1);
assertNull(result);
result = PathInfoUtil.getSelector(request, 10);
assertNull(result);
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project acs-aem-commons by Adobe-Consulting-Services.
the class PathInfoUtilTest method testGetLastSuffixSegments.
@Test
public void testGetLastSuffixSegments() {
ResourceResolver resourceResolver = context.resourceResolver();
MockSlingHttpServletRequest request = context.request();
request.setResource(resourceResolver.getResource("/apple/macbookair"));
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setSelectorString("show.test");
requestPathInfo.setExtension("html");
requestPathInfo.setSuffix("first/second/third");
request.setQueryString("cpu=i7&ghz=2.4");
String expResult = "third";
String result = PathInfoUtil.getLastSuffixSegment(request);
assertEquals(expResult, result);
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project acs-aem-commons by Adobe-Consulting-Services.
the class PathInfoUtilTest method testGetSuffixSegments.
@Test
public void testGetSuffixSegments() {
ResourceResolver resourceResolver = context.resourceResolver();
MockSlingHttpServletRequest request = context.request();
request.setResource(resourceResolver.getResource("/apple/macbookair"));
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setSelectorString("show.test");
requestPathInfo.setExtension("html");
requestPathInfo.setSuffix("super/simple");
request.setQueryString("cpu=i7&ghz=2.4");
String[] expResult = new String[] { "super", "simple" };
String[] result = PathInfoUtil.getSuffixSegments(request);
assertArrayEquals(expResult, result);
}
Aggregations