@Test public void testGenerateResources() { List<String> testData = Arrays.asList("key1:value1", "key1:value2", "key2:value3", "key2:value4"); List<Resource> results = classUnderTest.generateResources(Mockito.mock(ResourceResolver.class), testData); Assert.assertEquals("The list has the correct number of elements", testData.size(), results.size()); testData.stream().forEach(testProperty -> { Resource resourceToCheck = results.get(testData.indexOf(testProperty)); ValueMap resourceProperties = resourceToCheck.getValueMap(); Assert.assertEquals("The value of property [text] is [" + testProperty + "]", testProperty, resourceProperties.get("text")); Assert.assertEquals("The value of property [value] is [" + testProperty + "]", testProperty, resourceProperties.get("value")); }); }
protected List<Resource> generateResources(ResourceResolver resolver, List<String> properties) { return properties.stream().map(property -> { Map<String, Object> resourceProperties = new HashMap<String, Object>() { { put("text", property); put("value", property); } }; ValueMapResource syntheticResource = new ValueMapResource(resolver, new ResourceMetadata(), "", new ValueMapDecorator( resourceProperties)); return syntheticResource; }).collect(Collectors.toList()); }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { protected List<Resource> generateResources(ResourceResolver resolver, List<String> properties) { return properties.stream().map(property -> { Map<String, Object> resourceProperties = new HashMap<String, Object>() { { put("text", property); put("value", property); } }; ValueMapResource syntheticResource = new ValueMapResource(resolver, new ResourceMetadata(), "", new ValueMapDecorator( resourceProperties)); return syntheticResource; }).collect(Collectors.toList()); } }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { protected List<Resource> generateResources(ResourceResolver resolver, List<String> properties) { return properties.stream().map(property -> { Map<String, Object> resourceProperties = new HashMap<String, Object>() { { put("text", property); put("value", property); } }; ValueMapResource syntheticResource = new ValueMapResource(resolver, new ResourceMetadata(), "", new ValueMapDecorator( resourceProperties)); return syntheticResource; }).collect(Collectors.toList()); }  }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { protected List<Resource> generateResources(ResourceResolver resolver, List<String> properties) { return properties.stream().map(property -> { Map<String, Object> resourceProperties = new HashMap<String, Object>() { { put("text", property); put("value", property); } }; ValueMapResource syntheticResource = new ValueMapResource(resolver, new ResourceMetadata(), "", new ValueMapDecorator( resourceProperties)); return syntheticResource; }).collect(Collectors.toList()); }   }
CatalogIdentifierDatasource extends SlingSafeMethodsServlet { protected List<Resource> generateResources(ResourceResolver resolver, List<String> properties) { return properties.stream().map(property -> { Map<String, Object> resourceProperties = new HashMap<String, Object>() { { put("text", property); put("value", property); } }; ValueMapResource syntheticResource = new ValueMapResource(resolver, new ResourceMetadata(), "", new ValueMapDecorator( resourceProperties)); return syntheticResource; }).collect(Collectors.toList()); }    }