### Question:
NamedTransformImageServlet extends SlingSafeMethodsServlet implements OptingServlet { protected final double getQuality(final String mimeType, final ValueMap transforms) { final String key = "quality"; final int defaultQuality = 82; final int maxQuality = 100; final int minQuality = 0; final int maxQualityGif = 255; final double oneHundred = 100D; log.debug("Transforming with [ quality ]"); double quality = transforms.get(key, defaultQuality); if (quality > maxQuality || quality < minQuality) { quality = defaultQuality; } quality = quality / oneHundred; if (StringUtils.equals("image/gif", mimeType)) { quality = quality * maxQualityGif; } return quality; }  @Override final boolean accepts(final SlingHttpServletRequest request); static final String NAME_IMAGE; static final String NAMED_IMAGE_FILENAME_PATTERN; static final String DEFAULT_FILENAME_PATTERN; static final String RT_LOCAL_SOCIAL_IMAGE; static final String RT_REMOTE_SOCIAL_IMAGE; }### Answer:
@Test public void test_getQuality() { ValueMap qualityTransforms = new ValueMapDecorator(new HashMap<String, Object>()); qualityTransforms.put("quality", 0); assertEquals(0D, servlet.getQuality("image/jpg", qualityTransforms), 0); qualityTransforms.put("quality", 100); assertEquals(1D, servlet.getQuality("image/jpg", qualityTransforms), 0); qualityTransforms.put("quality", 50); assertEquals(0.5D, servlet.getQuality("image/jpg", qualityTransforms), 0); qualityTransforms.put("quality", 101); assertEquals(.82D, servlet.getQuality("image/jpg", qualityTransforms), 0); qualityTransforms.put("quality", -1); assertEquals(.82D, servlet.getQuality("image/jpg", qualityTransforms), 0); qualityTransforms.put("quality", 0); assertEquals(0D, servlet.getQuality("image/gif", qualityTransforms), 0); qualityTransforms.put("quality", 100); assertEquals(255D, servlet.getQuality("image/gif", qualityTransforms), 0); qualityTransforms.put("quality", 50); assertEquals(127.5D, servlet.getQuality("image/gif", qualityTransforms), 0); qualityTransforms.put("quality", 101); assertEquals(209.1D, servlet.getQuality("image/gif", qualityTransforms), 0); qualityTransforms.put("quality", -1); assertEquals(209.1D, servlet.getQuality("image/gif", qualityTransforms), 0); }