public void testUserProfile() throws Exception { String userName = "******"; UserProfile userProfile = createdUserProfile(userName); // save UserProfile forumService_.saveUserProfile(userProfile, true, true); // getUserInfo userProfile = forumService_.getUserInfo(userName); assertNotNull("Get info UserProfile is null", userProfile); // get Default userProfile = forumService_.getDefaultUserProfile(userName, ""); assertNotNull("Get default UserProfile is null", userProfile); // getUserInformations userProfile = forumService_.getUserInformations(userProfile); assertNotNull("Get informations UserProfile is null", userProfile); // getUserSettingProfile userProfile = forumService_.getUserSettingProfile(userName); assertNotNull("Get Setting UserProfile is not null", userProfile); // saveUserSettingProfile assertEquals("Default AutoWatchMyTopics is false", userProfile.getIsAutoWatchMyTopics(), false); userProfile.setIsAutoWatchMyTopics(true); forumService_.saveUserSettingProfile(userProfile); userProfile = forumService_.getUserSettingProfile(userName); assertEquals( "Edit AutoWatchMyTopics and can't save this property. AutoWatchMyTopics is false", userProfile.getIsAutoWatchMyTopics(), true); // }
private static String getFormatDate(int dateFormat, Date myDate) { if (myDate == null) return ""; String format = (dateFormat == DateFormat.LONG) ? "EEE,MMM dd,yyyy" : "MM/dd/yyyy"; try { String userName = getCurrentUser(); if (!isFieldEmpty(userName)) { org.exoplatform.forum.service.ForumService forumService = (org.exoplatform.forum.service.ForumService) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(org.exoplatform.forum.service.ForumService.class); org.exoplatform.forum.service.UserProfile profile = forumService.getUserSettingProfile(userName); format = (dateFormat == DateFormat.LONG) ? profile.getLongDateFormat() : profile.getShortDateFormat(); } } catch (Exception e) { log.debug("No forum settings found for date format. Will use format " + format); } format = format.replaceAll("D", "E"); return TimeConvertUtils.getFormatDate(myDate, format); }