### Question:
PostmanService { void saveExecutionStreamToFile(Execution execution) throws IOException { if (execution.getResponse() == null || execution.getResponse().getStream() == null || execution.getResponse().getStream().getData() == null) { return; } final Stream stream = execution.getResponse().getStream(); File file = File.createTempFile("ara_execution_response_stream_", ".bin"); file.deleteOnExit(); FileUtils.writeByteArrayToFile(file, stream.getData()); stream.setTempFile(file); stream.setData(null); }  void parse(JsonParser parser, NewmanParsingResult result); List<ExecutedScenario> postProcess(Run run, NewmanParsingResult result, String newmanReportPath, AtomicInteger requestPosition); void deleteTempFiles(NewmanParsingResult newmanParsingResult); static final String FOLDER_DELIMITER; }### Answer:
@Test public void saveExecutionStreamToFile_should_not_crash_if_execution_has_null_response() throws IOException { Execution execution = new Execution(); cut.saveExecutionStreamToFile(execution); }
@Test public void saveExecutionStreamToFile_should_not_crash_if_response_has_null_stream() throws IOException { Execution execution = new Execution() .withResponse(new Response()); cut.saveExecutionStreamToFile(execution); }
@Test public void saveExecutionStreamToFile_should_not_crash_if_stream_has_null_data() throws IOException { Execution execution = new Execution() .withResponse(new Response() .withStream(new Stream())); cut.saveExecutionStreamToFile(execution); }
@Test public void saveExecutionStreamToFile_should_save_execution_stream_to_file() throws IOException { final Stream stream = new Stream() .withData(new byte[] { 'a', 'b', 'c' }); Execution execution = new Execution() .withResponse(new Response() .withStream(stream)); try { cut.saveExecutionStreamToFile(execution); assertThat(stream.getData()).isNull(); assertThat(stream.getTempFile()).isNotNull(); assertThat(FileUtils.readFileToString(stream.getTempFile(), StandardCharsets.UTF_8)).isEqualTo("abc"); } finally { FileUtils.deleteQuietly(stream.getTempFile()); } }