@Test public void should_create_dao_return_implementation() throws Exception { DummyDAO daoInstance = client.getDAO(DummyDAO.class); Assertions.assertThat(daoInstance).isNotNull(); }
@Test public void should_create_dao_throw_BusinessObjectDaoCreationException_if_daoImpl_has_no_constructor_with_session() throws Exception { Mockito.doReturn(DummyDAOWithoutConstructorImpl.class).when(client).loadClass(Matchers.any(Class.class)); expectedEx.expect(BusinessObjectDaoCreationException.class); expectedEx.expectMessage(""); client.getDAO(DummyDAO.class); }
@Test public void should_create_dao_throw_BusinessObjectDaoCreationException_if_daoImpl_not_in_classpath() throws Exception { Mockito.doThrow(ClassNotFoundException.class).when(client).loadClass(BusinessObjectDAO.class); expectedEx.expect(BusinessObjectDaoCreationException.class); expectedEx.expectMessage(""); client.getDAO(BusinessObjectDAO.class); }
@Test public void should_create_dao_throw_IllegalArgmumentException_for_null_interface() throws Exception { expectedEx.expect(IllegalArgumentException.class); expectedEx.expectMessage("daoInterface is null"); client.getDAO(null); }
@Test public void should_create_dao_throw_IllegalArgmumentException_if_daoInterface_is_not_an_interface() throws Exception { expectedEx.expect(IllegalArgumentException.class); expectedEx.expectMessage("DummyDAOImpl is not an interface"); client.getDAO(DummyDAOImpl.class); }