diff --git a/data.mv.db b/data.mv.db index f12d577..88140bf 100644 Binary files a/data.mv.db and b/data.mv.db differ diff --git a/src/main/java/ru/ulstu/is/sbapp/Post/service/PostService.java b/src/main/java/ru/ulstu/is/sbapp/Post/service/PostService.java index a8ca639..49c0da1 100644 --- a/src/main/java/ru/ulstu/is/sbapp/Post/service/PostService.java +++ b/src/main/java/ru/ulstu/is/sbapp/Post/service/PostService.java @@ -66,6 +66,7 @@ public class PostService { @Transactional public void deleteAllPosts() { + em.createQuery("delete from Comment").executeUpdate(); em.createQuery("delete from Post").executeUpdate(); } diff --git a/src/test/java/ru/ulstu/is/sbapp/JpaPostTests.java b/src/test/java/ru/ulstu/is/sbapp/JpaPostTests.java index ef03279..50af215 100644 --- a/src/test/java/ru/ulstu/is/sbapp/JpaPostTests.java +++ b/src/test/java/ru/ulstu/is/sbapp/JpaPostTests.java @@ -82,6 +82,7 @@ public class JpaPostTests { @Test void TestAddComment() { + log.info("Добавление комментария"); postService.deleteAllPosts(); userService.deleteAllUsers(); final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com"); @@ -101,6 +102,7 @@ public class JpaPostTests { @Test void TestDeleteCommentFromPost() { + log.info("Удаление коммента"); postService.deleteAllPosts(); userService.deleteAllUsers(); final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com"); @@ -110,6 +112,7 @@ public class JpaPostTests { final Post post2=postService.findPost(post.getId()); log.info("Пост который добавили"+post2.toString()); final Comment comment =postService.addCommentToPost(post.getId(),user,"Крутой пост"); + final Comment commentcur =postService.addCommentToPost(post.getId(),user,"Пост плохой"); final List comments = commentService.findAllComments(); log.info("Добавили коммент"+comments.toString()); final User user1=userService.findUser(user.getId()); @@ -127,6 +130,7 @@ public class JpaPostTests { log.info(post3.getComments().toString()); final List comment4=commentService.findAllComments(); log.info(comment4.toString()); + commentService.deleteAllComments(); postService.deleteAllPosts(); userService.deleteAllUsers(); }