@Test(expectedExceptions = IllegalArgumentException.class) public void testgetAllCardCountCustomerNull() throws BaseException { CardService cardService = new CardService(); cardService.getAllCards(null, 0); }
@SuppressWarnings("unchecked") public QueryResponse getAllCards(String customerId) throws BaseException { logger.debug("Enter CardService::getAllCards"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<List<Card>> typeReference = new TypeReference<List<Card>>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); List<Card> cards = (List<Card>) response.getResponseObject(); QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build(); prepareResponse(request, response, queryResponse); return queryResponse; }
CardService extends ServiceBase { @SuppressWarnings("unchecked") public QueryResponse getAllCards(String customerId) throws BaseException { logger.debug("Enter CardService::getAllCards"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<List<Card>> typeReference = new TypeReference<List<Card>>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); List<Card> cards = (List<Card>) response.getResponseObject(); QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build(); prepareResponse(request, response, queryResponse); return queryResponse; } }
CardService extends ServiceBase { @SuppressWarnings("unchecked") public QueryResponse getAllCards(String customerId) throws BaseException { logger.debug("Enter CardService::getAllCards"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<List<Card>> typeReference = new TypeReference<List<Card>>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); List<Card> cards = (List<Card>) response.getResponseObject(); QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build(); prepareResponse(request, response, queryResponse); return queryResponse; } CardService(RequestContext requestContext); protected  CardService(); }
CardService extends ServiceBase { @SuppressWarnings("unchecked") public QueryResponse getAllCards(String customerId) throws BaseException { logger.debug("Enter CardService::getAllCards"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<List<Card>> typeReference = new TypeReference<List<Card>>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); List<Card> cards = (List<Card>) response.getResponseObject(); QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build(); prepareResponse(request, response, queryResponse); return queryResponse; } CardService(RequestContext requestContext); protected  CardService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Card create(Card card, String customerId); Card createFromToken(Token token, String customerId); Card delete(String customerId, String cardId); Card getCard(String customerId, String cardId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId, int count); }
CardService extends ServiceBase { @SuppressWarnings("unchecked") public QueryResponse getAllCards(String customerId) throws BaseException { logger.debug("Enter CardService::getAllCards"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<List<Card>> typeReference = new TypeReference<List<Card>>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); List<Card> cards = (List<Card>) response.getResponseObject(); QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build(); prepareResponse(request, response, queryResponse); return queryResponse; } CardService(RequestContext requestContext); protected  CardService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Card create(Card card, String customerId); Card createFromToken(Token token, String customerId); Card delete(String customerId, String cardId); Card getCard(String customerId, String cardId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId, int count);  }