@Test public void test_should_return_escalation_hours_for_given_search_criteria() throws Exception { String tenantId = "tenantId"; final String complaintTypeId = "1"; final String designationId1 = "2"; String expectedUrl = "http: server.expect(once(), requestTo(expectedUrl)) .andExpect(method(HttpMethod.POST)) .andExpect(content().string(resources.getFileContents("escalationHoursRequest.json"))) .andRespond(withSuccess(resources.getFileContents("escalationHoursResponse.json"), MediaType.APPLICATION_JSON_UTF8)); final int escalationHours = escalationHoursRepository .getEscalationHours(tenantId, complaintTypeId, designationId1); server.verify(); assertEquals(3, escalationHours); }
public int getEscalationHours(String tenantId, String complaintTypeId, String designationId) { final EscalationHoursRequest request = new EscalationHoursRequest(null); final HashMap<String, String> uriVariables = new HashMap<>(); uriVariables.put("tenantId", tenantId); uriVariables.put("complaintTypeId", complaintTypeId); uriVariables.put("designationId", designationId); final EscalationHoursResponse escalationHoursResponse = this.restTemplate .postForObject(this.url, request, EscalationHoursResponse.class, uriVariables); if (escalationHoursResponse.getEscalationTimeTypes().size() > 0) { return Math.toIntExact(escalationHoursResponse.getEscalationTimeTypes().get(0).getHours()); } else return 0; }
EscalationHoursRepository { public int getEscalationHours(String tenantId, String complaintTypeId, String designationId) { final EscalationHoursRequest request = new EscalationHoursRequest(null); final HashMap<String, String> uriVariables = new HashMap<>(); uriVariables.put("tenantId", tenantId); uriVariables.put("complaintTypeId", complaintTypeId); uriVariables.put("designationId", designationId); final EscalationHoursResponse escalationHoursResponse = this.restTemplate .postForObject(this.url, request, EscalationHoursResponse.class, uriVariables); if (escalationHoursResponse.getEscalationTimeTypes().size() > 0) { return Math.toIntExact(escalationHoursResponse.getEscalationTimeTypes().get(0).getHours()); } else return 0; } }
EscalationHoursRepository { public int getEscalationHours(String tenantId, String complaintTypeId, String designationId) { final EscalationHoursRequest request = new EscalationHoursRequest(null); final HashMap<String, String> uriVariables = new HashMap<>(); uriVariables.put("tenantId", tenantId); uriVariables.put("complaintTypeId", complaintTypeId); uriVariables.put("designationId", designationId); final EscalationHoursResponse escalationHoursResponse = this.restTemplate .postForObject(this.url, request, EscalationHoursResponse.class, uriVariables); if (escalationHoursResponse.getEscalationTimeTypes().size() > 0) { return Math.toIntExact(escalationHoursResponse.getEscalationTimeTypes().get(0).getHours()); } else return 0; } EscalationHoursRepository(RestTemplate restTemplate,
                                     @Value("${egov.services.workflow.hostname}") String host,
                                     @Value("${egov.services.workflow.escalationhours}") String endpointUrl); }
EscalationHoursRepository { public int getEscalationHours(String tenantId, String complaintTypeId, String designationId) { final EscalationHoursRequest request = new EscalationHoursRequest(null); final HashMap<String, String> uriVariables = new HashMap<>(); uriVariables.put("tenantId", tenantId); uriVariables.put("complaintTypeId", complaintTypeId); uriVariables.put("designationId", designationId); final EscalationHoursResponse escalationHoursResponse = this.restTemplate .postForObject(this.url, request, EscalationHoursResponse.class, uriVariables); if (escalationHoursResponse.getEscalationTimeTypes().size() > 0) { return Math.toIntExact(escalationHoursResponse.getEscalationTimeTypes().get(0).getHours()); } else return 0; } EscalationHoursRepository(RestTemplate restTemplate,
                                     @Value("${egov.services.workflow.hostname}") String host,
                                     @Value("${egov.services.workflow.escalationhours}") String endpointUrl); int getEscalationHours(String tenantId, String complaintTypeId, String designationId); }
EscalationHoursRepository { public int getEscalationHours(String tenantId, String complaintTypeId, String designationId) { final EscalationHoursRequest request = new EscalationHoursRequest(null); final HashMap<String, String> uriVariables = new HashMap<>(); uriVariables.put("tenantId", tenantId); uriVariables.put("complaintTypeId", complaintTypeId); uriVariables.put("designationId", designationId); final EscalationHoursResponse escalationHoursResponse = this.restTemplate .postForObject(this.url, request, EscalationHoursResponse.class, uriVariables); if (escalationHoursResponse.getEscalationTimeTypes().size() > 0) { return Math.toIntExact(escalationHoursResponse.getEscalationTimeTypes().get(0).getHours()); } else return 0; } EscalationHoursRepository(RestTemplate restTemplate,
                                     @Value("${egov.services.workflow.hostname}") String host,
                                     @Value("${egov.services.workflow.escalationhours}") String endpointUrl); int getEscalationHours(String tenantId, String complaintTypeId, String designationId);  }