Search in sources :

Example 6 with ObjectType

use of com.helger.commons.type.ObjectType in project peppol-practical by phax.

the class CommentThreadObjectTypeManagerTest method testBasic.

@Test
public void testBasic() throws DAOException {
    final CommentThreadObjectTypeManager aMgr = new CommentThreadObjectTypeManager(new ObjectType("mock"));
    final Comment aComment = new Comment("unittest", ECommentState.APPROVED, "userid", "creatorname", "title", "text");
    assertNotNull(aComment.getCreationDateTime());
    assertNull(aComment.getLastModificationDateTime());
    assertEquals("userid", aComment.getUserID());
    assertEquals("creatorname", aComment.getCreatorName());
    assertFalse(aComment.isDeleted());
    assertEquals("title", aComment.getTitle());
    assertEquals("text", aComment.getText());
    final String sOwningObjectID = "blafoofasel";
    try {
        assertNotNull(aMgr.getAllCommentThreadsOfObject(sOwningObjectID));
        assertEquals(0, aMgr.getAllCommentThreadsOfObject(sOwningObjectID).size());
        // Create new thread
        final String sThreadID = aMgr.createNewThread(sOwningObjectID, aComment).getID();
        assertEquals(1, aMgr.getAllCommentThreadsOfObject(sOwningObjectID).size());
        // Add another comments into the thread
        aMgr.addCommentToThread(sOwningObjectID, sThreadID, sThreadID, new Comment("unittest", ECommentState.APPROVED, "userid", "creatorname", "title2", "text2"));
        assertEquals(1, aMgr.getAllCommentThreadsOfObject(sOwningObjectID).size());
        // Adding the same should fail
        try {
            aMgr.createNewThread(sOwningObjectID, aComment);
            fail();
        } catch (final IllegalArgumentException ex) {
        }
        // Create a second thread
        aMgr.createNewThread(sOwningObjectID, new Comment("unittest", ECommentState.APPROVED, "userid2", "creatorname2", "title4", "text4"));
        assertEquals(2, aMgr.getAllCommentThreadsOfObject(sOwningObjectID).size());
    } finally {
        aMgr.removeAllCommentThreadsOfObject(sOwningObjectID);
    }
}
Also used : ObjectType(com.helger.commons.type.ObjectType) Test(org.junit.Test)

Aggregations

ObjectType (com.helger.commons.type.ObjectType)6 ICommentThread (com.helger.peppol.comment.domain.ICommentThread)5 IHCNode (com.helger.html.hc.IHCNode)4 IComment (com.helger.peppol.comment.domain.IComment)4 LayoutExecutionContext (com.helger.photon.core.execcontext.LayoutExecutionContext)4 Locale (java.util.Locale)4 Comment (com.helger.peppol.comment.domain.Comment)2 CommentFormErrors (com.helger.peppol.comment.ui.CommentFormErrors)2 IUser (com.helger.photon.security.user.IUser)2 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 PDTToString (com.helger.commons.datetime.PDTToString)1 EChange (com.helger.commons.state.EChange)1 ESuccess (com.helger.commons.state.ESuccess)1 ISimpleURL (com.helger.commons.url.ISimpleURL)1 HCRow (com.helger.html.hc.html.tabular.HCRow)1 HCTable (com.helger.html.hc.html.tabular.HCTable)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 CommentThreadManager (com.helger.peppol.comment.domain.CommentThreadManager)1