@Test(expected = CustomException.class) public void test_should_throw_exception_when_role_does_not_exist_for_given_role_code() { final String roleCode = "roleCode1"; final org.egov.user.domain.model.Role domainRole = org.egov.user.domain.model.Role.builder().name(roleCode) .build(); User domainUser = User.builder() .tenantId("ap.p") .roles(Collections.singleton(domainRole)).build(); userRepository.create(domainUser); }
public User create(User user) { validateAndEnrichRoles(Collections.singletonList(user)); final Long newId = getNextSequence(); user.setId(newId); user.setUuid(UUID.randomUUID().toString()); user.setCreatedDate(new Date()); user.setLastModifiedDate(new Date()); user.setCreatedBy(user.getLoggedInUserId()); user.setLastModifiedBy(user.getLoggedInUserId()); final User savedUser = save(user); if (user.getRoles().size() > 0) { saveUserRoles(user); } final Address savedCorrespondenceAddress = saveAddress(user.getCorrespondenceAddress(), savedUser.getId(), savedUser.getTenantId()); final Address savedPermanentAddress = saveAddress(user.getPermanentAddress(), savedUser.getId(), savedUser.getTenantId()); savedUser.setPermanentAddress(savedPermanentAddress); savedUser.setCorrespondenceAddress(savedCorrespondenceAddress); return savedUser; }
UserRepository { public User create(User user) { validateAndEnrichRoles(Collections.singletonList(user)); final Long newId = getNextSequence(); user.setId(newId); user.setUuid(UUID.randomUUID().toString()); user.setCreatedDate(new Date()); user.setLastModifiedDate(new Date()); user.setCreatedBy(user.getLoggedInUserId()); user.setLastModifiedBy(user.getLoggedInUserId()); final User savedUser = save(user); if (user.getRoles().size() > 0) { saveUserRoles(user); } final Address savedCorrespondenceAddress = saveAddress(user.getCorrespondenceAddress(), savedUser.getId(), savedUser.getTenantId()); final Address savedPermanentAddress = saveAddress(user.getPermanentAddress(), savedUser.getId(), savedUser.getTenantId()); savedUser.setPermanentAddress(savedPermanentAddress); savedUser.setCorrespondenceAddress(savedCorrespondenceAddress); return savedUser; } }
UserRepository { public User create(User user) { validateAndEnrichRoles(Collections.singletonList(user)); final Long newId = getNextSequence(); user.setId(newId); user.setUuid(UUID.randomUUID().toString()); user.setCreatedDate(new Date()); user.setLastModifiedDate(new Date()); user.setCreatedBy(user.getLoggedInUserId()); user.setLastModifiedBy(user.getLoggedInUserId()); final User savedUser = save(user); if (user.getRoles().size() > 0) { saveUserRoles(user); } final Address savedCorrespondenceAddress = saveAddress(user.getCorrespondenceAddress(), savedUser.getId(), savedUser.getTenantId()); final Address savedPermanentAddress = saveAddress(user.getPermanentAddress(), savedUser.getId(), savedUser.getTenantId()); savedUser.setPermanentAddress(savedPermanentAddress); savedUser.setCorrespondenceAddress(savedCorrespondenceAddress); return savedUser; } @Autowired  UserRepository(RoleRepository roleRepository, UserTypeQueryBuilder userTypeQueryBuilder,
                   AddressRepository addressRepository, UserResultSetExtractor userResultSetExtractor,
                   JdbcTemplate jdbcTemplate,
                   NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
UserRepository { public User create(User user) { validateAndEnrichRoles(Collections.singletonList(user)); final Long newId = getNextSequence(); user.setId(newId); user.setUuid(UUID.randomUUID().toString()); user.setCreatedDate(new Date()); user.setLastModifiedDate(new Date()); user.setCreatedBy(user.getLoggedInUserId()); user.setLastModifiedBy(user.getLoggedInUserId()); final User savedUser = save(user); if (user.getRoles().size() > 0) { saveUserRoles(user); } final Address savedCorrespondenceAddress = saveAddress(user.getCorrespondenceAddress(), savedUser.getId(), savedUser.getTenantId()); final Address savedPermanentAddress = saveAddress(user.getPermanentAddress(), savedUser.getId(), savedUser.getTenantId()); savedUser.setPermanentAddress(savedPermanentAddress); savedUser.setCorrespondenceAddress(savedCorrespondenceAddress); return savedUser; } @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 User create(User user) { validateAndEnrichRoles(Collections.singletonList(user)); final Long newId = getNextSequence(); user.setId(newId); user.setUuid(UUID.randomUUID().toString()); user.setCreatedDate(new Date()); user.setLastModifiedDate(new Date()); user.setCreatedBy(user.getLoggedInUserId()); user.setLastModifiedBy(user.getLoggedInUserId()); final User savedUser = save(user); if (user.getRoles().size() > 0) { saveUserRoles(user); } final Address savedCorrespondenceAddress = saveAddress(user.getCorrespondenceAddress(), savedUser.getId(), savedUser.getTenantId()); final Address savedPermanentAddress = saveAddress(user.getPermanentAddress(), savedUser.getId(), savedUser.getTenantId()); savedUser.setPermanentAddress(savedPermanentAddress); savedUser.setCorrespondenceAddress(savedCorrespondenceAddress); return savedUser; } @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);  }