### Question:
RenditionPatternPicker implements RenditionPicker { @Override public final Rendition getRendition(final Asset asset) { final List<Rendition> renditions = asset.getRenditions(); final Pattern p = getPattern(); boolean hasOriginal = asset.getOriginal() != null; boolean hasRenditions = renditions.size() > 0; for (final Rendition rendition : renditions) { final Matcher m = p.matcher(rendition.getName()); if (m.find()) { return rendition; } } if (hasOriginal) { return asset.getOriginal(); } else if (hasRenditions) { return renditions.get(0); } else { return null; } } RenditionPatternPicker(String pattern);  RenditionPatternPicker(final Pattern pattern); @Override final Rendition getRendition(final Asset asset);  }### Answer:
@Test public void testGetRendition_MatchingRegex() { RenditionPatternPicker instance = new RenditionPatternPicker("^cust.*"); Rendition expResult = customRendition; Rendition result = instance.getRendition(asset); assertEquals(expResult, result); }
@Test public void testGetRendition_MultiMatchingRegex() { RenditionPatternPicker instance = new RenditionPatternPicker("^cq5dam\\.thumb*"); Rendition expResult = largeRendition; Rendition result = instance.getRendition(asset); assertEquals(expResult, result); }
@Test public void testGetRendition_NonMatchingRegex() { RenditionPatternPicker instance = new RenditionPatternPicker("nothinghere"); Rendition expResult = originalRendition; Rendition result = instance.getRendition(asset); assertEquals(expResult, result); }