/** * Test method for {@link * org.opensaas.jaudit.dao.hibernate.GenericDaoHibernate#create(java.lang.Object)}. */ @Test public void testCreate() { final DAO dao = getDAOFactory().createUnique(); final MockedGenericDao<DAO> mock = new MockedGenericDao<DAO>(dao); final PK key1 = getPKFactory().createUnique(); EasyMock.expect(mock.getMockSession().save(null)).andReturn(key1); final PK key2 = getPKFactory().createUnique(); EasyMock.expect(mock.getMockSession().save(getVOFactory().createEquivalent())).andReturn(key2); mock.mockReplay(); Assert.assertEquals(key1, dao.create(null)); Assert.assertEquals(key2, dao.create(getVOFactory().createEquivalent())); mock.mockVerify(); }
/** * Test method for {@link * org.opensaas.jaudit.dao.hibernate.GenericDaoHibernate#read(java.io.Serializable)}. */ @Test public void testRead() { final DAO dao = getDAOFactory().createUnique(); final MockedGenericDao<DAO> mock = new MockedGenericDao<DAO>(dao); EasyMock.expect(mock.getMockSession().get(getVOClass(), getPKFactory().createEquivalent())) .andReturn(getVOFactory().createEquivalent()); mock.mockReplay(); Assert.assertEquals( getVOFactory().createEquivalent(), dao.read(getPKFactory().createEquivalent())); mock.mockVerify(); }