@Test
public void testBasicRoundtrip() {

    resultWriter.addResult(new Result(ResultType.IMAGE, "image", 14, 32));
    resultWriter.addResult(new Result(ResultType.GRAPH, "graph.json"));
    assertThat(new File(OUTPUT_DIR).exists()).isTrue();
    assertThat(new File(OUTPUT_DIR).isDirectory()).isTrue();
    File resultFile = new File(OUTPUT_DIR, AnalysisResultWriter.QAV_RESULT_FILENAME);
    assertThat(resultFile.exists()).isTrue();
    // Read the result and check it:
    AnalysisResultReader reader = new AnalysisResultReader(resultFile.getAbsolutePath());
    AnalysisResult analysisResult = reader.getAnalysisResult();
    assertThat(analysisResult).isNotNull();
    assertThat(analysisResult.getItems()).hasSize(2);
    assertThat(analysisResult).isEqualTo(resultWriter.getAnalysisResult());
    assertThat(analysisResult.getAnalysisId()).startsWith("qav-");
    assertThat(analysisResult.getAnalysisId()).hasSize(40);
    assertThat(Duration.between(analysisResult.getAnalysisStart(), LocalDateTime.now()).getSeconds()).isLessThan(5);
}