Examples of PostBuilder


Examples of net.pterodactylus.sone.database.PostBuilder

          /* TODO - mark Sone as bad. */
          logger.log(Level.WARNING, String.format("Downloaded post for Sone %s with missing data! ID: %s, Time: %s, Text: %s", sone, postId, postTime, postText));
          return null;
        }
        try {
          PostBuilder postBuilder = core.postBuilder();
          /* TODO - parse time correctly. */
          postBuilder.withId(postId).from(sone.getId()).withTime(Long.parseLong(postTime)).withText(postText);
          if ((postRecipientId != null) && (postRecipientId.length() == 43)) {
            postBuilder.to(postRecipientId);
          }
          posts.add(postBuilder.build());
        } catch (NumberFormatException nfe1) {
          /* TODO - mark Sone as bad. */
          logger.log(Level.WARNING, String.format("Downloaded post for Sone %s with invalid time: %s", sone, postTime));
          return null;
        }
View Full Code Here

Examples of net.pterodactylus.sone.database.PostBuilder

      String postText = configuration.getStringValue(postPrefix + "/Text").getValue(null);
      if ((postTime == 0) || (postText == null)) {
        logger.log(Level.WARNING, "Invalid post found, aborting load!");
        return;
      }
      PostBuilder postBuilder = postBuilder().withId(postId).from(sone.getId()).withTime(postTime).withText(postText);
      if ((postRecipientId != null) && (postRecipientId.length() == 43)) {
        postBuilder.to(postRecipientId);
      }
      posts.add(postBuilder.build());
    }

    /* load replies. */
    Set<PostReply> replies = new HashSet<PostReply>();
    while (true) {
View Full Code Here

Examples of net.pterodactylus.sone.database.PostBuilder

    checkArgument(text.trim().length() > 0, "text must not be empty");
    if (!sone.isLocal()) {
      logger.log(Level.FINE, String.format("Tried to create post for non-local Sone: %s", sone));
      return null;
    }
    PostBuilder postBuilder = database.newPostBuilder();
    postBuilder.from(sone.getId()).randomId().withTime(time).withText(text.trim());
    if (recipient.isPresent()) {
      postBuilder.to(recipient.get().getId());
    }
    final Post post = postBuilder.build();
    database.storePost(post);
    eventBus.post(new NewPostFoundEvent(post));
    sone.addPost(post);
    touchConfiguration();
    localElementTicker.schedule(new Runnable() {
View Full Code Here

Examples of sagan.blog.PostBuilder

    @Test
    public void blogIndexPostsIncludeLinkToAuthor() throws Exception {
        MemberProfile activeAuthor = MemberProfileBuilder.profile().username("active_author").build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
View Full Code Here

Examples of sagan.blog.PostBuilder

    public void blogIndexPostsDoNotIncludeLinksToHiddenAuthors() throws Exception {
        MemberProfile activeAuthor =
                MemberProfileBuilder.profile().name("Hidden Author").username("hidden_author").hidden(true).build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertTrue(html.select("a.author").isEmpty());
View Full Code Here

Examples of sagan.blog.PostBuilder

    @Test
    public void blogPostPageIncludesLinkToAuthor() throws Exception {
        MemberProfile activeAuthor = MemberProfileBuilder.profile().username("active_author").build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog/" + post.getPublicSlug())).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
View Full Code Here

Examples of sagan.blog.PostBuilder

    public void blogPostPageDoesNotIncludeLinkToHiddenAuthors() throws Exception {
        MemberProfile activeAuthor =
                MemberProfileBuilder.profile().name("Hidden Author").username("hidden_author").hidden(true).build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog/" + post.getPublicSlug())).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertTrue(html.select("a.author").isEmpty());
View Full Code Here

Examples of sagan.blog.PostBuilder

    private void createPosts(int numPostsToCreate) {
        Calendar calendar = Calendar.getInstance();
        List<Post> posts = new ArrayList<>();
        for (int postNumber = 1; postNumber <= numPostsToCreate; postNumber++) {
            calendar.set(2013, 10, postNumber);
            Post post = new PostBuilder().title("This week in Spring - November " + postNumber + ", 2013")
                    .rawContent("Raw content")
                    .renderedContent("Html content")
                    .renderedSummary("Html summary")
                    .createdAt(calendar.getTime())
                    .build();
View Full Code Here

Examples of sagan.blog.PostBuilder

    @Test
    public void givenPostContentThatIsEqualToSummary_blogIndexShouldNotShow_ReadMore() throws Exception {
        String summary = "A blog post string that is longish.";
        String content = summary;
        Post post = new PostBuilder().renderedContent(content).renderedSummary(summary).build();

        postRepository.save(post);

        MvcResult result = mockMvc.perform(get("/blog")).andReturn();
        String response = result.getResponse().getContentAsString();
View Full Code Here

Examples of sagan.blog.PostBuilder

        String summary = "A blog post string that is longish.";
        String content = "";
        for (int i = 0; i < 50; i++) {
            content = content + summary;
        }
        Post post = new PostBuilder().renderedContent(content).renderedSummary(summary).build();

        postRepository.save(post);

        MvcResult result = mockMvc.perform(get("/blog")).andReturn();
        String response = result.getResponse().getContentAsString();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.