Package models

Examples of models.Post


    assertNull(post.getUser());
  }

  public void testDelete() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    Post post = posts.create(null, 10L, 1, 0l);
    long id = post.getId();
    posts.delete(id);
    assertNull(posts.find(id));
  }
View Full Code Here


    assertNull(posts.find(id));
  }

  public void testSave() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    Post post = posts.create(null, 10L, 1, 0l);
    long id = post.getId();
    post.setPostedAtMillis(20L);
    dbs.getDatabase1().posts().save(post);
    assertEquals(Long.valueOf(20), posts.find(id).getPostedAtMillis());
  }
View Full Code Here

    assertEquals(Long.valueOf(20), posts.find(id).getPostedAtMillis());
  }

  public void testInsertOnSave() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    Post post = new Post(50, "Post", 20L, 100, 0l, dbs);
    posts.save(post);
    assertEquals(post, posts.find(50));
  }
View Full Code Here

    Image imageInDb = images.find(i1.getId());
    assertEquals(i1, imageInDb);
  }

  public void testComparable() {
    Post post1 = new Post(50, "Post1", 20L, 100, 0l, dbs);
    Post post2 = new Post(70, "Post2", 20L, 100, 0l, dbs);
    Post post3 = new Post(71, "Post2", 20L, 100, 0l, dbs);
    Post post4 = new Post(100, "Post2", 20L, 100, 0l, dbs);

    assertTrue(post1.compareTo(post2) < 0);

    List<Post> posts = new ArrayList<Post>();
    posts.add(post2);
View Full Code Here

  }


  public Post create(final String title, final Long posted_at_millis, final Integer user_id, final Long updated_at) throws IOException {
    long __id = curId.getAndIncrement();
    Post newInst = new Post(__id, title, posted_at_millis, user_id, updated_at, databases);
    records.put(__id, newInst);
    clearForeignKeyCache();
    return newInst.getCopy();
  }
View Full Code Here



  public Post create() throws IOException {
    long __id = curId.getAndIncrement();
    Post newInst = new Post(__id, null, null, null, null, databases);
    records.put(__id, newInst);
    clearForeignKeyCache();
    return newInst.getCopy();
  }
View Full Code Here

  }
 
 
    public static void index() {
     
       Post frontPost = Post.find("order by postedAt desc").first();
         List<Post> olderPosts = Post.find(
             "order by postedAt desc"
         ).from(1).fetch(10);
         render(frontPost, olderPosts);
     
View Full Code Here

     
    }
   
   
    public static void show(Long id) {
        Post post = Post.findById(id);
        String randomID = Codec.UUID();
        render(post, randomID);
    }
View Full Code Here

            @Required(message="Author is required") String author,
            @Required(message="A message is required") String content,
            @Required(message="Please type the code") String code,
            String randomID)
    {
        Post post = Post.findById(postId);
        validation.equals(
            code, Cache.get(randomID)
        ).message("Invalid code. Please type it again");
        if(validation.hasErrors()) {
            render("Application/show.html", post, randomID);
        }
        post.addComment(author, content);
        flash.success("Thanks for posting %s", author);
        Cache.delete(randomID);
        show(postId);
    }
View Full Code Here

    public void createPost() {
        // Create a new user and save it
        User bob = new User("bob@gmail.com", "secret", "Bob").save();

        // Create a new post
        new Post(bob, "My first post", "Hello world").save();

        // Test that the post has been created
        assertEquals(1, Post.count());

        // Retrieve all post created by bob
        List<Post> bobPosts = Post.find("byAuthorEmail", bob.email).asList();

        // Tests
        assertEquals(1, bobPosts.size());
        Post firstPost = bobPosts.get(0);
        assertNotNull(firstPost);
        assertEquals(bob.email, firstPost.authorEmail);
        assertEquals("My first post", firstPost.title);
        assertEquals("Hello world", firstPost.content);
        assertNotNull(firstPost.postedAt);
View Full Code Here

TOP

Related Classes of models.Post

Copyright © 2018 www.massapicom. 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.