@Test(expected = ServiceCallException.class) public void idGenShouldThrowServiceCallException() { Integer count =2; when(restTemplate.postForObject(idGenHost+idGenPath, getIdGenRequest(), IdGenerationResponse.class)).thenThrow(new HttpClientErrorException(HttpStatus.BAD_REQUEST)); assertFalse(getIdGenResponse().equals(idGenRepo.getId(new RequestInfo(), "mh.roha", count, PGRConstants.SERV_REQ_ID_NAME, PGRConstants.SERV_REQ_ID_FORMAT))); }
public IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name, String format) { List<IdRequest> reqList = new ArrayList<>(); for (int i = 0; i < count; i++) { reqList.add(IdRequest.builder().idName(name).format(format).tenantId(tenantId).build()); } IdGenerationRequest req = IdGenerationRequest.builder().idRequests(reqList).requestInfo(requestInfo).build(); IdGenerationResponse response = null; try { response = restTemplate.postForObject(idGenHost + idGenPath, req, IdGenerationResponse.class); } catch (HttpClientErrorException e) { throw new ServiceCallException(e.getResponseBodyAsString()); } catch (Exception e) { Map<String, String> map = new HashMap<>(); map.put(e.getCause().getClass().getName(),e.getMessage()); throw new CustomException(map); } return response; }
IdGenRepo { public IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name, String format) { List<IdRequest> reqList = new ArrayList<>(); for (int i = 0; i < count; i++) { reqList.add(IdRequest.builder().idName(name).format(format).tenantId(tenantId).build()); } IdGenerationRequest req = IdGenerationRequest.builder().idRequests(reqList).requestInfo(requestInfo).build(); IdGenerationResponse response = null; try { response = restTemplate.postForObject(idGenHost + idGenPath, req, IdGenerationResponse.class); } catch (HttpClientErrorException e) { throw new ServiceCallException(e.getResponseBodyAsString()); } catch (Exception e) { Map<String, String> map = new HashMap<>(); map.put(e.getCause().getClass().getName(),e.getMessage()); throw new CustomException(map); } return response; } }
IdGenRepo { public IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name, String format) { List<IdRequest> reqList = new ArrayList<>(); for (int i = 0; i < count; i++) { reqList.add(IdRequest.builder().idName(name).format(format).tenantId(tenantId).build()); } IdGenerationRequest req = IdGenerationRequest.builder().idRequests(reqList).requestInfo(requestInfo).build(); IdGenerationResponse response = null; try { response = restTemplate.postForObject(idGenHost + idGenPath, req, IdGenerationResponse.class); } catch (HttpClientErrorException e) { throw new ServiceCallException(e.getResponseBodyAsString()); } catch (Exception e) { Map<String, String> map = new HashMap<>(); map.put(e.getCause().getClass().getName(),e.getMessage()); throw new CustomException(map); } return response; }  }
IdGenRepo { public IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name, String format) { List<IdRequest> reqList = new ArrayList<>(); for (int i = 0; i < count; i++) { reqList.add(IdRequest.builder().idName(name).format(format).tenantId(tenantId).build()); } IdGenerationRequest req = IdGenerationRequest.builder().idRequests(reqList).requestInfo(requestInfo).build(); IdGenerationResponse response = null; try { response = restTemplate.postForObject(idGenHost + idGenPath, req, IdGenerationResponse.class); } catch (HttpClientErrorException e) { throw new ServiceCallException(e.getResponseBodyAsString()); } catch (Exception e) { Map<String, String> map = new HashMap<>(); map.put(e.getCause().getClass().getName(),e.getMessage()); throw new CustomException(map); } return response; }  IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name,
			String format); }
IdGenRepo { public IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name, String format) { List<IdRequest> reqList = new ArrayList<>(); for (int i = 0; i < count; i++) { reqList.add(IdRequest.builder().idName(name).format(format).tenantId(tenantId).build()); } IdGenerationRequest req = IdGenerationRequest.builder().idRequests(reqList).requestInfo(requestInfo).build(); IdGenerationResponse response = null; try { response = restTemplate.postForObject(idGenHost + idGenPath, req, IdGenerationResponse.class); } catch (HttpClientErrorException e) { throw new ServiceCallException(e.getResponseBodyAsString()); } catch (Exception e) { Map<String, String> map = new HashMap<>(); map.put(e.getCause().getClass().getName(),e.getMessage()); throw new CustomException(map); } return response; }  IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, Integer count, String name,
			String format);  }