Package com.rapleaf.jack.test_project.database_1

Examples of com.rapleaf.jack.test_project.database_1.BaseDatabase1Fixtures


    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


    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

    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 void testBasicQuery(IDatabases dbs) throws IOException, SQLException {

    IUserPersistence users = dbs.getDatabase1().users();
    users.deleteAll();

    User userA = users.createDefaultInstance().setHandle("A").setBio("Trader").setNumPosts(1);
    User userB = users.createDefaultInstance().setHandle("B").setBio("Trader").setNumPosts(2);
    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

  }


  public User create(final String handle, final Long created_at_millis, final int num_posts, final Long some_date, final Long some_datetime, final String bio, final byte[] some_binary, final Double some_float, final Double some_decimal, final Boolean some_boolean) throws IOException {
    long __id = curId.getAndIncrement();
    User newInst = new User(__id, handle, created_at_millis, num_posts, some_date, some_datetime, bio, some_binary, some_float, some_decimal, some_boolean, databases);
    records.put(__id, newInst);
    clearForeignKeyCache();
    return newInst.getCopy();
  }
View Full Code Here



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

  public void testQueryOperators(IDatabases dbs) throws IOException, SQLException {

    IUserPersistence users = dbs.getDatabase1().users();
    users.deleteAll();

    User brad = users.createDefaultInstance().setHandle("Brad").setBio("Soccer player").setNumPosts(1).setCreatedAtMillis(1l);
    User brandon = users.createDefaultInstance().setHandle("Brandon").setBio("Formula 1 driver").setNumPosts(2).setCreatedAtMillis(1l).setSomeDatetime(0l);
    User casey = users.createDefaultInstance().setHandle("Casey").setBio("Singer").setNumPosts(2).setCreatedAtMillis(2l);
    User john = users.createDefaultInstance().setHandle("John").setBio("Ice skater").setNumPosts(3).setCreatedAtMillis(2l);
    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

TOP

Related Classes of com.rapleaf.jack.test_project.database_1.BaseDatabase1Fixtures

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.