public static List<Branch> getDefaultBranchList() { List<Branch> branches = new ArrayList<>(); for (Long i = 1L; i <= 3; i++) { branches.add(getDefaultBranch(i)); } return branches; }
public static Section getDefaultSectionWithBranches() { Section section = getDefaultSection(); section.getBranches().addAll(getDefaultBranchList()); return section; }
public static List<ExternalLink> getExternalLinks(int size) { List<ExternalLink> result = new ArrayList<>(); for (int i = 0; i < size; i++) { result.add(getDefaultExternalLink()); } return result; }
public static JCUser getDefaultUserWithGroups() { List<Group> groups = ObjectsFactory.getDefaultGroupList(); for (Group group : groups) { persist(group); } JCUser user = ObjectsFactory.getDefaultUser(); user.setGroups(groups); persist(user); return user; }
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; }
/** * 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 PostVote getDefaultPostVote() { return new PostVote(getDefaultUser()); }
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; }
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 List<Section> getDefaultSectionListWithBranches() { List<Section> sections = new ArrayList<>(); long branchId = 1; for (int i = 0; i < 3; i++) { sections.add(getDefaultSectionWithBranches()); for (org.jtalks.common.model.entity.Branch branch : sections.get(i).getBranches()) { branch.setId(branchId++); } } return sections; }
public static Section getDefaultSectionWithBranch(Branch branch) { Section section = getDefaultSection(); branch.setSection(section); section.addOrUpdateBranch(branch); return section; }
/** * @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 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 Topic getDefaultTopic() { return new Topic(getDefaultUser(), "title", "Discussion"); }
public static Post getDefaultPost() { return persist(new Post(persist(ObjectsFactory.getRandomUser()), "post content")); }
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 UserContact getDefaultUserContact() { UserContactType type = new UserContactType(); UserContact contact = new UserContact("value", type); contact.setOwner(ObjectsFactory.getDefaultUser()); return contact; }
public static Branch getDefaultBranch() { Branch branch = ObjectsFactory.getDefaultBranch(); return persist(branch); }
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 Post getPostWithComments() { Post post = new Post(getDefaultUser(), "test"); post.addComment(new PostComment()); post.addComment(new PostComment()); return post; } }