@Test public void shouldCallMarqetaApiAndSaveResponse() { final String userToken = "test"; final CreateCardResponse response = new CreateCardResponse(); response.setToken(UUID.randomUUID().toString()); response.setCardProductToken(CARD_PRODUCT_TOKEN); response.setUserToken(userToken); response.setPan("1111222233334444"); response.setCvvNumber("123"); response.setExpirationTime(LocalDateTime.now().plusYears(4)); when(marqetaClient.createCard(any())).thenReturn(response); final Card entity = target.createCard(userToken); assertThat(entity, is(notNullValue())); assertThat(entity.getToken(), is(equalTo(response.getToken()))); assertThat(entity.getCardProductToken(), is(equalTo(response.getCardProductToken()))); assertThat(entity.getUserToken(), is(equalTo(response.getUserToken()))); assertThat(entity.getPan(), is(equalTo(response.getPan()))); assertThat(entity.getCvvNumber(), is(equalTo(response.getCvvNumber()))); assertThat(entity.getExpirationTime(), is(equalTo(response.getExpirationTime()))); final ArgumentCaptor<CreateCardRequest> arg = ArgumentCaptor.forClass(CreateCardRequest.class); verify(marqetaClient).createCard(arg.capture()); final CreateCardRequest request = arg.getValue(); assertThat(request, is(notNullValue())); assertThat(request.getCardProductToken(), is(equalTo(CARD_PRODUCT_TOKEN))); assertThat(request.getUserToken(), is(equalTo(userToken))); }
@Override public Card createCard(String userToken) { final CreateCardResponse response = marqetaClient.createCard(new CreateCardRequest(cardProductToken, userToken)); final Card card = new Card(); card.setToken(response.getToken()); card.setCardProductToken(response.getCardProductToken()); card.setUserToken(response.getUserToken()); card.setPan(response.getPan()); card.setCvvNumber(response.getCvvNumber()); card.setExpirationTime(response.getExpirationTime()); return cardRepository.save(card); }
CardServiceImpl implements CardService { @Override public Card createCard(String userToken) { final CreateCardResponse response = marqetaClient.createCard(new CreateCardRequest(cardProductToken, userToken)); final Card card = new Card(); card.setToken(response.getToken()); card.setCardProductToken(response.getCardProductToken()); card.setUserToken(response.getUserToken()); card.setPan(response.getPan()); card.setCvvNumber(response.getCvvNumber()); card.setExpirationTime(response.getExpirationTime()); return cardRepository.save(card); } }
CardServiceImpl implements CardService { @Override public Card createCard(String userToken) { final CreateCardResponse response = marqetaClient.createCard(new CreateCardRequest(cardProductToken, userToken)); final Card card = new Card(); card.setToken(response.getToken()); card.setCardProductToken(response.getCardProductToken()); card.setUserToken(response.getUserToken()); card.setPan(response.getPan()); card.setCvvNumber(response.getCvvNumber()); card.setExpirationTime(response.getExpirationTime()); return cardRepository.save(card); } CardServiceImpl(CardRepository cardRepository, MarqetaClient marqetaClient,
      @Value("${marqeta.card-product.token}") String cardProductToken); }
CardServiceImpl implements CardService { @Override public Card createCard(String userToken) { final CreateCardResponse response = marqetaClient.createCard(new CreateCardRequest(cardProductToken, userToken)); final Card card = new Card(); card.setToken(response.getToken()); card.setCardProductToken(response.getCardProductToken()); card.setUserToken(response.getUserToken()); card.setPan(response.getPan()); card.setCvvNumber(response.getCvvNumber()); card.setExpirationTime(response.getExpirationTime()); return cardRepository.save(card); } CardServiceImpl(CardRepository cardRepository, MarqetaClient marqetaClient,
      @Value("${marqeta.card-product.token}") String cardProductToken); @Override Card createCard(String userToken); }
CardServiceImpl implements CardService { @Override public Card createCard(String userToken) { final CreateCardResponse response = marqetaClient.createCard(new CreateCardRequest(cardProductToken, userToken)); final Card card = new Card(); card.setToken(response.getToken()); card.setCardProductToken(response.getCardProductToken()); card.setUserToken(response.getUserToken()); card.setPan(response.getPan()); card.setCvvNumber(response.getCvvNumber()); card.setExpirationTime(response.getExpirationTime()); return cardRepository.save(card); } CardServiceImpl(CardRepository cardRepository, MarqetaClient marqetaClient,
      @Value("${marqeta.card-product.token}") String cardProductToken); @Override Card createCard(String userToken);  }