Ejemplo n.º 1
0
  @Test
  public void testSetTransactionManager() throws Exception {
    SavedReviewerSearchDAO dao = new SavedReviewerSearchDAO();

    ITransactionManager mgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(mgr);
    assertEquals("Wrong tx manager returned.", mgr, dao.getTransactionManager());
  }
Ejemplo n.º 2
0
  @Test
  public void testUpsert() throws Exception {
    SavedReviewerSearch search = new SavedReviewerSearch();
    SavedReviewerSearchDAO dao =
        EasyMock.createMockBuilder(SavedReviewerSearchDAO.class)
            .withConstructor()
            .addMockedMethod("upsert", Connection.class, SavedReviewerSearch.class)
            .createStrictMock();
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(txMgr);
    Connection mockConn = EasyMock.createStrictMock(Connection.class);
    EasyMock.expect(dao.upsert(mockConn, search)).andReturn(search);

    MockExecutionWithThrow.<Boolean>execute(txMgr, mockConn);
    EasyMock.replay(txMgr, mockConn, dao);
    assertEquals("Wrong search result.", search, dao.upsert(search));
    EasyMock.verify(txMgr, mockConn, dao);
  }
Ejemplo n.º 3
0
  @Test
  public void testDeleteByCustomerId() throws Exception {
    int id = 34;
    SavedReviewerSearchDAO dao =
        EasyMock.createMockBuilder(SavedReviewerSearchDAO.class)
            .withConstructor()
            .addMockedMethod("deleteByCustomerId", Connection.class, Integer.TYPE)
            .createStrictMock();
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(txMgr);
    Connection mockConn = EasyMock.createStrictMock(Connection.class);
    EasyMock.expect(dao.deleteByCustomerId(mockConn, id)).andReturn(34);

    MockExecutionWithThrow.<Boolean>execute(txMgr, mockConn);
    EasyMock.replay(txMgr, mockConn, dao);
    assertEquals("Wrong delete result.", 34, dao.deleteByCustomerId(id));
    EasyMock.verify(txMgr, mockConn, dao);
  }
Ejemplo n.º 4
0
  @Test
  public void testFindByUserId() throws Exception {
    List<String> results = new LinkedList<String>();

    SavedReviewerSearchQuery constraints = new SavedReviewerSearchQuery();
    SavedReviewerSearchDAO dao =
        EasyMock.createMockBuilder(SavedReviewerSearchDAO.class)
            .withConstructor()
            .addMockedMethod("find", Connection.class, SavedReviewerSearchQuery.class)
            .createStrictMock();
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(txMgr);
    Connection mockConn = EasyMock.createStrictMock(Connection.class);
    EasyMock.expect(dao.find(mockConn, constraints)).andReturn(results);

    MockExecutionWithThrow.<Boolean>execute(txMgr, mockConn);
    EasyMock.replay(txMgr, mockConn, dao);
    assertEquals("Wrong searches returned.", results, dao.find(constraints));
    EasyMock.verify(txMgr, mockConn, dao);
  }
Ejemplo n.º 5
0
  @Test
  public void testRead() throws Exception {
    SavedReviewerSearch search = new SavedReviewerSearch();

    int id = 34;
    String name = "mySearch";
    SavedReviewerSearchDAO dao =
        EasyMock.createMockBuilder(SavedReviewerSearchDAO.class)
            .withConstructor()
            .addMockedMethod("read", Connection.class, Integer.TYPE, String.class)
            .createStrictMock();
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(txMgr);
    Connection mockConn = EasyMock.createStrictMock(Connection.class);
    EasyMock.expect(dao.read(mockConn, id, name)).andReturn(search);

    MockExecutionWithThrow.<Boolean>execute(txMgr, mockConn);
    EasyMock.replay(txMgr, mockConn, dao);
    assertEquals("Wrong search item returned.", search, dao.read(id, name));
    EasyMock.verify(txMgr, mockConn, dao);
  }