Package com.rapleaf.jack.test_project.database_1.iface

Examples of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence.save()


  }

  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);

View Full Code Here


  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

  }

  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));
  }

  public void testFindWithFieldsMap() throws IOException, SQLException {
    IUserPersistence users = dbs.getDatabase1().users();
View Full Code Here

  public void testFindWithFieldsMap() throws IOException, SQLException {
    IUserPersistence users = dbs.getDatabase1().users();

    User u1 = users.create("a_handle", 2);
    users.save(u1);

    User u2 = users.create("another_handle", 2);

    Set<User> found = users.find(new HashMap<Enum, Object>() {
      {
View Full Code Here

  public void testFindByField() throws IOException {
    IUserPersistence users = dbs.getDatabase1().users();

    User u1 = users.create("a_handle", 2);
    users.save(u1);

    User u2 = users.create("another_handle", 2);

    Set<User> found = users.findByHandle("a_handle");
    assertEquals(1, found.size());
View Full Code Here

  public void testCreateAssociation() throws Exception {
    IImagePersistence images = dbs.getDatabase1().images();

    Image i1 = images.createDefaultInstance();
    i1.save();

    User u1 = i1.createUser();
    assertEquals(Long.valueOf(u1.getId()), Long.valueOf(i1.getUserId()));
    IUserPersistence users = dbs.getDatabase1().users();
    User userInDb = users.find(i1.getUserId());
View Full Code Here

    User userC = users.createDefaultInstance().setHandle("C").setBio("CEO").setNumPosts(2);
    User userD = users.createDefaultInstance().setHandle("D").setBio("Janitor").setNumPosts(3);
    userA.save();
    userB.save();
    userC.save();
    userD.save();

    Set<User> result;

    // an empty query should return an empty set
    result = users.query().find();
View Full Code Here

    User james = users.createDefaultInstance().setHandle("James").setBio("Surfer").setNumPosts(5).setCreatedAtMillis(3l).setSomeDatetime(1000000l);
    brad.save();
    brandon.save();
    casey.save();
    john.save();
    james.save();

    Set<User> result;

    // Equal To
    result = users.query().whereHandle(equalTo("Brad")).find();
View Full Code Here

    userC.save();
    userD.save();
    userE.save();
    userF.save();
    userG.save();
    userH.save();

    List<User> orderedResult1;
    List<User> orderedResult2;

    // An empty query should return an empty list.
View Full Code Here

    User userA = users.createDefaultInstance().setHandle("AAAA").setBio("Batman").setCreatedAtMillis(1L).setNumPosts(1);
    User userB = users.createDefaultInstance().setHandle("BBBB").setBio("Superman").setCreatedAtMillis(1L);
    User userC = users.createDefaultInstance().setHandle("CCCC").setBio("Spiderman").setCreatedAtMillis(1L);
    userA.save();
    userB.save();
    userC.save();

    Collection<User> result;

    result = users.query().select(User._Fields.handle)
        .whereBio(endsWith("man"))
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.