@Test public void testGetStartDateTime_should_return_the_parsed_date_for_utc() { final KeyValue[] headers = { new KeyValue("Some", "value"), new KeyValue("Date", "Wed, 21 Oct 2015 07:28:01 GMT"), new KeyValue("Other", "value") }; Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expected.set(2015, Calendar.OCTOBER, 21, 7, 28, 1); expected.set(Calendar.MILLISECOND, 0); final Optional<Instant> startDateTime = cut.getStartDateTime(new Response().withHeader(headers)); assertThat(startDateTime.orElse(null)).isEqualTo(expected.toInstant()); }
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; }