public static JCUser getUserWithAllFieldsFilled() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { JCUser user = getDefaultUser(); DateTime dateTime = new DateTime(); user.setId(1); user.setLanguage(Language.RUSSIAN); user.setPageSize(1); user.setLocation("location"); user.setSignature("signature"); user.setRegistrationDate(dateTime); user.setEnabled(true); user.setAutosubscribe(true); user.setMentioningNotificationsEnabled(true); user.setSendPmNotification(true); user.getContacts().add(ObjectsFactory.getDefaultUserContact()); user.setAvatarLastModificationTime(dateTime); user.setAllForumMarkedAsReadTime(dateTime); user.setAvatar(new byte[]{1}); user.setVersion(1L); user.setBanReason("Ban Reason"); user.setRole("Role"); Method setLastLogin = User.class.getDeclaredMethod("setLastLogin", DateTime.class); Method setEncodedUsername = User.class.getDeclaredMethod("setEncodedUsername", String.class); setLastLogin.setAccessible(true); setEncodedUsername.setAccessible(true); setLastLogin.invoke(user, new DateTime()); setEncodedUsername.invoke(user, "Encoded Username"); return user; }
user.setEnabled(Boolean.parseBoolean(authInfo.get("enabled")));
/** * {@inheritDoc} */ @Override public void activateAccount(String uuid) throws NotFoundException, UserTriesActivatingAccountAgainException { JCUser user = this.getDao().getByUuid(uuid); if (user == null) { LOGGER.warn("Could not activate user with UUID[{}] because it doesn't exist. Either it was removed from DB " + "because too much time passed between registration and activation, or there is an error in link" + ", might be possible the user searches for vulnerabilities in the forum.", uuid); throw new NotFoundException(); } else if (!user.isEnabled()) { Group group = groupDao.getGroupByName(AdministrationGroup.USER.getName()); user.addGroup(group); user.setEnabled(true); this.getDao().saveOrUpdate(user); activateByPlugin(user.getUsername()); LOGGER.info("User [{}] successfully activated", user.getUsername()); } else { LOGGER.warn("User [{}] tried to activate his account again, but that's impossible. Either he clicked the " + "link again, or someone looks for vulnerabilities in the forum.", user.getUsername()); throw new UserTriesActivatingAccountAgainException(); } }
copy.setSignature(user.getSignature()); copy.setRegistrationDate(user.getRegistrationDate()); copy.setEnabled(user.isEnabled()); copy.setAutosubscribe(user.isAutosubscribe()); copy.setMentioningNotificationsEnabled(user.isMentioningNotificationsEnabled());