@Test public void testDoGetWithNoAvailableService() throws ServletException, IOException { CatalogIdentifierDatasource datasourceToTest = new CatalogIdentifierDatasource(); datasourceToTest.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 no elements when the CatalogIdentifierService reference is not satisfied", 0, 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); }    }