@Test
  public void testExecute() throws Exception {
    final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml"));
    final Template template = config.getTemplate("main");
    PJsonObject requestData = loadJsonRequestData();
    Values values =
        new Values(
            requestData,
            template,
            this.parser,
            getTaskDirectory(),
            this.httpRequestFactory,
            new File("."));

    this.forkJoinPool.invoke(template.getProcessorGraph().createTask(values));

    @SuppressWarnings("unchecked")
    List<URI> layerGraphics = (List<URI>) values.getObject("layerGraphics", List.class);
    assertEquals(1, layerGraphics.size());

    //        Files.copy(new File(layerGraphics.get(0)), new File(TMP,
    // getClass().getSimpleName()+".tiff"));
    new ImageSimilarity(new File(layerGraphics.get(0)), 2)
        .assertSimilarity(getFile(BASE_DIR + "expectedSimpleImage.tiff"), 0);
  }
  @Test
  public void testBasicTableProperties() throws Exception {
    final String baseDir = BASIC_BASE_DIR;

    final Configuration config = configurationFactory.getConfig(getFile(baseDir + "config.yaml"));
    final Template template = config.getTemplate("main");
    PJsonObject requestData = loadJsonRequestData(baseDir);
    Values values =
        new Values(
            requestData,
            template,
            parser,
            getTaskDirectory(),
            this.httpRequestFactory,
            new File("."));
    forkJoinPool.invoke(template.getProcessorGraph().createTask(values));

    final JRMapCollectionDataSource tableDataSource =
        values.getObject("table", JRMapCollectionDataSource.class);

    int count = 0;
    while (tableDataSource.next()) {
      count++;
    }

    assertEquals(2, count);
  }
  @Test
  public void testParsableByValues() throws Exception {
    final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml"));
    PJsonObject requestData = loadJsonRequestData();

    Template template = config.getTemplate("main");
    Values values =
        new Values(
            requestData,
            template,
            this.parser,
            config.getDirectory(),
            httpClientFactory,
            config.getDirectory());

    assertTrue(values.getBoolean("field1"));
    assertFalse(values.getBoolean("field2"));
    assertFalse(values.getBoolean("field3"));

    JSONObject field2Config =
        AbstractAttributeTest.getClientConfig(template.getAttributes().get("field2"), template);
    assertFalse(field2Config.has(ReflectiveAttribute.JSON_ATTRIBUTE_DEFAULT));

    JSONObject field3Config =
        AbstractAttributeTest.getClientConfig(template.getAttributes().get("field3"), template);
    assertTrue(field3Config.has(ReflectiveAttribute.JSON_ATTRIBUTE_DEFAULT));
    assertFalse(field3Config.getBoolean(ReflectiveAttribute.JSON_ATTRIBUTE_DEFAULT));
  }
  @Test
  public void testTableConvertersDynamic() throws Exception {
    final String baseDir = TABLE_CONVERTERS_DYNAMIC;
    final Configuration config = configurationFactory.getConfig(getFile(baseDir + "config.yaml"));
    PJsonObject requestData = loadJsonRequestData(baseDir);

    final AbstractJasperReportOutputFormat format =
        (AbstractJasperReportOutputFormat) this.outputFormat.get("pngOutputFormat");
    final File file = getFile(TableProcessorTest.class, baseDir);
    JasperPrint print = format.getJasperPrint(requestData, config, file, getTaskDirectory()).print;
    BufferedImage reportImage = ImageSimilarity.exportReportToImage(print, 0);
    //        ImageIO.write(reportImage, "png", new File("/tmp/expectedImage.png"));
    // note that we are using a sample size of 50, because the image is quite big.
    // otherwise small differences are not detected!
    new ImageSimilarity(reportImage, 50)
        .assertSimilarity(getFile(baseDir + "expectedImage.png"), 10);
  }
  @Test
  @DirtiesContext
  public void testTableConverters() throws Exception {
    httpRequestFactory.registerHandler(
        new Predicate<URI>() {
          @Override
          public boolean apply(@Nullable URI input) {
            return input.toString().contains("icons.com");
          }
        },
        new TestHttpClientFactory.Handler() {
          @Override
          public MockClientHttpRequest handleRequest(URI uri, HttpMethod httpMethod)
              throws Exception {
            final URL imageUrl = TableProcessorTest.class.getResource("/icons" + uri.getPath());
            final byte[] imageBytes = Resources.toByteArray(imageUrl);
            MockClientHttpRequest request = new MockClientHttpRequest();
            request.setResponse(new MockClientHttpResponse(imageBytes, HttpStatus.OK));
            return request;
          }
        });

    final String baseDir = TABLE_CONVERTERS;
    final Configuration config = configurationFactory.getConfig(getFile(baseDir + "config.yaml"));
    PJsonObject requestData = loadJsonRequestData(baseDir);

    final AbstractJasperReportOutputFormat format =
        (AbstractJasperReportOutputFormat) this.outputFormat.get("pngOutputFormat");
    final File file = getFile(TableProcessorTest.class, baseDir);
    JasperPrint print = format.getJasperPrint(requestData, config, file, getTaskDirectory()).print;
    BufferedImage reportImage = ImageSimilarity.exportReportToImage(print, 0);
    //        ImageIO.write(reportImage, "png", new File("/tmp/testColumnImageConverter.png"));
    // note that we are using a sample size of 50, because the image is quite big.
    // otherwise small differences are not detected!
    new ImageSimilarity(reportImage, 50)
        .assertSimilarity(getFile(baseDir + "expectedImage.png"), 10);
  }