@Test public void test_should_fetch_employee_for_given_positionid() throws Exception { LocalDate sysDate = new LocalDate(); server.expect(once(), requestTo("http: .andExpect(method(HttpMethod.POST)) .andRespond(withSuccess(new Resources().getFileContents("successEmployeeResponse.json"), MediaType.APPLICATION_JSON_UTF8)); final Employee employee = employeeRepository.fetchEmployeeByPositionId(1L, sysDate, "1"); server.verify(); assertEquals(Long.valueOf(1), employee.getId()); assertEquals("narasappa", employee.getName()); }
public Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); final String date = asOnDate.toString("dd/MM/yyyy"); final EmployeeResponse employeeResponse = restTemplate .postForObject(hrMasterPositionUrl, wrapper, EmployeeResponse.class, positionId, date, tenantId); return employeeResponse.getEmployees().get(0); }
EmployeeRepository { public Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); final String date = asOnDate.toString("dd/MM/yyyy"); final EmployeeResponse employeeResponse = restTemplate .postForObject(hrMasterPositionUrl, wrapper, EmployeeResponse.class, positionId, date, tenantId); return employeeResponse.getEmployees().get(0); } }
EmployeeRepository { public Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); final String date = asOnDate.toString("dd/MM/yyyy"); final EmployeeResponse employeeResponse = restTemplate .postForObject(hrMasterPositionUrl, wrapper, EmployeeResponse.class, positionId, date, tenantId); return employeeResponse.getEmployees().get(0); } EmployeeRepository(RestTemplate restTemplate,
                              @Value("${egov.services.hremployee.host}") String employeeServiceHost,
                              @Value("${egov.services.hr_employee.positionhierarchys}") String hrMasterHost); }
EmployeeRepository { public Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); final String date = asOnDate.toString("dd/MM/yyyy"); final EmployeeResponse employeeResponse = restTemplate .postForObject(hrMasterPositionUrl, wrapper, EmployeeResponse.class, positionId, date, tenantId); return employeeResponse.getEmployees().get(0); } EmployeeRepository(RestTemplate restTemplate,
                              @Value("${egov.services.hremployee.host}") String employeeServiceHost,
                              @Value("${egov.services.hr_employee.positionhierarchys}") String hrMasterHost); Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId); }
EmployeeRepository { public Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); final String date = asOnDate.toString("dd/MM/yyyy"); final EmployeeResponse employeeResponse = restTemplate .postForObject(hrMasterPositionUrl, wrapper, EmployeeResponse.class, positionId, date, tenantId); return employeeResponse.getEmployees().get(0); } EmployeeRepository(RestTemplate restTemplate,
                              @Value("${egov.services.hremployee.host}") String employeeServiceHost,
                              @Value("${egov.services.hr_employee.positionhierarchys}") String hrMasterHost); Employee fetchEmployeeByPositionId(final Long positionId, final LocalDate asOnDate, final String tenantId);  }