use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method setUpMockDataSource.
private void setUpMockDataSource() {
Resource dataSourceResource = context.resourceResolver().getResource(CONTENT_ROOT + "/dataDatasource/datasource/items");
SimpleDataSource dataSource = new SimpleDataSource(dataSourceResource.listChildren());
context.request().setAttribute(DataSource.class.getName(), dataSource);
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class AllowedTitleSizesDataSourceServletTest method testDataSource.
@Test
public void testDataSource() throws Exception {
when(properties.get("allowedTypes", String[].class)).thenReturn(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("Expected class", TextValueDataResourceSource.class.isAssignableFrom(resource.getClass()));
TextValueDataResourceSource textValueDataResourceSource = (TextValueDataResourceSource) resource;
assertTrue("Expected type in (h3, h4)", textValueDataResourceSource.getText().matches("h[3|4]"));
assertTrue("Expected value in (h3, h4)", textValueDataResourceSource.getValue().matches("h[3|4]"));
});
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class AllowedTitleSizesDataSourceServletTest method testDataSourceWithInvalidValues.
@Test
public void testDataSourceWithInvalidValues() throws Exception {
when(properties.get("allowedTypes", String[].class)).thenReturn(new String[] { "foo", "h10" });
dataSourceServlet.doGet(context.request(), context.response());
DataSource dataSource = (DataSource) context.request().getAttribute(DataSource.class.getName());
assertNotNull(dataSource);
dataSource.iterator().forEachRemaining(resource -> {
assertTrue("Expected class", TextValueDataResourceSource.class.isAssignableFrom(resource.getClass()));
TextValueDataResourceSource textValueDataResourceSource = (TextValueDataResourceSource) resource;
assertNull("Expected null type", textValueDataResourceSource.getText());
assertTrue("Expected value in (foo, h10)", textValueDataResourceSource.getValue().matches("foo|h10"));
});
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class VariationsDataSourceServletTest method testComponentPathNonExisting.
@Test
void testComponentPathNonExisting() throws ServletException, IOException {
DataSource dataSource = getDataSource(servlet, DS_COMPONENT_PATH__NON_EXISTING);
assertDataSource(dataSource, new String[0], new String[0]);
}
use of com.adobe.granite.ui.components.ds.DataSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class VariationsDataSourceServletTest method testFragmentPathTextOnly.
@Test
void testFragmentPathTextOnly() throws ServletException, IOException {
DataSource dataSource = getDataSource(servlet, DS_FRAGMENT_PATH_TEXT_ONLY);
assertDataSource(dataSource, VARIATION_NAMES, VARIATION_TITLES);
}
Aggregations