@Test public void getOptions() { final Map<String, String> params = new HashMap<>(); params.put("foo", "foo value"); params.put("foo_bar", "foo_bar value"); params.put("foo-bar", "foo-bar value"); final Map<String, String> expected = new HashMap<>(); expected.put("Foo", "foo"); expected.put("Foo bar", "foo_bar"); expected.put("Foo-bar", "foo-bar"); final AssetRenditions assetRenditions = ctx.getService(AssetRenditions.class); final Map<String, String> actual = assetRenditions.getOptions(params); assertEquals(expected, actual); }
@Override public Map<String, String> getOptions(final Map<String, ? extends Object> mappings) { final Map<String, String> options = new LinkedHashMap<>(); mappings.keySet().stream() .sorted() .forEach(key -> { if (!options.containsValue(key)) { options.put( StringUtils.capitalize(StringUtils.replace(key, "_", " ")), key); } }); return options; }
AssetRenditionsImpl implements AssetRenditions { @Override public Map<String, String> getOptions(final Map<String, ? extends Object> mappings) { final Map<String, String> options = new LinkedHashMap<>(); mappings.keySet().stream() .sorted() .forEach(key -> { if (!options.containsValue(key)) { options.put( StringUtils.capitalize(StringUtils.replace(key, "_", " ")), key); } }); return options; } }
AssetRenditionsImpl implements AssetRenditions { @Override public Map<String, String> getOptions(final Map<String, ? extends Object> mappings) { final Map<String, String> options = new LinkedHashMap<>(); mappings.keySet().stream() .sorted() .forEach(key -> { if (!options.containsValue(key)) { options.put( StringUtils.capitalize(StringUtils.replace(key, "_", " ")), key); } }); return options; }  }
AssetRenditionsImpl implements AssetRenditions { @Override public Map<String, String> getOptions(final Map<String, ? extends Object> mappings) { final Map<String, String> options = new LinkedHashMap<>(); mappings.keySet().stream() .sorted() .forEach(key -> { if (!options.containsValue(key)) { options.put( StringUtils.capitalize(StringUtils.replace(key, "_", " ")), key); } }); return options; }  @Override String getUrl(final SlingHttpServletRequest request, final AssetModel asset, final AssetRenditionParameters parameters); @Override Map<String, String> getOptions(final Map<String, ? extends Object> mappings); @Override String evaluateExpression(final SlingHttpServletRequest request, String expression); }
AssetRenditionsImpl implements AssetRenditions { @Override public Map<String, String> getOptions(final Map<String, ? extends Object> mappings) { final Map<String, String> options = new LinkedHashMap<>(); mappings.keySet().stream() .sorted() .forEach(key -> { if (!options.containsValue(key)) { options.put( StringUtils.capitalize(StringUtils.replace(key, "_", " ")), key); } }); return options; }  @Override String getUrl(final SlingHttpServletRequest request, final AssetModel asset, final AssetRenditionParameters parameters); @Override Map<String, String> getOptions(final Map<String, ? extends Object> mappings); @Override String evaluateExpression(final SlingHttpServletRequest request, String expression);  }