public static PollItem createDefaultVotingOption() { Poll voting = createDefaultVoting(); persist(voting); PollItem option = new PollItem("First voting option"); voting.addPollOptions(option); return option; }
public static LastReadPost getDefaultLastReadPost() { Topic topic = getDefaultTopic(); JCUser user = topic.getTopicStarter(); return new LastReadPost(user, topic, new DateTime()); }
public static PostVote getDefaultPostVote() { return new PostVote(getDefaultUser()); }
/** * @return group with randoms users */ public static Group groupWithUsers(int count) { List<JCUser> users = usersListOf(count); Group group = ObjectsFactory.getRandomGroup(); group.setUsers((List<User>) (Object) users); return persist(group); }
public static JCUser getUser(String username, String mail) { JCUser user = new JCUser(username, mail, "user"); persist(user); return user; }
public static PostComment getModifiedPostComment() { PostComment comment3 = new PostComment(); comment3.setAuthor(persist(ObjectsFactory.getRandomUser())); comment3.setBody("Comment3 body"); comment3.setCreationDate(new DateTime(3)); comment3.setPost(getDefaultPost()); comment3.setUserChanged(persist(ObjectsFactory.getRandomUser())); comment3.setModificationDate(new DateTime(4)); return comment3; }
public static Poll createDefaultVoting() { Topic topic = getDefaultTopic(); Poll poll = new Poll("New voting"); List<PollItem> pollItems = new ArrayList<>(); pollItems.add(new PollItem("item1")); pollItems.add(new PollItem("item2")); pollItems.add(new PollItem("item3")); poll.setPollItems(pollItems); topic.setPoll(poll); poll.setTopic(topic); persist(topic); return poll; }
public static JCUser getDefaultUser() { return getUser("user", "email@user.org"); }
public static List<JCUser> usersListOf(int n) { List<JCUser> result = new ArrayList<>(n); for (int i = 0; i < n; i++) { result.add(persist(ObjectsFactory.getRandomUser())); } return result; } }
/** * Return first code review comment from persisted code review. * * @return first code review comment from persisted code review. */ public static PostComment getDefaultPostComment() { PostComment comment2 = new PostComment(); comment2.setAuthor(persist(ObjectsFactory.getRandomUser())); comment2.setBody("Comment2 body"); comment2.setCreationDate(new DateTime(2)); comment2.setPost(getDefaultPost()); return comment2; }
public static PluginConfiguration getDefaultPluginConfiguration() { PluginConfiguration configuration = new PluginConfiguration("Default name", true, Collections.<PluginProperty>emptyList()); persist(configuration); return configuration; }
public static List<Post> createAndSavePostList(int size) { List<Post> posts = new ArrayList<>(); Topic topic = PersistedObjectsFactory.getDefaultTopic(); JCUser author = topic.getTopicStarter(); for (int i = 0; i < size - 1; i++) { Post newPost = new Post(author, "content " + i); topic.addPost(newPost); posts.add(newPost); session.save(newPost); } session.save(topic); return posts; }
public static Group groupWithUsers(String name) { Group group = new Group(name, "default-group-description"); group.getUsers().add(getDefaultUser()); session.save(group); session.flush(); session.evict(group); return group; }
public static Branch getDefaultBranch() { Branch branch = ObjectsFactory.getDefaultBranch(); return persist(branch); }
/** * Create the PrivateMessage with filled required fields. * * @return ready to save instance */ public static PrivateMessage getDefaultPrivateMessage() { JCUser userTo = persist(ObjectsFactory.getUser("UserTo", "mail2@mail.com")); JCUser userFrom = persist(ObjectsFactory.getUser("UserFrom", "mail1@mail.com")); return new PrivateMessage(userTo, userFrom, "Message title", "Private message body"); }
/** * Create and persist one single message. * * @param status message status. * @return saved pm. */ public static PrivateMessage createAndSaveMessage(PrivateMessageStatus status, JCUser userTo, JCUser userFrom) { PrivateMessage pm = new PrivateMessage(userTo, userFrom, "Message title", "Private message body"); pm.setStatus(status); persist(pm); return pm; }
public static PluginProperty getDefaultPluginConfigurationProperty() { PluginProperty property = new PluginProperty("Property", PluginProperty.Type.BOOLEAN, "true"); PluginConfiguration configuration = new PluginConfiguration("Default name", true, Arrays.asList(property)); property.setPluginConfiguration(configuration); persist(configuration); return property; }
public static TopicDraft getDefaultTopicDraft() { JCUser user = persist(ObjectsFactory.getDefaultUser()); Branch branch = persist(ObjectsFactory.getDefaultBranch()); TopicDraft newTopicDraft = new TopicDraft(user, RandomStringUtils.random(5), RandomStringUtils.random(15)); newTopicDraft.setTopicType(TopicTypeName.DISCUSSION.getName()); newTopicDraft.setBranchId(branch.getId()); persist(newTopicDraft); return newTopicDraft; }