Search in sources :

Example 1 with TextValueDataResourceSource

use of com.adobe.cq.wcm.core.components.internal.servlets.TextValueDataResourceSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class AllowedEmbeddablesDataSourceServletTest method validateAllowedEmbeddables.

private void validateAllowedEmbeddables(DataSource dataSource, TextValueDataResourceSource... textValueDataResourceSources) {
    Iterator<Resource> iterator = dataSource.iterator();
    int items = 0;
    while (iterator.hasNext()) {
        TextValueDataResourceSource textValueDataResourceSource = (TextValueDataResourceSource) iterator.next();
        assertEquals(textValueDataResourceSources[items].getValue(), textValueDataResourceSource.getValue());
        assertEquals(textValueDataResourceSources[items].getText(), textValueDataResourceSource.getText());
        items++;
    }
    assertEquals(textValueDataResourceSources.length, items);
}
Also used : TextValueDataResourceSource(com.adobe.cq.wcm.core.components.internal.servlets.TextValueDataResourceSource) Resource(org.apache.sling.api.resource.Resource)

Example 2 with TextValueDataResourceSource

use of com.adobe.cq.wcm.core.components.internal.servlets.TextValueDataResourceSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class AllowedEmbeddablesDataSourceServletTest method getExpectedAllowedEmbeddables.

private TextValueDataResourceSource[] getExpectedAllowedEmbeddables(String[][] expectedAllowedEmbeddables) {
    TextValueDataResourceSource[] textValueDataResourceSources = new TextValueDataResourceSource[expectedAllowedEmbeddables.length];
    for (int i = 0; i < expectedAllowedEmbeddables.length; i++) {
        final int index = i;
        textValueDataResourceSources[i] = new TextValueDataResourceSource(context.resourceResolver(), "", "") {

            @Override
            public String getText() {
                return expectedAllowedEmbeddables[index][0];
            }

            @Override
            public String getValue() {
                return expectedAllowedEmbeddables[index][1];
            }
        };
    }
    return textValueDataResourceSources;
}
Also used : TextValueDataResourceSource(com.adobe.cq.wcm.core.components.internal.servlets.TextValueDataResourceSource)

Aggregations

TextValueDataResourceSource (com.adobe.cq.wcm.core.components.internal.servlets.TextValueDataResourceSource)2 Resource (org.apache.sling.api.resource.Resource)1