@Test public void testGetServiceRequestsFailure() { Object response = new Object(); SearcherRequest searcherRequest = Mockito.mock(SearcherRequest.class); StringBuilder uri = new StringBuilder(); uri.append("http: Mockito.when(restTemplate.postForObject(uri.toString(), searcherRequest, Map.class)).thenReturn(null); MdmsCriteriaReq mdmsCriteriaReq = new MdmsCriteriaReq(); response = serviceRequestRepository.fetchResult(uri, mdmsCriteriaReq); assertNull(response); }
public Object fetchResult(StringBuilder uri, Object request) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Object response = null; try { response = restTemplate.postForObject(uri.toString(), request, Map.class); }catch(HttpClientErrorException e) { log.error("External Service threw an Exception: ",e); throw new ServiceCallException(e.getResponseBodyAsString()); }catch(Exception e) { log.error("Exception while fetching from searcher: ",e); } return response; }
ServiceRequestRepository { public Object fetchResult(StringBuilder uri, Object request) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Object response = null; try { response = restTemplate.postForObject(uri.toString(), request, Map.class); }catch(HttpClientErrorException e) { log.error("External Service threw an Exception: ",e); throw new ServiceCallException(e.getResponseBodyAsString()); }catch(Exception e) { log.error("Exception while fetching from searcher: ",e); } return response; } }
ServiceRequestRepository { public Object fetchResult(StringBuilder uri, Object request) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Object response = null; try { response = restTemplate.postForObject(uri.toString(), request, Map.class); }catch(HttpClientErrorException e) { log.error("External Service threw an Exception: ",e); throw new ServiceCallException(e.getResponseBodyAsString()); }catch(Exception e) { log.error("Exception while fetching from searcher: ",e); } return response; }  }
ServiceRequestRepository { public Object fetchResult(StringBuilder uri, Object request) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Object response = null; try { response = restTemplate.postForObject(uri.toString(), request, Map.class); }catch(HttpClientErrorException e) { log.error("External Service threw an Exception: ",e); throw new ServiceCallException(e.getResponseBodyAsString()); }catch(Exception e) { log.error("Exception while fetching from searcher: ",e); } return response; }  Object fetchResult(StringBuilder uri, Object request); }
ServiceRequestRepository { public Object fetchResult(StringBuilder uri, Object request) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Object response = null; try { response = restTemplate.postForObject(uri.toString(), request, Map.class); }catch(HttpClientErrorException e) { log.error("External Service threw an Exception: ",e); throw new ServiceCallException(e.getResponseBodyAsString()); }catch(Exception e) { log.error("Exception while fetching from searcher: ",e); } return response; }  Object fetchResult(StringBuilder uri, Object request);  }