@Test public void test_should_return_false_when_user_does_not_exist_with_given_user_name_and_tenant() { boolean isPresent = userRepository.isUserPresent("userName", "ap.public", UserType.EMPLOYEE); assertFalse(isPresent); }
public boolean isUserPresent(String userName, String tenantId, UserType userType) { String query = userTypeQueryBuilder.getUserPresentByUserNameAndTenant(); final Map<String, Object> parametersMap = new HashMap<String, Object>(); parametersMap.put("userName", userName); parametersMap.put("tenantId", tenantId); parametersMap.put("userType", userType.toString()); int count = namedParameterJdbcTemplate.queryForObject(query, parametersMap, Integer.class); return count > 0; }
UserRepository { public boolean isUserPresent(String userName, String tenantId, UserType userType) { String query = userTypeQueryBuilder.getUserPresentByUserNameAndTenant(); final Map<String, Object> parametersMap = new HashMap<String, Object>(); parametersMap.put("userName", userName); parametersMap.put("tenantId", tenantId); parametersMap.put("userType", userType.toString()); int count = namedParameterJdbcTemplate.queryForObject(query, parametersMap, Integer.class); return count > 0; } }
UserRepository { public boolean isUserPresent(String userName, String tenantId, UserType userType) { String query = userTypeQueryBuilder.getUserPresentByUserNameAndTenant(); final Map<String, Object> parametersMap = new HashMap<String, Object>(); parametersMap.put("userName", userName); parametersMap.put("tenantId", tenantId); parametersMap.put("userType", userType.toString()); int count = namedParameterJdbcTemplate.queryForObject(query, parametersMap, Integer.class); return count > 0; } @Autowired  UserRepository(RoleRepository roleRepository, UserTypeQueryBuilder userTypeQueryBuilder,
                   AddressRepository addressRepository, UserResultSetExtractor userResultSetExtractor,
                   JdbcTemplate jdbcTemplate,
                   NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
UserRepository { public boolean isUserPresent(String userName, String tenantId, UserType userType) { String query = userTypeQueryBuilder.getUserPresentByUserNameAndTenant(); final Map<String, Object> parametersMap = new HashMap<String, Object>(); parametersMap.put("userName", userName); parametersMap.put("tenantId", tenantId); parametersMap.put("userType", userType.toString()); int count = namedParameterJdbcTemplate.queryForObject(query, parametersMap, Integer.class); return count > 0; } @Autowired  UserRepository(RoleRepository roleRepository, UserTypeQueryBuilder userTypeQueryBuilder,
                   AddressRepository addressRepository, UserResultSetExtractor userResultSetExtractor,
                   JdbcTemplate jdbcTemplate,
                   NamedParameterJdbcTemplate namedParameterJdbcTemplate); List<User> findAll(UserSearchCriteria userSearch); boolean isUserPresent(String userName, String tenantId, UserType userType); User create(User user); void update(final User user, User oldUser); void fetchFailedLoginAttemptsByUser(String uuid); List<FailedLoginAttempt> fetchFailedAttemptsByUserAndTime(String uuid, long attemptStartDate); FailedLoginAttempt insertFailedLoginAttempt(FailedLoginAttempt failedLoginAttempt); void resetFailedLoginAttemptsForUser(String uuid); }
UserRepository { public boolean isUserPresent(String userName, String tenantId, UserType userType) { String query = userTypeQueryBuilder.getUserPresentByUserNameAndTenant(); final Map<String, Object> parametersMap = new HashMap<String, Object>(); parametersMap.put("userName", userName); parametersMap.put("tenantId", tenantId); parametersMap.put("userType", userType.toString()); int count = namedParameterJdbcTemplate.queryForObject(query, parametersMap, Integer.class); return count > 0; } @Autowired  UserRepository(RoleRepository roleRepository, UserTypeQueryBuilder userTypeQueryBuilder,
                   AddressRepository addressRepository, UserResultSetExtractor userResultSetExtractor,
                   JdbcTemplate jdbcTemplate,
                   NamedParameterJdbcTemplate namedParameterJdbcTemplate); List<User> findAll(UserSearchCriteria userSearch); boolean isUserPresent(String userName, String tenantId, UserType userType); User create(User user); void update(final User user, User oldUser); void fetchFailedLoginAttemptsByUser(String uuid); List<FailedLoginAttempt> fetchFailedAttemptsByUserAndTime(String uuid, long attemptStartDate); FailedLoginAttempt insertFailedLoginAttempt(FailedLoginAttempt failedLoginAttempt); void resetFailedLoginAttemptsForUser(String uuid);  }