Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardContentDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardContentDAO.java,v diff -u -r1.1 -r1.2 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardContentDAO.java 7 Jun 2005 05:50:05 -0000 1.1 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardContentDAO.java 22 Jun 2005 06:17:30 -0000 1.2 @@ -21,17 +21,19 @@ package org.lamsfoundation.lams.tool.noticeboard.dao.hibernate; +import java.util.List; +import java.lang.Long; + import net.sf.hibernate.HibernateException; import net.sf.hibernate.Session; - import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardContentDAO; import org.springframework.orm.hibernate.HibernateCallback; import org.springframework.orm.hibernate.support.HibernateDaoSupport; /** * @author mtruong - * Hibernate implementation for database access for the noticeboard tool. + * Hibernate implementation for database access to Noticeboard content for the noticeboard tool. */ public class NoticeboardContentDAO extends HibernateDaoSupport implements INoticeboardContentDAO { @@ -41,22 +43,50 @@ + "nb.nbSessions session where session.nbSessionId=:sessionId"; - /** Finds a noticeboard by its noticeboard id and returns - * null if not found + + /** + *

Return the persistent instance of a NoticeboardContent + * with the given identifier uid, returns null if not found.

+ * + * @param uid an identifier for the NoticeboardContent instance. + * @return the persistent instance of a NoticeboardContent or null if not found */ - - public NoticeboardContent getNbContentById(Long nbContentId) + public NoticeboardContent getNbContentByUID(Long uid) { return (NoticeboardContent) this.getHibernateTemplate() - .get(NoticeboardContent.class, nbContentId); + .get(NoticeboardContent.class, uid); } - public NoticeboardContent loadNbContentById(Long nbContentId) + /** + *

Return the persistent instance of a NoticeboardContent + * with the given tool content id nbContentId, + * returns null if not found.

+ * + * @param nbContentId The tool content id + * @return the persistent instance of a NoticeboardContent or null if not found. + */ + public NoticeboardContent findNbContentById(Long nbContentId) { - return (NoticeboardContent) this.getHibernateTemplate() - .load(NoticeboardContent.class, nbContentId); + String query = "from NoticeboardContent as nb where nb.nbContentId = ?"; + List content = getHibernateTemplate().find(query,nbContentId); + + if(content!=null && content.size() == 0) + { + return null; + } + else + { + return (NoticeboardContent)content.get(0); + } + } - + /** + *

Returns the persistent instance of NoticeboardContent + * with the given tool session id nbSessionId, returns null if not found. + * + * @param nbSessionId The tool session id + * @return a persistent instance of NoticeboardContent or null if not found. + */ public NoticeboardContent getNbContentBySession(final Long nbSessionId) { return (NoticeboardContent) getHibernateTemplate().execute(new HibernateCallback() @@ -72,22 +102,59 @@ }); } + /** + *

Persist the given persistent instance of NoticeboardContent.

+ * + * @param nbContent The instance of NoticeboardContent to persist. + */ public void saveNbContent(NoticeboardContent nbContent) { this.getHibernateTemplate().save(nbContent); } + /** + *

Update the given persistent instance of NoticeboardContent.

+ * + * @param nbContent The instance of NoticeboardContent to persist. + */ public void updateNbContent(NoticeboardContent nbContent) { this.getHibernateTemplate().update(nbContent); } + /** + *

Delete the given instance of NoticeboardContent with the + * given tool content id nbContentId + * + * @param nbContentId The tool content Id. + */ public void removeNoticeboard(Long nbContentId) { - NoticeboardContent nb = (NoticeboardContent)getHibernateTemplate().get(NoticeboardContent.class, nbContentId); - getHibernateTemplate().delete(nb); + + String query = "from NoticeboardContent as nb where nb.nbContentId="; + StringBuffer sb = new StringBuffer(query); + sb.append(nbContentId.longValue()); + String queryString = sb.toString(); + + this.getHibernateTemplate().delete(queryString); } + /** + *

Delete the given instance of NoticeboardContent

+ * + * @param nbContent The instance of NoticeboardContent to delete. + */ + public void removeNoticeboard(NoticeboardContent nbContent) + { + this.getHibernateTemplate().delete(nbContent); + } + + /** + *

Deletes all instances of NoticeboardSession that are associated + * with the given instance of NoticeboardContent

+ * + * @param nbContent The instance of NoticeboardContent in which corresponding instances of NoticeboardSession should be deleted. + */ public void removeNbSessions(NoticeboardContent nbContent) { this.getHibernateTemplate().deleteAll(nbContent.getNbSessions()); Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java,v diff -u -r1.1 -r1.2 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java 7 Jun 2005 05:50:05 -0000 1.1 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java 22 Jun 2005 06:17:35 -0000 1.2 @@ -21,48 +21,113 @@ package org.lamsfoundation.lams.tool.noticeboard.dao.hibernate; +import java.util.List; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO; import org.springframework.orm.hibernate.support.HibernateDaoSupport; /** * @author mtruong - * Hibernate implementation for database access for the noticeboard tool. + * Hibernate implementation for database access to Noticeboard sessions for the noticeboard tool. */ public class NoticeboardSessionDAO extends HibernateDaoSupport implements INoticeboardSessionDAO { - - /** Finds a noticeboard by its noticeboard id and returns - * null if not found + /** + *

Return the persistent instance of a NoticeboardSession + * with the given identifier uid, returns null if not found.

+ * + * @param uid an identifier for the NoticeboardSession object. + * @return the persistent instance of a NoticeboardSession or null if not found */ - - public NoticeboardSession getNbSessionById(Long nbSessionId) + public NoticeboardSession getNbSessionByUID(Long uid) { return (NoticeboardSession) this.getHibernateTemplate() - .get(NoticeboardSession.class, nbSessionId); + .get(NoticeboardSession.class, uid); } - public NoticeboardSession loadNbSessionById(Long nbSessionId) + + /** + *

Return the persistent instance of a NoticeboardSession + * with the given tool session id nbSessionId, + * returns null if not found.

+ * + * @param nbSessionId The tool session id + * @return the persistent instance of a NoticeboardSession or null if not found. + */ + public NoticeboardSession findNbSessionById(Long nbSessionId) { - return (NoticeboardSession) this.getHibernateTemplate() - .load(NoticeboardSession.class, nbSessionId); + String query = "from NoticeboardSession nbS where nbS.nbSessionId=?"; + List session = getHibernateTemplate().find(query,nbSessionId); + + if(session!=null && session.size() == 0) + { + return null; + } + else + { + return (NoticeboardSession)session.get(0); + } } - - public void saveNbSession(NoticeboardSession nbSession) + + + /** + *

Persist the given persistent instance of NoticeboardSession.

+ * + * @param nbSession The instance of NoticeboardSession to persist. + */ + public void saveNbSession(NoticeboardSession nbSession) { this.getHibernateTemplate().save(nbSession); } + /** + *

Update the given persistent instance of NoticeboardSession.

+ * + * @param nbContent The instance of NoticeboardSession to persist. + */ public void updateNbSession(NoticeboardSession nbSession) { this.getHibernateTemplate().update(nbSession); } + /** + *

Delete the given instance of NoticeboardSession with the + * given identifier uid + * + * @param uid an identifier for the NoticeboardSession instance. + */ + public void removeNbSessionByUID(Long uid) + { + NoticeboardSession nb = (NoticeboardSession)getHibernateTemplate().get(NoticeboardSession.class, uid); + this.getHibernateTemplate().delete(nb); + } + + /** + *

Delete the given instance of NoticeboardSession with the + * given tool session id nbSessionid + * + * @param nbSessionId The tool session Id. + */ public void removeNbSession(Long nbSessionId) { - NoticeboardSession nb = (NoticeboardSession)getHibernateTemplate().get(NoticeboardSession.class, nbSessionId); - getHibernateTemplate().delete(nb); + String query = "from NoticeboardSession as nbS where nbS.nbSessionId ="; + StringBuffer sb = new StringBuffer(query); + sb.append(nbSessionId.longValue()); + + String queryString = sb.toString(); + + this.getHibernateTemplate().delete(queryString); + } + /** + *

Delete the given instance of NoticeboardSession

+ * + * @param nbSession The instance of NoticeboardSession to delete. + */ + public void removeNbSession(NoticeboardSession nbSession) + { + this.getHibernateTemplate().delete(nbSession); + } } Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java,v diff -u -r1.2 -r1.3 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 16 Jun 2005 02:26:38 -0000 1.2 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 22 Jun 2005 06:18:40 -0000 1.3 @@ -51,26 +51,69 @@ private static Logger log = Logger.getLogger(NoticeboardServicePOJO.class); + + /* ============================================================================== + * Methods for access to NoticeboardContent objects + * ============================================================================== + */ + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardByUID(Long) + */ + public NoticeboardContent retrieveNoticeboardByUID(Long uid) + { + try + { + nbContent = nbContentDAO.getNbContentByUID(uid); + } + catch (DataAccessException e) + { + throw new NbApplicationException("An exception has occured while trying to retrieve noticeboard content: " + + e.getMessage(), + e); + } + return nbContent; + } + + /** * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboard(Long) */ public NoticeboardContent retrieveNoticeboard(Long nbContentId) { try { - nbContent = nbContentDAO.getNbContentById(nbContentId); + nbContent = nbContentDAO.findNbContentById(nbContentId); } catch (DataAccessException e) { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content object: " + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " + e.getMessage(), e); } return nbContent; } + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardBySessionID(Long) + */ + public NoticeboardContent retrieveNoticeboardBySessionID(Long nbSessionId) + { + try + { + nbContent = nbContentDAO.getNbContentBySession(nbSessionId); + } + catch (DataAccessException e) + { + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " + + e.getMessage(), + e); + } + + return nbContent; + } + /** * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ @@ -139,6 +182,66 @@ } /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) + */ + public void removeNoticeboard(NoticeboardContent nbContent) + { + try + { + nbContentDAO.removeNoticeboard(nbContent); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " + + e.getMessage(), e); + } + } + + /* ============================================================================== + * Methods for access to NoticeboardSession objects + * ============================================================================== + */ + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardSession(Long) + */ + public NoticeboardSession retrieveNoticeboardSession(Long nbSessionId) + { + try + { + nbSession = nbSessionDAO.findNbSessionById(nbSessionId); + } + catch (DataAccessException e) + { + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard session object: " + + e.getMessage(), + e); + } + + return nbSession; + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardSessionByUID(Long) + */ + + public NoticeboardSession retrieveNoticeboardSessionByUID(Long uid) + { + try + { + nbSession = nbSessionDAO.getNbSessionByUID(uid); + } + catch (DataAccessException e) + { + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard session object: " + + e.getMessage(), + e); + } + + return nbSession; + } + + /** * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ public void saveNoticeboardSession(NoticeboardSession nbSession) @@ -149,12 +252,76 @@ } catch(DataAccessException e) { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard session: " + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to save this noticeboard session: " +e.getMessage(), e); } } + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void updateNoticeboardSession(NoticeboardSession nbSession) + { + try + { + nbSessionDAO.updateNbSession(nbSession); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to update this noticeboard session: " + +e.getMessage(), e); + } + } + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(Long) + */ + public void removeSession(Long nbSessionId) + { + try + { + nbSessionDAO.removeNbSession(nbSessionId); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " + + e.getMessage(), e); + } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void removeSession(NoticeboardSession nbSession) + { + try + { + nbSessionDAO.removeNbSession(nbSession); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " + + e.getMessage(), e); + } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSessionByUID(Long) + */ + public void removeSessionByUID(Long uid) + { + try + { + nbSessionDAO.removeNbSessionByUID(uid); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " + + e.getMessage(), e); + } + } + + /* ===============Methods implemented from ToolContentManager =============== */ public void copyToolContent(Long fromContentId, Long toContentId) throws NbApplicationException @@ -205,12 +372,7 @@ public void removeToolContent(Long toolContentId) { - //all sessions relating to this content id is removed first - //then remove the tool that is associated with this toolContentId - NoticeboardContent nbContent = retrieveNoticeboard(toolContentId); - removeNoticeboardSessions(nbContent); - removeNoticeboard(toolContentId); } Index: lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/Attic/TestNoticeboardServicePOJO.java,v diff -u -r1.2 -r1.3 --- lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java 16 Jun 2005 02:25:00 -0000 1.2 +++ lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java 22 Jun 2005 06:22:02 -0000 1.3 @@ -20,16 +20,13 @@ */ /* - * Created on May 23, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * @author Mai Ling Truong + * modified: June 22, 2005 */ package org.lamsfoundation.lams.tool.noticeboard.service; import java.util.Date; - import org.lamsfoundation.lams.tool.noticeboard.NbDataAccessTestCase; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; @@ -46,11 +43,11 @@ { private INoticeboardService nbService = null; - //private INoticeboardContentDAO nbContentDAO = null; - private NoticeboardContent nb; + private NoticeboardContent nbContent; + private NoticeboardSession nbSession; private boolean cleanContentData = true; - private boolean cleanAllData = true; + public TestNoticeboardServicePOJO(String name) { @@ -62,51 +59,47 @@ super.setUp(); //setup some data nbService = (INoticeboardService)this.context.getBean("nbService"); - this.initNbContentData(); - this.initNbSessionContent(); + super.initAllData(); } protected void tearDown() throws Exception { super.tearDown(); //delete data - if (cleanAllData) - { - super.cleanAllData(); - } - else if(cleanContentData) - { - super.cleanNbContentData(); - } + if(cleanContentData) + { + super.cleanNbContentData(TEST_NB_ID); + } } + + public void testRetrieveNoticeboardByUID() + { + nbContent = nbService.retrieveNoticeboard(TEST_NB_ID); + Long uid = nbContent.getUid(); + + NoticeboardContent testObject = nbService.retrieveNoticeboardByUID(uid); + + assertContentEqualsTestData(testObject); + } - public void testretrieveNoticeboard() + public void testRetrieveNoticeboard() { - nb = nbService.retrieveNoticeboard(TEST_NB_ID); + nbContent = nbService.retrieveNoticeboard(TEST_NB_ID); - assertEquals(nb.getNbContentId(), TEST_NB_ID); - - assertEquals(nb.getTitle(), TEST_TITLE); - assertEquals(nb.getContent(), TEST_CONTENT); - assertEquals(nb.getOnlineInstructions(), TEST_ONLINE_INSTRUCTIONS); - assertEquals(nb.getOfflineInstructions(), TEST_OFFLINE_INSTRUCTIONS); - assertEquals(nb.isDefineLater(), TEST_DEFINE_LATER); - assertEquals(nb.isForceOffline(), TEST_FORCE_OFFLINE); - assertEquals(nb.getCreatorUserId(), TEST_CREATOR_USER_ID); - assertEquals(nb.getDateCreated(), TEST_DATE_CREATED); + assertContentEqualsTestData(nbContent); } - public void testupdateNoticeboard() + public void testUpdateNoticeboard() { - String newContent = "New updated content"; - nb = nbService.retrieveNoticeboard(TEST_NB_ID); - nb.setContent(newContent); + String newContent = "New updated content"; + nbContent = nbService.retrieveNoticeboard(TEST_NB_ID); + nbContent.setContent(newContent); //save the new changes - nbService.updateNoticeboard(nb); + nbService.updateNoticeboard(nbContent); //check whether the changes has been saved NoticeboardContent newNb = nbService.retrieveNoticeboard(TEST_NB_ID); @@ -121,9 +114,9 @@ assertEquals(newNb.getDateCreated(), TEST_DATE_CREATED); } - public void testsaveNoticeboard() + public void testSaveNoticeboard() { - Long testToolContentId = new Long(8000); + Long testToolContentId = new Long(8000); String testTitle = "TestCase: saveNoticeboard()"; String testContent = "This is to test the saveNoticeboard() function"; String testOnlineInstructions = "online instructions"; @@ -144,60 +137,141 @@ assertEquals(retrievedObject.getOfflineInstructions(), testOfflineInstructions); //remove test data + nbService.removeNoticeboard(testToolContentId); + } + + /** + * TODO: finish this one after testing sesssion + * + */ + /*public void testremoveNoticeboardSessions() + { + nbContent = nbService.retrieveNoticeboard(TEST_NB_ID); + nbService.removeNoticeboardSessions(nbContent); + } */ + + public void testRemoveNoticeboardByID() + { + cleanContentData = false; + nbService.removeNoticeboard(TEST_NB_ID); + + NoticeboardContent nb = nbService.retrieveNoticeboard(TEST_NB_ID); + assertNull(nb); } - public void testremoveNoticeboard() + public void testRemoveNoticeboard() { - - cleanAllData = false; - cleanContentData = false; - //remove associated sessions first, then remove the noticeboard content - nb = nbService.retrieveNoticeboard(TEST_NB_ID); - - nbService.removeNoticeboardSessions(nb); - nbService.removeNoticeboard(TEST_NB_ID); - - NoticeboardContent emptyNbContent = nbService.retrieveNoticeboard(TEST_NB_ID); - assertNull(emptyNbContent); - } + cleanContentData = false; + nbService.removeNoticeboard(nbService.retrieveNoticeboard(TEST_NB_ID)); + + NoticeboardContent nb = nbService.retrieveNoticeboard(TEST_NB_ID); + assertNull(nb); + } + public void testRetrieveNoticeboardSession() + { + nbSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + assertEqualsForSessionContent(nbSession); + } - /** - * TODO: write this test case once session stuff is done - * @author mtruong - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ - public void testremoveNoticeboardSessions() + public void testRetrieveNoticeboardSessionByUID() { + nbSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + Long uid = nbSession.getUid(); + NoticeboardSession testSession = nbService.retrieveNoticeboardSessionByUID(uid); + + assertEqualsForSessionContent(testSession); } - /** - * TODO: finish off this function, retrieve the session from the database - * and check to see if the values are correct, also delete tghe object after testing - * - */ -/* public void testSaveNoticeboardSession() + public void testSaveNoticeboardSession() { Long testSessionId = new Long(9000); + Long testContentId = new Long(9500); Date created = new Date(System.currentTimeMillis()); - NoticeboardContent nbContent = nbService.retrieveNoticeboard(TEST_NB_ID); + NoticeboardContent nbContent = new NoticeboardContent(); + nbContent.setNbContentId(testContentId); + nbService.saveNoticeboard(nbContent); - NoticeboardSession nbSession = new NoticeboardSession(testSessionId, + NoticeboardSession nbSession = new NoticeboardSession(testSessionId, nbContent, created, - null, - NoticeboardSession.NOT_ATTEMPTED); + NoticeboardSession.NOT_ATTEMPTED); + nbContent.getNbSessions().add(nbSession); + nbService.saveNoticeboardSession(nbSession); + - nbService.saveNoticeboardSession(nbSession); + NoticeboardSession retrievedSession = nbService.retrieveNoticeboardSession(testSessionId); - + assertEquals(retrievedSession.getNbContent().getNbContentId(), testContentId); + assertEquals(retrievedSession.getSessionStartDate(), created); + assertEquals(retrievedSession.getSessionStatus(), NoticeboardSession.NOT_ATTEMPTED); + //remove test data + nbService.removeNoticeboard(testContentId); } - */ + + public void testUpdateNoticeboardSession() + { + nbSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + Date date = new Date(System.currentTimeMillis()); + + nbSession.setSessionStatus(NoticeboardSession.COMPLETED); + nbSession.setSessionEndDate(date); + + nbService.updateNoticeboardSession(nbSession); + + NoticeboardSession retrievedSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + + assertEquals(retrievedSession.getSessionStatus(), NoticeboardSession.COMPLETED); + assertEquals(retrievedSession.getSessionEndDate(), date); + } + + public void testRemoveSessionByID() + { + nbSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + + nbContent = nbSession.getNbContent(); + nbContent.getNbSessions().remove(nbSession); + + nbService.removeSession(TEST_SESSION_ID); + nbService.updateNoticeboard(nbContent); + + assertSessionObjectIsNull(TEST_SESSION_ID); + } + + public void testRemoveSession() + { + nbSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + + nbContent = nbSession.getNbContent(); + nbContent.getNbSessions().remove(nbSession); + + nbService.removeSession(nbSession); + nbService.updateNoticeboard(nbContent); + + assertSessionObjectIsNull(TEST_SESSION_ID); + + } + + public void testRemoveSessionByUID() + { + nbSession = nbService.retrieveNoticeboardSession(TEST_SESSION_ID); + Long uid = nbSession.getUid(); + + nbContent = nbSession.getNbContent(); + nbContent.getNbSessions().remove(nbSession); + + nbService.removeSessionByUID(uid); + nbService.updateNoticeboard(nbContent); + + assertSessionObjectIsNull(TEST_SESSION_ID); + + } + } + + \ No newline at end of file Index: lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestToolContentManager.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/Attic/TestToolContentManager.java,v diff -u -r1.1 -r1.2 --- lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestToolContentManager.java 7 Jun 2005 05:52:19 -0000 1.1 +++ lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestToolContentManager.java 22 Jun 2005 06:22:02 -0000 1.2 @@ -47,7 +47,6 @@ private INoticeboardService nbService = null; private boolean cleanContentData = true; - private boolean cleanAllData = true; private boolean cleanCopyContent = false; @@ -71,21 +70,15 @@ super.tearDown(); //delete data - if (cleanAllData) - { - super.cleanAllData(); - } - else - { - if(cleanContentData) - { - super.cleanNbContentData(); - } - } + if(cleanContentData) + { + super.cleanNbContentData(TEST_NB_ID); + } + if(cleanCopyContent) { - super.cleanNbCopiedContent(); + super.cleanNbContentData(TEST_COPYNB_ID); } } @@ -101,14 +94,7 @@ // check whether this new object contains the right content assertEquals(nbContent.getNbContentId(), TEST_COPYNB_ID); - assertEquals(nbContent.getTitle(), TEST_TITLE); - assertEquals(nbContent.getContent(), TEST_CONTENT); - assertEquals(nbContent.getOnlineInstructions(), TEST_ONLINE_INSTRUCTIONS); - assertEquals(nbContent.getOfflineInstructions(), TEST_OFFLINE_INSTRUCTIONS); - assertEquals(nbContent.isDefineLater(), TEST_DEFINE_LATER); - assertEquals(nbContent.isForceOffline(), TEST_FORCE_OFFLINE); - assertEquals(nbContent.getCreatorUserId(), TEST_CREATOR_USER_ID); - assertEquals(nbContent.getDateCreated(), TEST_DATE_CREATED); + assertContentEqualsTestData(nbContent); } public void testsetAsDefineLater() @@ -129,7 +115,6 @@ public void testremoveToolContent() { - cleanAllData = false; cleanContentData = false; nbContentManager.removeToolContent(TEST_NB_ID);