@Test public void testDoGetWithData() throws ServletException, IOException { List<String> testResourceProperties = Arrays.asList("key1:value1", "key1:value2", "key2:value3", "key2:value4"); classUnderTest.doGet(mockRequest, mockResponse); DataSource result = (DataSource) mockRequest.getAttribute(DataSource.class.getName()); List<Resource> elementsInDatsource = new ArrayList<>(); result.iterator().forEachRemaining(resourceToCheck -> { elementsInDatsource.add(resourceToCheck); }); Assert.assertEquals("The datasource contains the correct number of elements", testResourceProperties.size(), elementsInDatsource .size()); }
@Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { DataSource ds; if (catalogIdentifierService == null) { ds = EmptyDataSource.instance(); } else { ds = buildValuesList(request.getResourceResolver()); } request.setAttribute(DataSource.class.getName(), ds); }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { @Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { DataSource ds; if (catalogIdentifierService == null) { ds = EmptyDataSource.instance(); } else { ds = buildValuesList(request.getResourceResolver()); } request.setAttribute(DataSource.class.getName(), ds); } }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { @Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { DataSource ds; if (catalogIdentifierService == null) { ds = EmptyDataSource.instance(); } else { ds = buildValuesList(request.getResourceResolver()); } request.setAttribute(DataSource.class.getName(), ds); }  }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { @Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { DataSource ds; if (catalogIdentifierService == null) { ds = EmptyDataSource.instance(); } else { ds = buildValuesList(request.getResourceResolver()); } request.setAttribute(DataSource.class.getName(), ds); }   }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { @Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { DataSource ds; if (catalogIdentifierService == null) { ds = EmptyDataSource.instance(); } else { ds = buildValuesList(request.getResourceResolver()); } request.setAttribute(DataSource.class.getName(), ds); }    }