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

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


    }
    Boolean use_mock = (Boolean)env_info.get("use_mock_db");
    if (use_mock != null && use_mock) {
      this.database1 = mockDatabases.getDatabase1();
    } else {
      this.database1 = new Database1Impl(new DatabaseConnection("database1"), this);
    }
  }
View Full Code Here


public class MockDatabasesImpl implements IDatabases {
  private final IDatabase1 database1;

  public MockDatabasesImpl() {
    this.database1 = new MockDatabase1Impl(this);
  }
View Full Code Here

    assertNotNull("Post should be found from db by bigint id", foundPost);

    foundPost = posts.find(postId);
    assertNotNull("Post should be found in cache by bigint id", foundPost);

    Comment c = new Comment(1, "comment content", 1, postId, System.currentTimeMillis(), getDBS());
    assertNotNull("Post should be findable by foreign key", c.getPost());
  }
View Full Code Here

  }

  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

          stmt.setInt(2, commenter_id);
          stmt.setLong(3, commented_on_id);
          stmt.setTimestamp(4, new Timestamp(created_at));
      }
    }, getInsertStatement(Arrays.<String>asList("content", "commenter_id", "commented_on_id", "created_at")));
    Comment newInst = new Comment(__id, content, commenter_id, commented_on_id, created_at, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

          stmt.setInt(1, commenter_id);
          stmt.setLong(2, commented_on_id);
          stmt.setTimestamp(3, new Timestamp(created_at));
      }
    }, getInsertStatement(Arrays.<String>asList("commenter_id", "commented_on_id", "created_at")));
    Comment newInst = new Comment(__id, null, commenter_id, commented_on_id, created_at, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
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

TOP

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

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.