@Test @PactVerification public void runTestBeer() { assertEquals(this.controller.gimmeABeer(new Person("marcin", 25)), "THERE YOU GO"); assertEquals(this.controller.gimmeABeer(new Person("marcin", 10)), "GET LOST"); }
@RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String gimmeABeer(@RequestBody Person person) { ResponseEntity<Response> response = this.restTemplate.exchange( RequestEntity .post(URI.create("http: .contentType(MediaType.APPLICATION_JSON_UTF8) .body(person), Response.class); switch (response.getBody().status) { case OK: return "THERE YOU GO"; default: return "GET LOST"; } }
BeerController { @RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String gimmeABeer(@RequestBody Person person) { ResponseEntity<Response> response = this.restTemplate.exchange( RequestEntity .post(URI.create("http: .contentType(MediaType.APPLICATION_JSON_UTF8) .body(person), Response.class); switch (response.getBody().status) { case OK: return "THERE YOU GO"; default: return "GET LOST"; } } }
BeerController { @RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String gimmeABeer(@RequestBody Person person) { ResponseEntity<Response> response = this.restTemplate.exchange( RequestEntity .post(URI.create("http: .contentType(MediaType.APPLICATION_JSON_UTF8) .body(person), Response.class); switch (response.getBody().status) { case OK: return "THERE YOU GO"; default: return "GET LOST"; } } BeerController(RestTemplate restTemplate); }
BeerController { @RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String gimmeABeer(@RequestBody Person person) { ResponseEntity<Response> response = this.restTemplate.exchange( RequestEntity .post(URI.create("http: .contentType(MediaType.APPLICATION_JSON_UTF8) .body(person), Response.class); switch (response.getBody().status) { case OK: return "THERE YOU GO"; default: return "GET LOST"; } } BeerController(RestTemplate restTemplate); @RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) String gimmeABeer(@RequestBody Person person); }
BeerController { @RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String gimmeABeer(@RequestBody Person person) { ResponseEntity<Response> response = this.restTemplate.exchange( RequestEntity .post(URI.create("http: .contentType(MediaType.APPLICATION_JSON_UTF8) .body(person), Response.class); switch (response.getBody().status) { case OK: return "THERE YOU GO"; default: return "GET LOST"; } } BeerController(RestTemplate restTemplate); @RequestMapping(method = RequestMethod.POST, value = "/beer", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) String gimmeABeer(@RequestBody Person person);  }