@Test
public void forwardedAfterWithLogs() throws IOException {

    JsonSecurityAnalysisResultExporter exporter = new JsonSecurityAnalysisResultExporter();
    Set<String> expectedLogs = ImmutableSet.of("logs.zip",
            "security-analysis.out",
            "security-analysis.err");
    for (String logFileName : expectedLogs) {
        Files.write(workingDir.resolve(logFileName), "logs".getBytes(StandardCharsets.UTF_8));
    }
    SecurityAnalysisExecutionInput input = new SecurityAnalysisExecutionInput();
    ExecutionHandler<SecurityAnalysisResultWithLog> handler2 = SecurityAnalysisExecutionHandlers.forwardedWithLogs(input, 2);
    assertThatExceptionOfType(ComputationException.class)
            .isThrownBy(() -> handler2.after(workingDir, new DefaultExecutionReport()))
            .withStackTraceContaining("NoSuchFile")
            .withStackTraceContaining("result.json")
            .satisfies(ce -> {
                assertEquals("logs", ce.getErrLogs().get("security-analysis.err"));
                assertEquals("logs", ce.getOutLogs().get("security-analysis.out"));
            });
    ExecutionHandler<SecurityAnalysisResultWithLog> handler = SecurityAnalysisExecutionHandlers.forwardedWithLogs(input, 2);
    try (Writer writer = Files.newBufferedWriter(workingDir.resolve("result.json"))) {
        exporter.export(resultForContingency("c1"), writer);
    }
    SecurityAnalysisResultWithLog resultWithLog = handler.after(workingDir, new DefaultExecutionReport());
    SecurityAnalysisResult result = resultWithLog.getResult();
    assertNotNull(result);
    assertTrue(result.getPreContingencyResult().isComputationOk());
    assertTrue(result.getPreContingencyResult().getLimitViolations().isEmpty());
    assertEquals(1, result.getPostContingencyResults().size());
    assertEquals("c1", result.getPostContingencyResults().get(0).getContingency().getId());
    assertTrue(resultWithLog.getLogBytes().isPresent());
    byte[] logBytes = resultWithLog.getLogBytes()
            .orElseThrow(AssertionError::new);
    Set<String> foundNames = getFileNamesFromZip(logBytes);
    assertEquals(expectedLogs, foundNames);
}