Examples of ICommentPersistence


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

  public IDatabases getDBS() {
    return new DatabasesImpl(DATABASE_CONNECTION1);
  }

  public void testFindAllByForeignKeyCache() throws Exception {
    ICommentPersistence comments = dbs.getDatabase1().comments();
    int userId = 1;
    comments.create("comment1", userId, 1, 1);
    comments.create("comment2", userId, 1, 1);
    comments.create("comment3", userId, 1, 1);

    Set<Comment> c1 = comments.findAllByForeignKey("commenter_id", userId);
    Set<Comment> c2 = comments.findAllByForeignKey("commenter_id", userId);
    assertTrue(c1 == c2);
  }
View Full Code Here

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

  }
 
  public void testTransactionRollback() throws IOException {
    dbs.getDatabase1().setAutoCommit(false);

    ICommentPersistence comments = dbs.getDatabase1().comments();
    try {
      comments.create("comment1", 1, 1, 1);
      assertEquals("There should be 1 record during transaction", 1, comments.findAll().size());

      dbs.getDatabase1().rollback();
     
      assertEquals("There should be 0 records after rollback", 0, comments.findAll().size());
    } finally {
      dbs.getDatabase1().rollback();
      dbs.getDatabase1().setAutoCommit(true);
    }
  }
View Full Code Here

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

    User u2 = users.find(user.getId());
    assertEquals(u1, u2);
  }

  public void testFindAllByForeignKey() throws Exception {
    ICommentPersistence comments = dbs.getDatabase1().comments();
    int userId = 1;
    Comment c1 = comments.create("comment1", userId, 1L, 1);
    Comment c2 = comments.create("comment2", userId, 1L, 1);
    Comment c3 = comments.create("comment3", userId, 1L, 1);

    Set<Comment> userComments = comments.findAllByForeignKey("commenter_id", userId);
    assertEquals(3, userComments.size());
    assertTrue(userComments.contains(c1));
    assertTrue(userComments.contains(c2));
    assertTrue(userComments.contains(c3));
  }
View Full Code Here

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

    }
    assertTrue("No User instance equivalent to u1_1 was found!", found);
  }

  public void testFindAllByForeignKeyFromSet() throws Exception {
    ICommentPersistence comments = dbs.getDatabase1().comments();
    comments.deleteAll();
    Long userId = 1L;
    Long otherUserId = 2L;
    Comment c1 = comments.create("comment1", userId.intValue(), 1L, 0);
    Comment c2 = comments.create("comment2", userId.intValue(), 1L, 0);
    Comment c3 = comments.create("comment3", userId.intValue(), 1L, 0);
    Comment c4 = comments.create("comment4", otherUserId.intValue(), 1L, 0);
    Comment c5 = comments.create("comment5", 3, 1L, 0);

    Set<Long> commenterIds = new HashSet<Long>();
    commenterIds.add(userId);
    commenterIds.add(otherUserId);
    Set<Comment> userComments = comments.findAllByForeignKey("commenter_id", commenterIds);
    assertEquals(4, userComments.size());
    assertTrue(userComments.contains(c1));
    assertTrue(userComments.contains(c2));
    assertTrue(userComments.contains(c3));
    assertTrue(userComments.contains(c4));
    assertFalse(userComments.contains(c5));

    Set<Comment> userCommentsSecondQuery = comments.findAllByForeignKey("commenter_id", commenterIds);
    assertEquals(4, userCommentsSecondQuery.size());
    assertTrue(userCommentsSecondQuery.contains(c1));
    assertTrue(userCommentsSecondQuery.contains(c2));
    assertTrue(userCommentsSecondQuery.contains(c3));
    assertTrue(userCommentsSecondQuery.contains(c4));
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.