@Test public void pingReturnsFailure_whenSecondTraceFails() throws Exception { doReturn(ResponseEntity.badRequest().body("invalid content")).when(restTemplate).getForEntity("http: PaymentResponse response = this.subject.chargeChard(); PaymentResponse expectedResponse = new PaymentResponse(false, "unable to process order, please try again."); assertThat(response, equalTo(expectedResponse)); verify(restTemplate).getForEntity("http: }
public PaymentResponse chargeChard() { ResponseEntity<String> paymentResponse = request(paymentsHost, "/charge-card"); return new PaymentResponse(paymentResponse); }
PaymentsConnector { public PaymentResponse chargeChard() { ResponseEntity<String> paymentResponse = request(paymentsHost, "/charge-card"); return new PaymentResponse(paymentResponse); } }
PaymentsConnector { public PaymentResponse chargeChard() { ResponseEntity<String> paymentResponse = request(paymentsHost, "/charge-card"); return new PaymentResponse(paymentResponse); } @Autowired  PaymentsConnector(
            @Value("${payments.host}") String paymentsHost,
            RestTemplate restTemplate
    ); }
PaymentsConnector { public PaymentResponse chargeChard() { ResponseEntity<String> paymentResponse = request(paymentsHost, "/charge-card"); return new PaymentResponse(paymentResponse); } @Autowired  PaymentsConnector(
            @Value("${payments.host}") String paymentsHost,
            RestTemplate restTemplate
    ); PaymentResponse chargeChard(); }
PaymentsConnector { public PaymentResponse chargeChard() { ResponseEntity<String> paymentResponse = request(paymentsHost, "/charge-card"); return new PaymentResponse(paymentResponse); } @Autowired  PaymentsConnector(
            @Value("${payments.host}") String paymentsHost,
            RestTemplate restTemplate
    ); PaymentResponse chargeChard();  }