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

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


  }

  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));
View Full Code Here


  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);
View Full Code Here

  }


  public Image create(final Integer user_id) throws IOException {
    long __id = curId.getAndIncrement();
    Image newInst = new Image(__id, user_id, databases);
    records.put(__id, newInst);
    clearForeignKeyCache();
    return newInst.getCopy();
  }
View Full Code Here



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

  @Override
  public void setUp() {
    dbs = new DatabasesImpl(DATABASE_CONNECTION1);
    postModel = new Post(0, "Test Post", 100l, 1, 0l);
    imageModel = new Image(0, null, dbs);
    userModel = new User(0l, "handle", 0l, 0, 0l, 0l, "bio", null, 0.0, 0.0, true);
    try {
      dbs.getDatabase1().deleteAll();
      dbs.getDatabase1().users().save(userModel);
    } catch (IOException e) {
View Full Code Here

  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

  }

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

        } else {
          stmt.setTimestamp(4, new Timestamp(updated_at));
        }
      }
    }, getInsertStatement(Arrays.<String>asList("title", "posted_at_millis", "user_id", "updated_at")));
    Post newInst = new Post(__id, title, posted_at_millis, user_id, updated_at, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

  public Post create() throws IOException {
    long __id = realCreate(new AttrSetter() {
      public void set(PreparedStatement stmt) throws SQLException {
      }
    }, getInsertStatement(Arrays.<String>asList()));
    Post newInst = new Post(__id, null, null, null, null, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

  }

  @Override
  protected Post instanceFromResultSet(ResultSet rs, Set<Enum> selectedFields) throws SQLException {
    boolean allFields = selectedFields == null || selectedFields.isEmpty();
    return new Post(rs.getLong("id"),
      allFields || selectedFields.contains(Post._Fields.title) ? rs.getString("title") : null,
      allFields || selectedFields.contains(Post._Fields.posted_at_millis) ? getDateAsLong(rs, "posted_at_millis") : null,
      allFields || selectedFields.contains(Post._Fields.user_id) ? getIntOrNull(rs, "user_id") : null,
      allFields || selectedFields.contains(Post._Fields.updated_at) ? getDateAsLong(rs, "updated_at") : null,
      databases
View Full Code Here

TOP

Related Classes of com.rapleaf.jack.test_project.database_1.iface.IUserPersistence

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.