Index: lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java =================================================================== diff -u -r1f57d491bdccbcc7a4a6036d766842d05c4d9b6e -rb48b51a5abe9ab155e1326716ba1601f5ae49fb9 --- lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java (.../TestNoticeboardServicePOJO.java) (revision 1f57d491bdccbcc7a4a6036d766842d05c4d9b6e) +++ lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java (.../TestNoticeboardServicePOJO.java) (revision b48b51a5abe9ab155e1326716ba1601f5ae49fb9) @@ -34,6 +34,7 @@ import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; @@ -48,6 +49,7 @@ private NoticeboardContent nbContent; private NoticeboardSession nbSession; private NoticeboardUser nbUser; + private NoticeboardAttachment attachment; private boolean cleanContentData = true; @@ -60,9 +62,10 @@ protected void setUp() throws Exception { super.setUp(); - //setup some data + nbService = (INoticeboardService)this.context.getBean("nbService"); super.initAllData(); + } protected void tearDown() throws Exception @@ -415,6 +418,54 @@ } + + /* ============================================================================== + * Methods for access to NoticeboardAttachment objects + * ============================================================================== + */ + + public void testRetrieveAttachment() + { + initNbAttachmentData(); + //test retrieveAttachmentByUuid + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + + assertAttachmentData(attachment); + /* test getAttachmentsFromContent which will return a list of attachment ids, which we can use in the next method call to + retrieveAttachment which takes in the attachmentId as the parameter. */ + List idList = nbService.getAttachmentIdsFromContent(nbService.retrieveNoticeboard(TEST_NB_ID)); + + //test retrieveAttachment (by attachmentId, which was retrieved from the previous method) + attachment = nbService.retrieveAttachment((Long)idList.get(0)); + assertAttachmentData(attachment); + } + + public void testSaveAttachment() + { + String newFilename = "NoticeboardInstructions.txt"; + initNbAttachmentData(); + + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + attachment.setFilename(newFilename); + + nbService.saveAttachment(attachment); + + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + assertEquals(attachment.getFilename(), newFilename); + } + + public void testRemoveAttachment() + { + initNbAttachmentData(); + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + + nbService.removeAttachment(attachment); + + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + + assertNull(attachment); + + } } \ No newline at end of file