@Override
 public Set<Format> getAvailableOutputFormats() {
   final Set<Format> outputFormats = new HashSet<>();
   if (format == Format.JP2) {
     outputFormats.addAll(ImageWriter.supportedFormats());
   }
   return outputFormats;
 }
  @Test
  public void testAvailableOutputFormats() throws Exception {
    final HashMap<Format, Set<Format>> formats = new HashMap<>();
    for (Format format : ImageReader.supportedFormats()) {
      formats.put(format, ImageWriter.supportedFormats());
    }

    instance.setSourceFormat(Format.JPG);
    Set<Format> expectedFormats = formats.get(Format.JPG);
    assertEquals(expectedFormats, instance.getAvailableOutputFormats());
  }