### Question:
RelationTypesDataSourceServlet extends SlingSafeMethodsServlet { @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { ResourceBundle resourceBundle = request.getResourceBundle(null); List<Resource> values = new ArrayList<>(); for (RelationType relationType : RelationType.values()) { ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>()); vm.put("value", relationType); vm.put("text", toText(resourceBundle, relationType.getText())); values.add(new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), JcrConstants.NT_UNSTRUCTURED, vm)); } DataSource ds = new SimpleDataSource(values.iterator()); request.setAttribute(DataSource.class.getName(), ds); }    }### Answer:
@Test public void testDataSource() throws ServletException, IOException { servlet.doGet(context.request(), context.response()); DataSource dataSource = (DataSource) context.request().getAttribute(DataSource.class.getName()); Assert.assertNotNull(dataSource); AtomicInteger size = new AtomicInteger(0); dataSource.iterator().forEachRemaining(resource -> { ValueMapResource vmr = (ValueMapResource) resource; String value = vmr.getValueMap().get("value", String.class); String text = vmr.getValueMap().get("text", String.class); RelationType relationType = RelationType.valueOf(value); Assert.assertNotNull(relationType); Assert.assertEquals(relationType.toString(), value); Assert.assertEquals(relationType.getText(), text); size.incrementAndGet(); }); Assert.assertEquals(RelationType.values().length, size.get()); }