@Test public void canProcessTheJsonPayloadFromTheProvider() throws UnirestException { String date = "2013-08-16T15:31:20+1000"; stubFor(get(urlPathEqualTo("/provider.json")) .withQueryParam("validDate", matching(".+")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("{\"test\": \"NO\", \"validDate\": \"" + date + "\", \"count\": 100}"))); List<Object> data = new Client("http: assertThat(data, hasSize(2)); assertThat(data.get(0), is(1)); assertThat(data.get(1), is(equalTo(OffsetDateTime.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXX"))))); }
public List<Object> fetchAndProcessData(String dateTime) throws UnirestException { Optional<JsonNode> data = loadProviderJson(dateTime); System.out.println("data=" + data); if (data != null && data.isPresent()) { JSONObject jsonObject = data.get().getObject(); int value = 100 / jsonObject.getInt("count"); TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXX") .parse(jsonObject.getString("validDate")); System.out.println("value=" + value); System.out.println("date=" + date); return Arrays.asList(value, OffsetDateTime.from(date)); } else { return Arrays.asList(0, null); } }
Client { public List<Object> fetchAndProcessData(String dateTime) throws UnirestException { Optional<JsonNode> data = loadProviderJson(dateTime); System.out.println("data=" + data); if (data != null && data.isPresent()) { JSONObject jsonObject = data.get().getObject(); int value = 100 / jsonObject.getInt("count"); TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXX") .parse(jsonObject.getString("validDate")); System.out.println("value=" + value); System.out.println("date=" + date); return Arrays.asList(value, OffsetDateTime.from(date)); } else { return Arrays.asList(0, null); } } }
Client { public List<Object> fetchAndProcessData(String dateTime) throws UnirestException { Optional<JsonNode> data = loadProviderJson(dateTime); System.out.println("data=" + data); if (data != null && data.isPresent()) { JSONObject jsonObject = data.get().getObject(); int value = 100 / jsonObject.getInt("count"); TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXX") .parse(jsonObject.getString("validDate")); System.out.println("value=" + value); System.out.println("date=" + date); return Arrays.asList(value, OffsetDateTime.from(date)); } else { return Arrays.asList(0, null); } } Client(String url); }
Client { public List<Object> fetchAndProcessData(String dateTime) throws UnirestException { Optional<JsonNode> data = loadProviderJson(dateTime); System.out.println("data=" + data); if (data != null && data.isPresent()) { JSONObject jsonObject = data.get().getObject(); int value = 100 / jsonObject.getInt("count"); TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXX") .parse(jsonObject.getString("validDate")); System.out.println("value=" + value); System.out.println("date=" + date); return Arrays.asList(value, OffsetDateTime.from(date)); } else { return Arrays.asList(0, null); } } Client(String url); List<Object> fetchAndProcessData(String dateTime); }
Client { public List<Object> fetchAndProcessData(String dateTime) throws UnirestException { Optional<JsonNode> data = loadProviderJson(dateTime); System.out.println("data=" + data); if (data != null && data.isPresent()) { JSONObject jsonObject = data.get().getObject(); int value = 100 / jsonObject.getInt("count"); TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXX") .parse(jsonObject.getString("validDate")); System.out.println("value=" + value); System.out.println("date=" + date); return Arrays.asList(value, OffsetDateTime.from(date)); } else { return Arrays.asList(0, null); } } Client(String url); List<Object> fetchAndProcessData(String dateTime);  }