@Test public void testGetStartDateTime_should_return_empty_if_none() { final KeyValue[] headers = { new KeyValue("No", "date") }; final Optional<Instant> startDateTime = cut.getStartDateTime(new Response().withHeader(headers)); assertThat(startDateTime).isEmpty(); }
Optional<Instant> getStartDateTime(Response response) { if (response == null) { return Optional.empty(); } return Arrays.stream(response.getHeader()) .filter(header -> "Date".equalsIgnoreCase(header.getKey())) .findFirst() .map(KeyValue::getValue) .map(value -> { try { return ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME).toInstant(); } catch (DateTimeParseException e) { log.error("Cannot parse date from response header in Newman report: {}", value, e); return null; } }); }
PostmanService { Optional<Instant> getStartDateTime(Response response) { if (response == null) { return Optional.empty(); } return Arrays.stream(response.getHeader()) .filter(header -> "Date".equalsIgnoreCase(header.getKey())) .findFirst() .map(KeyValue::getValue) .map(value -> { try { return ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME).toInstant(); } catch (DateTimeParseException e) { log.error("Cannot parse date from response header in Newman report: {}", value, e); return null; } }); } }
PostmanService { Optional<Instant> getStartDateTime(Response response) { if (response == null) { return Optional.empty(); } return Arrays.stream(response.getHeader()) .filter(header -> "Date".equalsIgnoreCase(header.getKey())) .findFirst() .map(KeyValue::getValue) .map(value -> { try { return ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME).toInstant(); } catch (DateTimeParseException e) { log.error("Cannot parse date from response header in Newman report: {}", value, e); return null; } }); }  }
PostmanService { Optional<Instant> getStartDateTime(Response response) { if (response == null) { return Optional.empty(); } return Arrays.stream(response.getHeader()) .filter(header -> "Date".equalsIgnoreCase(header.getKey())) .findFirst() .map(KeyValue::getValue) .map(value -> { try { return ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME).toInstant(); } catch (DateTimeParseException e) { log.error("Cannot parse date from response header in Newman report: {}", value, e); return null; } }); }  void parse(JsonParser parser, NewmanParsingResult result); List<ExecutedScenario> postProcess(Run run, NewmanParsingResult result, String newmanReportPath, AtomicInteger requestPosition); void deleteTempFiles(NewmanParsingResult newmanParsingResult); }
PostmanService { Optional<Instant> getStartDateTime(Response response) { if (response == null) { return Optional.empty(); } return Arrays.stream(response.getHeader()) .filter(header -> "Date".equalsIgnoreCase(header.getKey())) .findFirst() .map(KeyValue::getValue) .map(value -> { try { return ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME).toInstant(); } catch (DateTimeParseException e) { log.error("Cannot parse date from response header in Newman report: {}", value, e); return 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; }