@Test public void testShouldGetUserByUserName() { server.expect(once(), requestTo("http: withSuccess(new Resources().getFileContents("userResponse.json"), MediaType.APPLICATION_JSON_UTF8)); final User user = userRepository.getUserByUserName("system","tenantId"); server.verify(); assertEquals("system", user.getUserName()); }
public User getUserByUserName(String userName,String tenantId) { UserRequest request = new UserRequest(); request.setUserName(userName); request.setTenantId(tenantId); String url = userHost + getUserByUserNameUrl; List<User> userResponse = restTemplate.postForObject(url, request, UserResponse.class).getUser(); return (!userResponse.isEmpty()) ? userResponse.get(0) : User.builder().build(); }
UserRepository { public User getUserByUserName(String userName,String tenantId) { UserRequest request = new UserRequest(); request.setUserName(userName); request.setTenantId(tenantId); String url = userHost + getUserByUserNameUrl; List<User> userResponse = restTemplate.postForObject(url, request, UserResponse.class).getUser(); return (!userResponse.isEmpty()) ? userResponse.get(0) : User.builder().build(); } }
UserRepository { public User getUserByUserName(String userName,String tenantId) { UserRequest request = new UserRequest(); request.setUserName(userName); request.setTenantId(tenantId); String url = userHost + getUserByUserNameUrl; List<User> userResponse = restTemplate.postForObject(url, request, UserResponse.class).getUser(); return (!userResponse.isEmpty()) ? userResponse.get(0) : User.builder().build(); } UserRepository(RestTemplate restTemplate,
                          @Value("${egov.service.user.service.host}") String userHostUrl,
                          @Value("${egov.services.user.get_user_by_username}") String getUserByUserNameUrl); }
UserRepository { public User getUserByUserName(String userName,String tenantId) { UserRequest request = new UserRequest(); request.setUserName(userName); request.setTenantId(tenantId); String url = userHost + getUserByUserNameUrl; List<User> userResponse = restTemplate.postForObject(url, request, UserResponse.class).getUser(); return (!userResponse.isEmpty()) ? userResponse.get(0) : User.builder().build(); } UserRepository(RestTemplate restTemplate,
                          @Value("${egov.service.user.service.host}") String userHostUrl,
                          @Value("${egov.services.user.get_user_by_username}") String getUserByUserNameUrl); User getUserByUserName(String userName,String tenantId); }
UserRepository { public User getUserByUserName(String userName,String tenantId) { UserRequest request = new UserRequest(); request.setUserName(userName); request.setTenantId(tenantId); String url = userHost + getUserByUserNameUrl; List<User> userResponse = restTemplate.postForObject(url, request, UserResponse.class).getUser(); return (!userResponse.isEmpty()) ? userResponse.get(0) : User.builder().build(); } UserRepository(RestTemplate restTemplate,
                          @Value("${egov.service.user.service.host}") String userHostUrl,
                          @Value("${egov.services.user.get_user_by_username}") String getUserByUserNameUrl); User getUserByUserName(String userName,String tenantId);  }