@Test public void testRetrieveECheck() throws BaseException { ECheck expectedECheck = new ECheck.Builder().id("ijids").amount(new BigDecimal("50000")).build(); final String eCheckString = JsonUtil.serialize(expectedECheck); final Response mockedResponse = new Response(200, eCheckString, "fjkdlsfd"); mockedResponse.setResponseObject(expectedECheck); new Expectations() {{ serviceBase.sendRequest((Request) any); result = mockedResponse; }}; RequestContext requestContext = new RequestContext(); requestContext.setBaseUrl("fakeBaseUrl"); ECheckService eCheckService = new ECheckService(requestContext); try { ECheck eCheckGenerated = eCheckService.retrieve("myECheckId"); Assert.assertEquals(expectedECheck, eCheckGenerated); } catch (BaseException e) { Assert.fail("Unexpected BaseException thrown " + e.getMessage()); } }
public ECheck retrieve(String eCheckId) throws BaseException { logger.debug("Enter ECheckService::retrieve"); if (StringUtils.isBlank(eCheckId)) { logger.error("IllegalArgumentException {}", eCheckId); throw new IllegalArgumentException("eCheckId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "echecks/{id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", eCheckId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<ECheck> typeReference = new TypeReference<ECheck>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); ECheck eCheckResponse = (ECheck) response.getResponseObject(); prepareResponse(request, response, eCheckResponse); return eCheckResponse; }
ECheckService extends ServiceBase { public ECheck retrieve(String eCheckId) throws BaseException { logger.debug("Enter ECheckService::retrieve"); if (StringUtils.isBlank(eCheckId)) { logger.error("IllegalArgumentException {}", eCheckId); throw new IllegalArgumentException("eCheckId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "echecks/{id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", eCheckId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<ECheck> typeReference = new TypeReference<ECheck>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); ECheck eCheckResponse = (ECheck) response.getResponseObject(); prepareResponse(request, response, eCheckResponse); return eCheckResponse; } }
ECheckService extends ServiceBase { public ECheck retrieve(String eCheckId) throws BaseException { logger.debug("Enter ECheckService::retrieve"); if (StringUtils.isBlank(eCheckId)) { logger.error("IllegalArgumentException {}", eCheckId); throw new IllegalArgumentException("eCheckId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "echecks/{id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", eCheckId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<ECheck> typeReference = new TypeReference<ECheck>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); ECheck eCheckResponse = (ECheck) response.getResponseObject(); prepareResponse(request, response, eCheckResponse); return eCheckResponse; } ECheckService(RequestContext requestContext); protected  ECheckService(); }
ECheckService extends ServiceBase { public ECheck retrieve(String eCheckId) throws BaseException { logger.debug("Enter ECheckService::retrieve"); if (StringUtils.isBlank(eCheckId)) { logger.error("IllegalArgumentException {}", eCheckId); throw new IllegalArgumentException("eCheckId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "echecks/{id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", eCheckId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<ECheck> typeReference = new TypeReference<ECheck>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); ECheck eCheckResponse = (ECheck) response.getResponseObject(); prepareResponse(request, response, eCheckResponse); return eCheckResponse; } ECheckService(RequestContext requestContext); protected  ECheckService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); ECheck create(ECheck eCheck); ECheck retrieve(String eCheckId); Refund refund(String eCheckId, Refund refund); Refund getRefund(String eCheckId, String refundId); }
ECheckService extends ServiceBase { public ECheck retrieve(String eCheckId) throws BaseException { logger.debug("Enter ECheckService::retrieve"); if (StringUtils.isBlank(eCheckId)) { logger.error("IllegalArgumentException {}", eCheckId); throw new IllegalArgumentException("eCheckId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "echecks/{id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", eCheckId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<ECheck> typeReference = new TypeReference<ECheck>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); ECheck eCheckResponse = (ECheck) response.getResponseObject(); prepareResponse(request, response, eCheckResponse); return eCheckResponse; } ECheckService(RequestContext requestContext); protected  ECheckService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); ECheck create(ECheck eCheck); ECheck retrieve(String eCheckId); Refund refund(String eCheckId, Refund refund); Refund getRefund(String eCheckId, String refundId);  }