@Test public void searchBillTest() { BillSearchCriteria billSearchCriteria = new BillSearchCriteria(); billSearchCriteria.setBillId(1l); RequestInfo requestInfo = new RequestInfo(); List<BillInfo> billInfos = getBillInfos(); BillResponse billResponse = new BillResponse(); billResponse.setBillInfos(billInfos); String url = "host/_search" + "?billId=" + billSearchCriteria.getBillId(); when(propertiesManager.getDemandServiceHostName()).thenReturn("host/"); when(propertiesManager.getDemandBillSearchService()).thenReturn("_search"); when(restTemplate.postForObject(url, requestInfo, BillResponse.class)).thenReturn(billResponse); assertTrue(billInfos.get(0).equals(billRepository.searchBill(billSearchCriteria, requestInfo))); }
public BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandBillSearchService() + "?billId=" + billSearchCriteria.getBillId(); LOGGER.info("The url for search bill API ::: " + url); BillResponse billResponse = null; if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } try { billResponse = restTemplate.postForObject(url, requestInfo, BillResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.info("the exception from billsearch API call ::: " + e); } LOGGER.info("the response for bill search API call ::: " + billResponse.getBillInfos().get(0)); return billResponse.getBillInfos().get(0); }
BillRepository { public BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandBillSearchService() + "?billId=" + billSearchCriteria.getBillId(); LOGGER.info("The url for search bill API ::: " + url); BillResponse billResponse = null; if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } try { billResponse = restTemplate.postForObject(url, requestInfo, BillResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.info("the exception from billsearch API call ::: " + e); } LOGGER.info("the response for bill search API call ::: " + billResponse.getBillInfos().get(0)); return billResponse.getBillInfos().get(0); } }
BillRepository { public BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandBillSearchService() + "?billId=" + billSearchCriteria.getBillId(); LOGGER.info("The url for search bill API ::: " + url); BillResponse billResponse = null; if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } try { billResponse = restTemplate.postForObject(url, requestInfo, BillResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.info("the exception from billsearch API call ::: " + e); } LOGGER.info("the response for bill search API call ::: " + billResponse.getBillInfos().get(0)); return billResponse.getBillInfos().get(0); }  }
BillRepository { public BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandBillSearchService() + "?billId=" + billSearchCriteria.getBillId(); LOGGER.info("The url for search bill API ::: " + url); BillResponse billResponse = null; if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } try { billResponse = restTemplate.postForObject(url, requestInfo, BillResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.info("the exception from billsearch API call ::: " + e); } LOGGER.info("the response for bill search API call ::: " + billResponse.getBillInfos().get(0)); return billResponse.getBillInfos().get(0); }  String createBillAndGetXml(List<BillInfo> billInfos, RequestInfo requestInfo); BillResponse updateBill(List<BillInfo> billInfos, RequestInfo requestInfo); BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo); Map getPurpose(String tenantId); }
BillRepository { public BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandBillSearchService() + "?billId=" + billSearchCriteria.getBillId(); LOGGER.info("The url for search bill API ::: " + url); BillResponse billResponse = null; if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } try { billResponse = restTemplate.postForObject(url, requestInfo, BillResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.info("the exception from billsearch API call ::: " + e); } LOGGER.info("the response for bill search API call ::: " + billResponse.getBillInfos().get(0)); return billResponse.getBillInfos().get(0); }  String createBillAndGetXml(List<BillInfo> billInfos, RequestInfo requestInfo); BillResponse updateBill(List<BillInfo> billInfos, RequestInfo requestInfo); BillInfo searchBill(BillSearchCriteria billSearchCriteria, RequestInfo requestInfo); Map getPurpose(String tenantId);  }