@Test public void getDemandBySearchTest(){ DemandSearchCriteria demandSearchCriteria = new DemandSearchCriteria(); demandSearchCriteria.setDemandId(1l); RequestInfo requestInfo = new RequestInfo(); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); String url = "http: DemandResponse demandResponse = new DemandResponse(); demandResponse.setDemands(getdemands()); when(propertiesManager.getDemandServiceHostName()).thenReturn("http: when(propertiesManager.getDemandSearchServicepath()).thenReturn("demand-services/demand/_search"); when(restTemplate.postForObject(url, requestInfo, DemandResponse.class)).thenReturn(demandResponse); assertTrue(demandResponse.equals(demandRepository.getDemandBySearch(demandSearchCriteria, requestInfo))); }
public DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandSearchServicepath() + "?demandId=" + demandSearchCriteria.getDemandId(); LOGGER.info("the url of demand search API call ::: is " + url); if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } DemandResponse demandResponse = null; try { demandResponse = restTemplate.postForObject(url, requestInfo, DemandResponse.class); } catch (Exception e) { LOGGER.info("the exception thrown from demand search api call ::: " + e); } LOGGER.info("the response form demand search api call ::: " + demandResponse); return demandResponse; }
DemandRepository { public DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandSearchServicepath() + "?demandId=" + demandSearchCriteria.getDemandId(); LOGGER.info("the url of demand search API call ::: is " + url); if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } DemandResponse demandResponse = null; try { demandResponse = restTemplate.postForObject(url, requestInfo, DemandResponse.class); } catch (Exception e) { LOGGER.info("the exception thrown from demand search api call ::: " + e); } LOGGER.info("the response form demand search api call ::: " + demandResponse); return demandResponse; } }
DemandRepository { public DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandSearchServicepath() + "?demandId=" + demandSearchCriteria.getDemandId(); LOGGER.info("the url of demand search API call ::: is " + url); if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } DemandResponse demandResponse = null; try { demandResponse = restTemplate.postForObject(url, requestInfo, DemandResponse.class); } catch (Exception e) { LOGGER.info("the exception thrown from demand search api call ::: " + e); } LOGGER.info("the response form demand search api call ::: " + demandResponse); return demandResponse; }  }
DemandRepository { public DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandSearchServicepath() + "?demandId=" + demandSearchCriteria.getDemandId(); LOGGER.info("the url of demand search API call ::: is " + url); if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } DemandResponse demandResponse = null; try { demandResponse = restTemplate.postForObject(url, requestInfo, DemandResponse.class); } catch (Exception e) { LOGGER.info("the exception thrown from demand search api call ::: " + e); } LOGGER.info("the response form demand search api call ::: " + demandResponse); return demandResponse; }  List<DemandReason> getDemandReason(AgreementRequest agreementRequest); List<DemandReason> getLegacyDemandReason(AgreementRequest agreementRequest); List<Demand> getDemandList(AgreementRequest agreementRequest, List<DemandReason> demandReasons); DemandResponse createDemand(List<Demand> demands, RequestInfo requestInfo); DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo); DemandResponse updateDemandForCollection(List<Demand> demands, RequestInfo requestInfo); DemandResponse updateDemandForCollectionWithCancelReceipt(List<Demand> demands, RequestInfo requestInfo); DemandResponse updateDemand(List<Demand> demands, RequestInfo requestInfo); List<DemandReason> getDemandReasonForRenewal(AgreementRequest agreementRequest, boolean isForApproval); }
DemandRepository { public DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo) { String url = propertiesManager.getDemandServiceHostName() + propertiesManager.getDemandSearchServicepath() + "?demandId=" + demandSearchCriteria.getDemandId(); LOGGER.info("the url of demand search API call ::: is " + url); if (requestInfo == null) { LOGGER.info("requestInfo ::: is null "); requestInfo = new RequestInfo(); requestInfo.setApiId("apiid"); requestInfo.setVer("ver"); requestInfo.setTs(new Date()); } DemandResponse demandResponse = null; try { demandResponse = restTemplate.postForObject(url, requestInfo, DemandResponse.class); } catch (Exception e) { LOGGER.info("the exception thrown from demand search api call ::: " + e); } LOGGER.info("the response form demand search api call ::: " + demandResponse); return demandResponse; }  List<DemandReason> getDemandReason(AgreementRequest agreementRequest); List<DemandReason> getLegacyDemandReason(AgreementRequest agreementRequest); List<Demand> getDemandList(AgreementRequest agreementRequest, List<DemandReason> demandReasons); DemandResponse createDemand(List<Demand> demands, RequestInfo requestInfo); DemandResponse getDemandBySearch(DemandSearchCriteria demandSearchCriteria, RequestInfo requestInfo); DemandResponse updateDemandForCollection(List<Demand> demands, RequestInfo requestInfo); DemandResponse updateDemandForCollectionWithCancelReceipt(List<Demand> demands, RequestInfo requestInfo); DemandResponse updateDemand(List<Demand> demands, RequestInfo requestInfo); List<DemandReason> getDemandReasonForRenewal(AgreementRequest agreementRequest, boolean isForApproval);  }