Examples of IPostPersistence


Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    User bryand = users.create("bryand", t0, 5, t1, t2, "this is a relatively long string", someBinary, 1.2d, 3.4d, true);
    verifyCreatedUser(users, t0, t1, t2, someBinary, bryand);
  }

  public void testCreateWithBigintPrimaryKey() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    long postId = Integer.MAX_VALUE * 2l;
    assertTrue(posts.save(new Post(postId, "post title", System.currentTimeMillis(), 1, System.currentTimeMillis())));

    posts.clearCacheById(postId);
    Post foundPost = posts.find(postId);
    assertNotNull("Post should be found from db by bigint id", foundPost);

    foundPost = posts.find(postId);
    assertNotNull("Post should be found in cache by bigint id", foundPost);

    Comment c = new Comment(1, "comment content", 1, postId, System.currentTimeMillis(), getDBS());
    assertNotNull("Post should be findable by foreign key", c.getPost());
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

  public void testBelongsTo() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    User u1 = users.create("bryand", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);

    IPostPersistence posts = dbs.getDatabase1().posts();
    Post p1 = posts.create("title", System.currentTimeMillis(), (int)u1.getId(), 0l);
    assertEquals(u1, p1.getUser());
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

  public void testHasMany() throws Exception {
    IUserPersistence users = dbs.getDatabase1().users();
    User u1 = users.create("bryand", System.currentTimeMillis(), 5, System.currentTimeMillis() + 10, System.currentTimeMillis() + 20, "this is a relatively long string", new byte[]{5, 4, 3, 2, 1}, 1.2d, 3.4d, true);

    IPostPersistence posts = dbs.getDatabase1().posts();
    Post p1 = posts.create("title1", System.currentTimeMillis(), (int)u1.getId(), 0l);
    Post p2 = posts.create("title2", System.currentTimeMillis(), (int)u1.getId(), 0l);
    Post p3 = posts.create("title3", System.currentTimeMillis(), (int)u1.getId(), 0l);

    assertEquals(new HashSet<Post>(Arrays.asList(p1, p2, p3)), u1.getPosts());
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    assertEquals(new HashSet<Post>(Arrays.asList(p1, p2, p3)), u1.getPosts());
  }

  public void testFindByForeignKey() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    Post post = posts.create("title", 0L, 1, 0l);

    assertTrue(posts.findAllByForeignKey("user_id", -1).isEmpty());
    assertEquals(Collections.singleton(post), posts.findAllByForeignKey("user_id", 1));
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    assertTrue(posts.findAllByForeignKey("user_id", -1).isEmpty());
    assertEquals(Collections.singleton(post), posts.findAllByForeignKey("user_id", 1));
  }

  public void testSetReturnsModifiedModel() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    Post post = posts.create(null, 10L, 1, 0l);
    assertNotNull(post);
    Post postCopy = post.setUserId(null).setPostedAtMillis(20L);
    assertNull(postCopy.getUserId());
    assertEquals(Long.valueOf(20), post.getPostedAtMillis());
    assertEquals(post, postCopy);
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    assertEquals(Long.valueOf(20), post.getPostedAtMillis());
    assertEquals(post, postCopy);
  }

  public void testNullTreatment() throws Exception {
    IPostPersistence posts = dbs.getDatabase1().posts();
    Post post = posts.create(null, 10L, 1, 0l);
    assertNotNull(post);
    post.setUserId(null);
    posts.save(post);
    post = posts.find(post.getId());
    assertNull(post.getUserId());
    assertNull(post.getUser());
  }
View Full Code Here

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    assertNull(post.getUserId());
    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

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    posts.delete(id);
    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

Examples of com.rapleaf.jack.test_project.database_1.iface.IPostPersistence

    dbs.getDatabase1().posts().save(post);
    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
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.