@Test public void test_should_get_employees_by_userid() { server.expect(once(), requestTo("http: .andExpect(method(HttpMethod.POST)) .andRespond(withSuccess(new Resources().getFileContents("employeeResponse.json"), MediaType.APPLICATION_JSON_UTF8)); final EmployeeRes employeeRes = employeeRepository.getEmployeeForUserIdAndTenantId(1l, "tenantId"); server.verify(); assertEquals(1, employeeRes.getEmployees().size()); }
public EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); return restTemplate.postForObject(employeesByUserIdUrl, wrapper, EmployeeRes.class, userId, tenantId); }
EmployeeRepository { public EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); return restTemplate.postForObject(employeesByUserIdUrl, wrapper, EmployeeRes.class, userId, tenantId); } }
EmployeeRepository { public EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); return restTemplate.postForObject(employeesByUserIdUrl, wrapper, EmployeeRes.class, userId, tenantId); } @Autowired  EmployeeRepository(final RestTemplate restTemplate,
                              @Value("${egov.services.hremployee.host}") final String hrEmployeeServiceHostname,
                              @Value("${egov.services.hr.employee_by_userid}") final String hrEmployeesByUserIdUrl,
                              @Value("${egov.services.hr.employee_by_position}") final String hrEmployeesByPositionIdurl,
                              @Value("${egov.services.hr_employee_by_role}") final String hrEmployeesByRoleCodeurl); }
EmployeeRepository { public EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); return restTemplate.postForObject(employeesByUserIdUrl, wrapper, EmployeeRes.class, userId, tenantId); } @Autowired  EmployeeRepository(final RestTemplate restTemplate,
                              @Value("${egov.services.hremployee.host}") final String hrEmployeeServiceHostname,
                              @Value("${egov.services.hr.employee_by_userid}") final String hrEmployeesByUserIdUrl,
                              @Value("${egov.services.hr.employee_by_position}") final String hrEmployeesByPositionIdurl,
                              @Value("${egov.services.hr_employee_by_role}") final String hrEmployeesByRoleCodeurl); List<Employee> getByRoleCode(final String roleCode, final String tenantId); EmployeeRes getEmployeeForPositionAndTenantId(final Long posId, final LocalDate asOnDate, final String tenantId); EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId); }
EmployeeRepository { public EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(RequestInfo.builder().build()).build(); return restTemplate.postForObject(employeesByUserIdUrl, wrapper, EmployeeRes.class, userId, tenantId); } @Autowired  EmployeeRepository(final RestTemplate restTemplate,
                              @Value("${egov.services.hremployee.host}") final String hrEmployeeServiceHostname,
                              @Value("${egov.services.hr.employee_by_userid}") final String hrEmployeesByUserIdUrl,
                              @Value("${egov.services.hr.employee_by_position}") final String hrEmployeesByPositionIdurl,
                              @Value("${egov.services.hr_employee_by_role}") final String hrEmployeesByRoleCodeurl); List<Employee> getByRoleCode(final String roleCode, final String tenantId); EmployeeRes getEmployeeForPositionAndTenantId(final Long posId, final LocalDate asOnDate, final String tenantId); EmployeeRes getEmployeeForUserIdAndTenantId(final Long userId, final String tenantId);  }