@Test public void testDeleteBankAccount() throws BaseException { BankAccount expectedBankAccount = new BankAccount.Builder().accountNumber("accountId").build(); final String bankAccountString = JsonUtil.serialize(expectedBankAccount); final Response mockedResponse = new Response(200, bankAccountString, "fjkdlsfd"); mockedResponse.setResponseObject(expectedBankAccount); new Expectations() {{ serviceBase.sendRequest((Request) any); result = mockedResponse; }}; RequestContext requestContext = new RequestContext(); requestContext.setBaseUrl("fakeBaseUrl"); BankAccountService bankService = new BankAccountService(requestContext); try { BankAccount bankAccount = new BankAccount(); BankAccount bankAccountGenerated = bankService.delete("customerId", "bankAccountId"); } catch (BaseException e) { Assert.fail("Unexpected BaseException thrown " + e.getMessage()); } }
public BankAccount delete(String customerId, String bankaccountId) throws BaseException { logger.debug("Enter BankAccountService::delete"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(bankaccountId)) { logger.error("IllegalArgumentException {}", bankaccountId); throw new IllegalArgumentException("bankaccountId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId); logger.info("apiUrl - " + apiUrl); Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build(); Response response = sendRequest(request); BankAccount bankAccountResponse = new BankAccount(); prepareResponse(request, response, bankAccountResponse); return bankAccountResponse; }
BankAccountService extends ServiceBase { public BankAccount delete(String customerId, String bankaccountId) throws BaseException { logger.debug("Enter BankAccountService::delete"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(bankaccountId)) { logger.error("IllegalArgumentException {}", bankaccountId); throw new IllegalArgumentException("bankaccountId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId); logger.info("apiUrl - " + apiUrl); Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build(); Response response = sendRequest(request); BankAccount bankAccountResponse = new BankAccount(); prepareResponse(request, response, bankAccountResponse); return bankAccountResponse; } }
BankAccountService extends ServiceBase { public BankAccount delete(String customerId, String bankaccountId) throws BaseException { logger.debug("Enter BankAccountService::delete"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(bankaccountId)) { logger.error("IllegalArgumentException {}", bankaccountId); throw new IllegalArgumentException("bankaccountId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId); logger.info("apiUrl - " + apiUrl); Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build(); Response response = sendRequest(request); BankAccount bankAccountResponse = new BankAccount(); prepareResponse(request, response, bankAccountResponse); return bankAccountResponse; } BankAccountService(RequestContext requestContext); protected  BankAccountService(); }
BankAccountService extends ServiceBase { public BankAccount delete(String customerId, String bankaccountId) throws BaseException { logger.debug("Enter BankAccountService::delete"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(bankaccountId)) { logger.error("IllegalArgumentException {}", bankaccountId); throw new IllegalArgumentException("bankaccountId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId); logger.info("apiUrl - " + apiUrl); Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build(); Response response = sendRequest(request); BankAccount bankAccountResponse = new BankAccount(); prepareResponse(request, response, bankAccountResponse); return bankAccountResponse; } BankAccountService(RequestContext requestContext); protected  BankAccountService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); BankAccount create(BankAccount bankAccount, String customerId); BankAccount createFromToken(Token token, String customerId); BankAccount delete(String customerId, String bankaccountId); BankAccount getBankAccount(String customerId, String bankaccountId); @SuppressWarnings("unchecked") QueryResponse getAllBankAccounts(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllBankAccounts(String customerId, int count); }
BankAccountService extends ServiceBase { public BankAccount delete(String customerId, String bankaccountId) throws BaseException { logger.debug("Enter BankAccountService::delete"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(bankaccountId)) { logger.error("IllegalArgumentException {}", bankaccountId); throw new IllegalArgumentException("bankaccountId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId); logger.info("apiUrl - " + apiUrl); Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build(); Response response = sendRequest(request); BankAccount bankAccountResponse = new BankAccount(); prepareResponse(request, response, bankAccountResponse); return bankAccountResponse; } BankAccountService(RequestContext requestContext); protected  BankAccountService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); BankAccount create(BankAccount bankAccount, String customerId); BankAccount createFromToken(Token token, String customerId); BankAccount delete(String customerId, String bankaccountId); BankAccount getBankAccount(String customerId, String bankaccountId); @SuppressWarnings("unchecked") QueryResponse getAllBankAccounts(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllBankAccounts(String customerId, int count);  }