use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ElementsDataSourceServletTest method testFragmentPathTextOnly.
@Test
void testFragmentPathTextOnly() throws ServletException, IOException {
DataSource dataSource = getDataSource(servlet, DS_FRAGMENT_PATH_TEXT_ONLY);
assertDataSource(dataSource, ELEMENT_NAMES, ELEMENT_TITLES);
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class AllowedEmbeddablesDataSourceServletTest method testAllowedEmbeddablesDataSourceServlet.
@Test
public void testAllowedEmbeddablesDataSourceServlet() {
context.contentPolicyMapping("my-app/components/embed", Objects.requireNonNull(context.resourceResolver().getResource("/apps/conf/policy_1558011912823")).getValueMap());
context.request().setAttribute(Value.CONTENTPATH_ATTRIBUTE, CURRENT_PATH);
dataSourceServlet.doGet(context.request(), context.response());
DataSource dataSource = (DataSource) context.request().getAttribute(DataSource.class.getName());
assertNotNull(dataSource);
validateAllowedEmbeddables(dataSource, getExpectedAllowedEmbeddables(new String[][] { { "Select", "" }, { "Chatbot", "/apps/my-app/chatbot" }, { "Social", "/apps/my-app/social" } }));
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class AllowedHeadingElementsDataSourceServletTest method testDataSource.
@Test
void testDataSource() throws Exception {
context.contentPolicyMapping("core/wcm/components/title/v1/title", "type", "h3", AllowedHeadingElementsDataSourceServlet.PN_ALLOWED_TYPES, new String[] { "h3", "h4" });
dataSourceServlet.doGet(context.request(), context.response());
DataSource dataSource = (DataSource) context.request().getAttribute(DataSource.class.getName());
assertNotNull(dataSource);
dataSource.iterator().forEachRemaining(resource -> {
assertTrue(TextValueDataResourceSource.class.isAssignableFrom(resource.getClass()), "Expected class");
TextValueDataResourceSource textValueDataResourceSource = (TextValueDataResourceSource) resource;
assertTrue(textValueDataResourceSource.getText().matches("h[3|4]"), "Expected type in (h3, h4)");
assertTrue(textValueDataResourceSource.getValue().matches("h[3|4]"), "Expected value in (h3, h4)");
if (textValueDataResourceSource.getValue().equals("h3")) {
assertTrue(textValueDataResourceSource.getSelected());
} else {
assertFalse(textValueDataResourceSource.getSelected());
}
});
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibraryCategoriesDataSourceServletTest method testDataSource.
@Test
public void testDataSource() throws Exception {
context.currentResource("/apps/clientlibrarycategoriesinput");
dataSourceServlet.doGet(context.request(), context.response());
DataSource dataSource = (DataSource) context.request().getAttribute(DataSource.class.getName());
assertNotNull(dataSource);
dataSource.iterator().forEachRemaining(resource -> {
assertTrue(TextValueDataResourceSource.class.isAssignableFrom(resource.getClass()), "Expected class");
TextValueDataResourceSource textValueDataResourceSource = (TextValueDataResourceSource) resource;
assertTrue(Arrays.asList(CLIENTLIB_A_CATEGORIES[0], CLIENTLIB_B_CATEGORIES[0], CLIENTLIB_C_CATEGORIES[0]).contains(textValueDataResourceSource.getText()), "Expected type in (clientlib.a.jsonly, clientlib.b.cssonly, clientlib.c.jsandcss)");
assertTrue(Arrays.asList(CLIENTLIB_A_CATEGORIES[0], CLIENTLIB_B_CATEGORIES[0], CLIENTLIB_C_CATEGORIES[0]).contains(textValueDataResourceSource.getValue()), "Expected value in (clientlib.a.jsonly, clientlib.b.cssonly, clientlib.c.jsandcss)");
});
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibraryCategoriesDataSourceServletTest method testDataSourceTypeCSS.
@Test
public void testDataSourceTypeCSS() throws Exception {
context.currentResource("/apps/clientlibrarycategoriesinputcss");
dataSourceServlet.doGet(context.request(), context.response());
DataSource dataSource = (DataSource) context.request().getAttribute(DataSource.class.getName());
assertNotNull(dataSource);
dataSource.iterator().forEachRemaining(resource -> {
assertTrue(TextValueDataResourceSource.class.isAssignableFrom(resource.getClass()), "Expected class");
TextValueDataResourceSource textValueDataResourceSource = (TextValueDataResourceSource) resource;
assertTrue(Arrays.asList(CLIENTLIB_B_CATEGORIES[0], CLIENTLIB_C_CATEGORIES[0]).contains(textValueDataResourceSource.getText()), "Expected type in (clientlib.b.cssonly, clientlib.c.jsandcss)");
assertTrue(Arrays.asList(CLIENTLIB_B_CATEGORIES[0], CLIENTLIB_C_CATEGORIES[0]).contains(textValueDataResourceSource.getValue()), "Expected value in (clientlib.b.cssonly, clientlib.c.jsandcss)");
});
}
Aggregations