diff --git a/src/main/java/com/t13g2/forum/model/CommentRepository.java b/src/main/java/com/t13g2/forum/model/CommentRepository.java index f6c8c830aad4..3855c74d5b21 100644 --- a/src/main/java/com/t13g2/forum/model/CommentRepository.java +++ b/src/main/java/com/t13g2/forum/model/CommentRepository.java @@ -6,6 +6,7 @@ import java.util.stream.Collectors; import com.sun.istack.NotNull; +import com.t13g2.forum.commons.util.Extensions; import com.t13g2.forum.model.forum.Comment; import com.t13g2.forum.model.forum.ForumThread; import com.t13g2.forum.storage.forum.EntityDoesNotExistException; @@ -58,6 +59,17 @@ public void deleteComment(int commentId) { forumBookStorage.getComments().setDirty(); } + /** + * Updates an {@link Comment} + * + * @param comment + */ + @Override + public void updateComment(Comment comment) { + Extensions.updateObjectInList(forumBookStorage.getComments().getList(), comment); + forumBookStorage.getComments().setDirty(); + } + /** * Gets an {@link Comment} by its object Id * @param commentId diff --git a/src/main/java/com/t13g2/forum/model/ICommentRepository.java b/src/main/java/com/t13g2/forum/model/ICommentRepository.java index 4b10d1ead7c7..9d529650df22 100644 --- a/src/main/java/com/t13g2/forum/model/ICommentRepository.java +++ b/src/main/java/com/t13g2/forum/model/ICommentRepository.java @@ -31,6 +31,13 @@ public interface ICommentRepository { */ void deleteComment(int commentId); + /** + * Updates an {@link Comment} + * + * @param comment + */ + void updateComment(Comment comment); + /** * Gets an {@link Comment} by its object Id * @param commentId diff --git a/src/test/java/com/t13g2/forum/storage/UnitOfWorkTest.java b/src/test/java/com/t13g2/forum/storage/UnitOfWorkTest.java index 7a38722d3190..c959eae8319e 100644 --- a/src/test/java/com/t13g2/forum/storage/UnitOfWorkTest.java +++ b/src/test/java/com/t13g2/forum/storage/UnitOfWorkTest.java @@ -95,7 +95,6 @@ public void testLatestAnnouncement() throws EntityDoesNotExistException { IUnitOfWork unitOfWork2 = new UnitOfWork(storage); Announcement latest = unitOfWork2.getAnnouncementRepository().getLatestAnnouncement(); - Assert.assertEquals(latest.getId(), announcement2.getId()); Assert.assertEquals(latest.getTitle(), announcement2.getTitle()); Assert.assertEquals(latest.getContent(), announcement2.getContent());