@Test public void shouldCallMarqetaApiOnSuccessfulCreateCardInvocation() { final CreateCardResponse response = new CreateCardResponse(); when(restTemplate.postForObject(any(), any(), any(), any(Object[].class))).thenReturn(response); final CreateCardRequest request = new CreateCardRequest(); assertThat(target.createCard(request), is(sameInstance(response))); verify(restTemplate).postForObject( eq("https: same(request), eq(CreateCardResponse.class), any(Object[].class) ); }
public CreateCardResponse createCard(CreateCardRequest request) { try { final String url = baseUrl + "/cards?show_pan=true&show_cvv_number=true"; return restTemplate.postForObject(url, request, CreateCardResponse.class); } catch (HttpStatusCodeException cause) { throw errorFactory.fromResponseBody(cause.getResponseBodyAsString(), cause.getStatusCode()); } }
MarqetaClient { public CreateCardResponse createCard(CreateCardRequest request) { try { final String url = baseUrl + "/cards?show_pan=true&show_cvv_number=true"; return restTemplate.postForObject(url, request, CreateCardResponse.class); } catch (HttpStatusCodeException cause) { throw errorFactory.fromResponseBody(cause.getResponseBodyAsString(), cause.getStatusCode()); } } }
MarqetaClient { public CreateCardResponse createCard(CreateCardRequest request) { try { final String url = baseUrl + "/cards?show_pan=true&show_cvv_number=true"; return restTemplate.postForObject(url, request, CreateCardResponse.class); } catch (HttpStatusCodeException cause) { throw errorFactory.fromResponseBody(cause.getResponseBodyAsString(), cause.getStatusCode()); } } @Autowired  MarqetaClient(RestTemplate restTemplate, MarqetaErrorFactory errorFactory); }
MarqetaClient { public CreateCardResponse createCard(CreateCardRequest request) { try { final String url = baseUrl + "/cards?show_pan=true&show_cvv_number=true"; return restTemplate.postForObject(url, request, CreateCardResponse.class); } catch (HttpStatusCodeException cause) { throw errorFactory.fromResponseBody(cause.getResponseBodyAsString(), cause.getStatusCode()); } } @Autowired  MarqetaClient(RestTemplate restTemplate, MarqetaErrorFactory errorFactory); void setBaseUrl(String baseUrl); CreateCardResponse createCard(CreateCardRequest request); CreateUserResponse createUser(CreateUserRequest request); }
MarqetaClient { public CreateCardResponse createCard(CreateCardRequest request) { try { final String url = baseUrl + "/cards?show_pan=true&show_cvv_number=true"; return restTemplate.postForObject(url, request, CreateCardResponse.class); } catch (HttpStatusCodeException cause) { throw errorFactory.fromResponseBody(cause.getResponseBodyAsString(), cause.getStatusCode()); } } @Autowired  MarqetaClient(RestTemplate restTemplate, MarqetaErrorFactory errorFactory); void setBaseUrl(String baseUrl); CreateCardResponse createCard(CreateCardRequest request); CreateUserResponse createUser(CreateUserRequest request);  }