Package com.rapleaf.jack.test_project.database_1.impl

Examples of com.rapleaf.jack.test_project.database_1.impl.BaseImagePersistenceImpl


    assertEquals(Collections.singleton(u2), users.findAll("handle = 'thoma\"sk'"));
  }

  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


    assertEquals(u1, p1.getUser());
  }

  public void testHasOne() 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);

    IImagePersistence images = dbs.getDatabase1().images();
    Image image = images.create((int)u1.getId());
    assertEquals(u1, image.getUser());
  }
View Full Code Here

    assertEquals(u1, image.getUser());
  }

  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

  }

  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>() {
      {
        put(User._Fields.handle, "a_handle");
        put(User._Fields.some_float, null);
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());
    assertTrue(found.contains(u1));
View Full Code Here

    assertTrue(found.contains(u1));
    assertTrue(found.contains(u2));
  }

  public void testCopyConstructor() {
    User orig = new User(1, "some_handle", 1L, 1, 1L, 1L, "bio", "bio".getBytes(), 1d, 2d, true);
    User copy = new User(orig);

    orig.setHandle("another_handle");
    orig.setNumPosts(2);
    orig.setCreatedAtMillis(2L);
    orig.getSomeBinary()[0] = "z".getBytes()[0];
    orig.setSomeBoolean(false);

    assertEquals("some_handle", copy.getHandle());
    assertEquals(1, copy.getNumPosts());
    assertEquals((Object)1L, copy.getCreatedAtMillis());
    assertTrue(Arrays.equals("bio".getBytes(), copy.getSomeBinary()));
    assertEquals((Object)true, copy.isSomeBoolean());
  }
View Full Code Here

    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());
    assertEquals(u1, userInDb);
    Image imageInDb = images.find(i1.getId());
    assertEquals(i1, imageInDb);
  }
View Full Code Here

  public Set<Image> findByUserId(final Integer value) throws IOException {
    return find(new HashMap<Enum, Object>(){{put(Image._Fields.user_id, value);}});
  }

  public ImageQueryBuilder query() {
    return new ImageQueryBuilder(this);
  }
View Full Code Here

  public Set<Post> findByUpdatedAt(final Long value) throws IOException {
    return find(new HashMap<Enum, Object>(){{put(Post._Fields.updated_at, value);}});
  }

  public PostQueryBuilder query() {
    return new PostQueryBuilder(this);
  }
View Full Code Here

  public Set<User> findBySomeBoolean(final Boolean value) throws IOException {
    return find(new HashMap<Enum, Object>(){{put(User._Fields.some_boolean, value);}});
  }

  public UserQueryBuilder query() {
    return new UserQueryBuilder(this);
  }
View Full Code Here

TOP

Related Classes of com.rapleaf.jack.test_project.database_1.impl.BaseImagePersistenceImpl

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.