drink beer curl -H "Content-Type: application/json" -X POST \ -d ‘{ “age”: 20 }' \ http://some.external.api:8090/check ~ provided by the producer at some point of time REAL LIFE EXAMPLE This snippet was taken from JIRA or some random Slack channel
restTemplate.exchange( RequestEntity .put(URI.create("http://localhost:8080/chekc")) .contentType(MediaType.APPLICATION_JSON_UTF8) .body(new RequestPayload(10)), ResponsePayload.class); assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.OK); } TESTING on the consumer side
restTemplate.exchange( RequestEntity .put(URI.create("http://localhost:8091/items/validate")) .contentType(MediaType.APPLICATION_JSON_UTF8) .body(new RequestPayload(10)), ResponsePayload.class); assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.OK); } check_withValidAge_shouldReturnHttpStatusOk OK TESTING on the consumer side
restTemplate.exchange( RequestEntity .put(URI.create("http://localhost:8080/chekc")) .contentType(MediaType.APPLICATION_JSON_UTF8) .body(new RequestPayload(10)), ResponsePayload.class); assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.OK); } TESTING on the consumer side
restTemplate.exchange( RequestEntity .put(URI.create("http://localhost:8080/chekc")) .contentType(MediaType.APPLICATION_JSON_UTF8) .body(new RequestPayload(10)), ResponsePayload.class); assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.OK); } TESTING on the consumer side
restTemplate.exchange( RequestEntity .put(URI.create("http://localhost:8080/chekc")) .contentType(MediaType.APPLICATION_JSON_UTF8) .body(new RequestPayload(10)), ResponsePayload.class); assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.OK); } TESTING on the consumer side
restTemplate.exchange( RequestEntity .put(URI.create("http://localhost:8080/chekc")) .contentType(MediaType.APPLICATION_JSON_UTF8) .body(new RequestPayload(10)), ResponsePayload.class); assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.OK); } TESTING on the consumer side