use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class TeaserImplTest method testTeaserWithActions.
@Test
@SuppressWarnings("deprecation")
@Override
protected void testTeaserWithActions() {
Teaser teaser = getTeaserUnderTest(TEASER_7);
assertTrue(teaser.isActionsEnabled(), "Expected teaser with actions");
assertEquals(2, teaser.getActions().size(), "Expected to find two actions");
ListItem action = teaser.getActions().get(0);
assertEquals("http://www.adobe.com", action.getPath(), "Action link does not match");
assertEquals("Adobe", action.getTitle(), "Action text does not match");
assertEquals("http://www.adobe.com", action.getURL());
assertValidLink(action.getLink(), "http://www.adobe.com");
Utils.testJSONExport(teaser, Utils.getTestExporterJSONPath(testBase, "teaser9"));
}
use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class CarouselImplTest method verifyCarouselItems.
private void verifyCarouselItems(Object[][] expectedItems, List<ListItem> items, String carouselId) {
assertEquals(expectedItems.length, items.size(), "The carousel contains a different number of items than expected.");
int index = 0;
for (ListItem item : items) {
assertEquals(expectedItems[index][0], item.getName(), "The carousel item's name is not what was expected.");
assertEquals(expectedItems[index][1], item.getTitle(), "The carousel item's title is not what was expected: " + item.getTitle());
assertEquals(expectedItems[index][3], item.getPath(), "The carousel item's path is not what was expected: " + item.getPath());
if (item.getData() != null) {
assertNotEquals(item.getData().getJson(), "{}", "The carousel item's data layer string is empty");
assertEquals(expectedItems[index][1], item.getData().getTitle(), "The carousel item's data layer title is not what was expected: " + item.getData().getTitle());
assertEquals(expectedItems[index][2], item.getData().getType(), "The carousel item's data layer type is not what was expected: " + item.getData().getType());
assertEquals(ComponentUtils.generateId(carouselId + "-item", (String) expectedItems[index][3]), item.getData().getId(), "The carousel item's data layer id is not what was expected: " + item.getData().getId());
}
index++;
}
}
use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class TabsImplTest method verifyTabItems.
private void verifyTabItems(Object[][] expectedItems, List<ListItem> items) {
assertEquals(expectedItems.length, items.size(), "The tabs contains a different number of items than expected.");
int index = 0;
for (ListItem item : items) {
assertEquals(expectedItems[index][0], item.getName(), "The tabs item's name is not what was expected.");
assertEquals(expectedItems[index][1], item.getTitle(), "The tabs item's title is not what was expected: " + item.getTitle());
index++;
}
}
use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class AccordionImplTest method verifyAccordionItems.
private void verifyAccordionItems(Object[][] expectedItems, List<ListItem> items) {
assertEquals(expectedItems.length, items.size(), "The accordion contains a different number of items than expected.");
int index = 0;
for (ListItem item : items) {
assertEquals(expectedItems[index][0], item.getName(), "The accordion item's name is not what was expected.");
assertEquals(expectedItems[index][1], item.getTitle(), "The accordion item's title is not what was expected: " + item.getTitle());
index++;
}
}
use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class SearchResultServlet method doGet.
@Override
protected void doGet(@NotNull final SlingHttpServletRequest request, @NotNull final SlingHttpServletResponse response) throws IOException {
Page currentPage = Optional.ofNullable(request.getResourceResolver().adaptTo(PageManager.class)).map(pm -> pm.getContainingPage(request.getResource())).orElse(null);
if (currentPage != null) {
SlingBindings bindings = new SlingBindings();
bindings.setSling(new ScriptHelper(bundleContext, null, request, response));
request.setAttribute(SlingBindings.class.getName(), bindings);
Search searchComponent = getSearchComponent(request, currentPage);
try {
List<ListItem> results = getResults(request, searchComponent, currentPage.getPageManager());
response.setContentType("application/json");
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
new ObjectMapper().writeValue(response.getWriter(), results);
} catch (NumberFormatException e) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
Aggregations