public static JCUser getUser(String username, String mail) { JCUser user = new JCUser(username, mail, "user"); persist(user); return user; }
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; } }
public static PluginConfiguration getDefaultPluginConfiguration() { PluginConfiguration configuration = new PluginConfiguration("Default name", true, Collections.<PluginProperty>emptyList()); persist(configuration); return configuration; }
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; }
public static PollItem createDefaultVotingOption() { Poll voting = createDefaultVoting(); persist(voting); PollItem option = new PollItem("First voting option"); voting.addPollOptions(option); return option; }
/** * @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 Topic getDefaultTopic() { JCUser user = persist(ObjectsFactory.getDefaultUser()); Branch branch = ObjectsFactory.getDefaultBranch(); Topic newTopic = new Topic(user, "topic title", "Discussion"); Post post = new Post(user, "post content"); newTopic.addPost(post); branch.addTopic(newTopic); persist(branch); return newTopic; }
public static List<Topic> createAndSaveTopicList(int size) { org.jtalks.jcommune.model.entity.Branch branch = ObjectsFactory.getDefaultBranch(); JCUser user = persist(ObjectsFactory.getDefaultUser()); for (int i = 0; i < size; i++) { Topic topic = new Topic(user, "title" + i, "Discussion"); topic.addPost(new Post(user, "post_context" + i)); branch.addTopic(topic); } persist(branch); return branch.getTopics(); }
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 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; }
/** * Create the Topics with posts. * * @return saved topics */ public static List<Topic> createAndSaveTopicListWithPosts(int size) { org.jtalks.jcommune.model.entity.Branch branch = ObjectsFactory.getDefaultBranch(); JCUser user = persist(ObjectsFactory.getRandomUser()); for (int i = 0; i < size; i++) { Topic topic = new Topic(user, "title" + i, "Discussion"); topic.addPost(new Post(topic.getTopicStarter(), "content")); branch.addTopic(topic); } persist(branch); return branch.getTopics(); }
public static Component getDefaultComponent() { Component component = new Component(); component.setName("component.name"); component.setDescription("component.description"); component.setComponentType(ComponentType.FORUM); List<Property> properties = new ArrayList<>(); Property property1 = new Property("name1", "value1"); property1.setValidationRule("validationRule1"); properties.add(property1); Property property2 = new Property("name2", "value2"); property2.setValidationRule("validationRule2"); properties.add(property2); component.setProperties(properties); persist(component); return component; }
/** * 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; }