@Test public void testAddQuestion() throws Exception { final User user = UserServiceFactory.getUserService().getCurrentUser(); String tags = visa.getName() + "," + visa2.getName(); String categories = europe.getWebsafeId() + "," + budgetTravel.getWebsafeId(); PostEntity postEntity = postController.insertQuestionPost("Test content", tags, categories, Optional.absent(), Optional.of(10), user); assertNotNull(postEntity.getKey()); assertEquals("Test content", postEntity.getContent()); assertEquals(0, postEntity.getBounty()); Set<String> tagSet = new HashSet<>(); tagSet.add(visa.getName()); tagSet.add(visa2.getName()); assertEquals(tagSet, postEntity.getTags()); assertEquals(null, postEntity.getAcceptedCommentKey()); assertEquals(false, postEntity.isCommented()); assertEquals("Test user", postEntity.getUsername()); assertEquals(new Link("Test avatar"), postEntity.getAvatarUrl()); assertEquals(Vote.Direction.DEFAULT, postEntity.getDir()); Set<String> categorySet = new HashSet<>(); categorySet.add(budgetTravel.getName()); categorySet.add(europe.getName()); Tracker tracker = ofy().load().key(Tracker.createKey(Key.create(user.getUserId()))).now(); assertNotNull(tracker); assertEquals(120, tracker.getPoints()); assertEquals(2, tracker.getBounties()); }
public PostEntity insertQuestionPost(String content, String tags, String groupId, Optional<String> mediaIds, Optional<Integer> bounty, User user) { final PostEntity.Type type = mediaIds.isPresent() ? PostEntity.Type.RICH_POST : PostEntity.Type.TEXT_POST; return insertPost(Optional.of(content), tags, groupId, Optional.absent(), mediaIds, bounty, type, user); }
PostController extends Controller { public PostEntity insertQuestionPost(String content, String tags, String groupId, Optional<String> mediaIds, Optional<Integer> bounty, User user) { final PostEntity.Type type = mediaIds.isPresent() ? PostEntity.Type.RICH_POST : PostEntity.Type.TEXT_POST; return insertPost(Optional.of(content), tags, groupId, Optional.absent(), mediaIds, bounty, type, user); } }
PostController extends Controller { public PostEntity insertQuestionPost(String content, String tags, String groupId, Optional<String> mediaIds, Optional<Integer> bounty, User user) { final PostEntity.Type type = mediaIds.isPresent() ? PostEntity.Type.RICH_POST : PostEntity.Type.TEXT_POST; return insertPost(Optional.of(content), tags, groupId, Optional.absent(), mediaIds, bounty, type, user); }  }
PostController extends Controller { public PostEntity insertQuestionPost(String content, String tags, String groupId, Optional<String> mediaIds, Optional<Integer> bounty, User user) { final PostEntity.Type type = mediaIds.isPresent() ? PostEntity.Type.RICH_POST : PostEntity.Type.TEXT_POST; return insertPost(Optional.of(content), tags, groupId, Optional.absent(), mediaIds, bounty, type, user); }  PostEntity getPost(String postId, User user); PostEntity insertQuestionPost(String content, String tags, String groupId,
      Optional<String> mediaIds, Optional<Integer> bounty, User user); PostEntity insertBlogPost(String title, String content, String tags, String groupId,
      Optional<String> mediaIds, Optional<Integer> bounty, User user); PostEntity insertImagePost(String tags, String groupId, Optional<String> mediaIds,
      Optional<Integer> bounty, User user); PostEntity updatePost(String postId, Optional<String> title, Optional<String> content,
      Optional<Integer> bounty, Optional<String> tags, Optional<String> mediaIds); void deletePost(String postId); CollectionResponse<PostEntity> listPosts(Optional<String> userId,
      Optional<PostSorter> sorter, Optional<String> groupId, Optional<String> tags,
      Optional<Integer> limit, Optional<String> cursor, Optional<PostEntity.Type> postType,
      User user); CollectionResponse<PostEntity> listMediaPosts(Optional<Integer> limit,
      Optional<String> cursor, User user); void reportPost(String postId, User user); }
PostController extends Controller { public PostEntity insertQuestionPost(String content, String tags, String groupId, Optional<String> mediaIds, Optional<Integer> bounty, User user) { final PostEntity.Type type = mediaIds.isPresent() ? PostEntity.Type.RICH_POST : PostEntity.Type.TEXT_POST; return insertPost(Optional.of(content), tags, groupId, Optional.absent(), mediaIds, bounty, type, user); }  PostEntity getPost(String postId, User user); PostEntity insertQuestionPost(String content, String tags, String groupId,
      Optional<String> mediaIds, Optional<Integer> bounty, User user); PostEntity insertBlogPost(String title, String content, String tags, String groupId,
      Optional<String> mediaIds, Optional<Integer> bounty, User user); PostEntity insertImagePost(String tags, String groupId, Optional<String> mediaIds,
      Optional<Integer> bounty, User user); PostEntity updatePost(String postId, Optional<String> title, Optional<String> content,
      Optional<Integer> bounty, Optional<String> tags, Optional<String> mediaIds); void deletePost(String postId); CollectionResponse<PostEntity> listPosts(Optional<String> userId,
      Optional<PostSorter> sorter, Optional<String> groupId, Optional<String> tags,
      Optional<Integer> limit, Optional<String> cursor, Optional<PostEntity.Type> postType,
      User user); CollectionResponse<PostEntity> listMediaPosts(Optional<Integer> limit,
      Optional<String> cursor, User user); void reportPost(String postId, User user);  }