EmbeddablesDataSourceServlet extends SlingSafeMethodsServlet { @Override protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) { SimpleDataSource embeddablesDataSource = new SimpleDataSource(getEmbeddableResources( request.getResourceResolver()).iterator()); request.setAttribute(DataSource.class.getName(), embeddablesDataSource); }   static final String RESOURCE_TYPE_V1; }
@Test public void testEmbeddablesDataSourceServlet() { context.currentResource("/apps/embeddablesdatasource"); EmbeddablesDataSourceServlet dataSourceServlet = new EmbeddablesDataSourceServlet(); dataSourceServlet.doGet(request, context.response()); DataSource dataSource = (com.adobe.granite.ui.components.ds.DataSource) request.getAttribute(DataSource.class .getName()); assertNotNull(dataSource); Resource resource = dataSource.iterator().next(); ValueMap valueMap = resource.getValueMap(); assertEquals("YouTube", valueMap.get(TextValueDataResourceSource.PN_TEXT, String.class)); assertEquals("my-app/youtube", valueMap.get(TextValueDataResourceSource.PN_VALUE, String.class)); EmbeddableDescription embed1 = new EmbeddableDescription(null, embeddableResources.get(1).getName(), embeddableResources.get(1).getValueMap()); EmbeddableDescription embed2 = new EmbeddableDescription(null, embeddableResources.get(0).getName(), embeddableResources.get(0).getValueMap()); assertNotEquals(embed2, embed1); assertNotNull(embed1.hashCode()); }