/*
package ru.ulstu.is.sbapp;

import jakarta.persistence.EntityNotFoundException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import ru.ulstu.is.sbapp.Comment.model.Comment;
import ru.ulstu.is.sbapp.Comment.service.CommentService;
import ru.ulstu.is.sbapp.Post.model.Post;
import ru.ulstu.is.sbapp.Post.service.PostNotFoundException;
import ru.ulstu.is.sbapp.Post.service.PostService;
import ru.ulstu.is.sbapp.User.model.User;
import ru.ulstu.is.sbapp.User.service.UserService;

import java.util.List;

@SpringBootTest
public class JpaPostTests {
    private static final Logger log = LoggerFactory.getLogger(JpaPostTests.class);
    @Autowired
    private CommentService commentService;
    @Autowired
    private UserService userService;
    @Autowired
    private PostService postService;

    @Test
    void TestAddPost(){
        postService.deleteAllPosts();
        final Post post = postService.addPost("Test","Test");
        Assertions.assertNotNull(post.getId());
    }

    @Test
    void TestFindPost(){
        postService.deleteAllPosts();
        final Post post = postService.addPost("Test","Test");
        final Post findPost = postService.findPost(post.getId());
        Assertions.assertEquals(post, findPost);
    }

    @Test
    void TestPostReadNotFound(){
        postService.deleteAllPosts();
        Assertions.assertThrows(PostNotFoundException.class, () -> postService.findPost(-1L));
    }

    @Test
    void TestFindAllPost(){
        postService.deleteAllPosts();
        final Post firstPost = postService.addPost("Test1","Test1");
        final Post secondPost = postService.addPost("Test2","Test2");
        final List<Post> posts = postService.findAllPosts();
        Assertions.assertEquals(posts.size(), 2);
    }
    @Test
    void TestPostReadAllEmpty() {
        postService.deleteAllPosts();
        final List<Post> posts = postService.findAllPosts();
        Assertions.assertEquals(posts.size(), 0);
    }

    @Test
    void TestPostUpdate(){
        postService.deleteAllPosts();
        Post post = postService.addPost("Test1", "Test1");
        post = postService.updatePost(post.getId(), "Test2", "Test2");
        Assertions.assertEquals(post.getHeading(), "Test2");
        Assertions.assertEquals(post.getContent(), "Test2");
    }
    @Test
    void TestDeleteAllPosts()
    {
        log.info("Удаление всех постов");
        Post post = postService.addPost("Test1", "Test1");
        Post post2 = postService.addPost("Test1", "Test1");
        List<Post> posts1 = postService.findAllPosts();
        log.info(posts1.toString());
        postService.deleteAllPosts();
        List<Post> posts = postService.findAllPosts();
        log.info(posts.toString());

    }

    @Test
    void TestDeletePost(){
        postService.deleteAllPosts();
        final Post post = postService.addPost("Test","Test");
        postService.deletePost(post.getId());
        Assertions.assertThrows(PostNotFoundException.class, () -> postService.findPost(1L));
    }

    @Test
    void TestAddComment()
    {
        log.info("Добавление комментария");
        postService.deleteAllPosts();
        userService.deleteAllUsers();
        final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
        userService.addNewPost(user.getId(),"Text1","Text2");
        final User user2=userService.findUser(user.getId());
        log.info(user2.getPosts().toString());
        final List<Post> posts = postService.findAllPosts();
        final  Post post2=postService.findPost(posts.get(0).getId());
        log.info(post2.toString());
        postService.addCommentToPost(posts.get(0).getId(),user.getId(),"Крутой пост");
        final List<Comment> comments = commentService.findAllComments();
        log.info(comments.toString());
        final User user1=userService.findUser(user.getId());
        log.info(user1.getComments().toString());
        final  Post post1=postService.findPost(posts.get(0).getId());
        log.info(post1.getComments().toString());
    }
    @Test
    void TestDeleteCommentFromPost()
    {
        log.info("Удаление коммента");
        postService.deleteAllPosts();
        userService.deleteAllUsers();
        final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
        userService.addNewPost(user.getId(),"Text1","Text2");
        final User user2=userService.findUser(user.getId());
        log.info("Посты юзера (добавили)"+user2.getPosts().toString());
        final List<Post> posts = postService.findAllPosts();
        final  Post post2=postService.findPost(posts.get(0).getId());
        log.info("Пост который добавили"+post2.toString());
        postService.addCommentToPost(posts.get(0).getId(),user.getId(),"Крутой пост");
        postService.addCommentToPost(posts.get(0).getId(),user.getId(),"Пост плохой");
        final List<Comment> comments = commentService.findAllComments();
        log.info("Добавили коммент"+comments.toString());
        final User user1=userService.findUser(user.getId());
        log.info("Комменты юзера"+user1.getComments().toString());
        final  Post post1=postService.findPost(posts.get(0).getId());
        log.info("Комменты к посту"+post1.getComments().toString());
        Comment comment1 = commentService.findComment(comments.get(0).getId());
        log.info("Удаляем коммент");
        postService.removeCommentFromPost(posts.get(0).getId(),comment1.getId());
        final User user3=userService.findUser(user.getId());
        log.info(user3.getPosts().toString());
        log.info("Комменты юзера после удаления"+user3.getComments().toString());
        final Post post3 = postService.findPost(posts.get(0).getId());
        log.info(post3.toString());
        log.info(post3.getComments().toString());
        final List<Comment> comment4=commentService.findAllComments();
        log.info(comment4.toString());
        commentService.deleteAllComments();
        postService.deleteAllPosts();
        userService.deleteAllUsers();
    }
}
*/
