diff --git a/src/main/java/com/makefire/anonymous/config/web/advice/Advice.java b/src/main/java/com/makefire/anonymous/config/web/advice/Advice.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/makefire/anonymous/domain/common/BasicEntity.java b/src/main/java/com/makefire/anonymous/domain/common/BasicEntity.java new file mode 100644 index 0000000..9bad8af --- /dev/null +++ b/src/main/java/com/makefire/anonymous/domain/common/BasicEntity.java @@ -0,0 +1,27 @@ +package com.makefire.anonymous.domain.common; + +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import javax.persistence.*; +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BasicEntity { + @Id + @GeneratedValue + protected Long id; + + @CreatedDate + @Column(name = "created_date",updatable = false) + private LocalDateTime createdDate; + + @LastModifiedDate + @Column(name = "modifiedDate",insertable = false) + private LocalDateTime modifiedDate; + + +} diff --git a/src/main/java/com/makefire/anonymous/domain/post/entity/Post.java b/src/main/java/com/makefire/anonymous/domain/post/entity/Post.java new file mode 100644 index 0000000..96d0d07 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/domain/post/entity/Post.java @@ -0,0 +1,46 @@ +package com.makefire.anonymous.domain.post.entity; + + +import com.makefire.anonymous.domain.common.BasicEntity; +import com.makefire.anonymous.rest.dto.request.post.PostRequest; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import javax.persistence.Entity; +import javax.validation.constraints.NotNull; + + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Post extends BasicEntity { + + + @NotNull(message = "Title must not be null") + private String title; + + private String content; + + @NotNull(message = "Author must not be null") + private String author; + + private Long authorId; + + @Builder + public Post(String title, String content, String author, Long authorId) { + this.title = title; + this.content = content; + this.author = author; + this.authorId = authorId; + } + + public void update(PostRequest postRequest){ + this.id = postRequest.getId(); + this.title = postRequest.getTitle(); + this.content = postRequest.getContent(); + this.author = postRequest.getAuthor(); + this.authorId = postRequest.getAuthorId(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/makefire/anonymous/domain/post/repository/PostRepository.java b/src/main/java/com/makefire/anonymous/domain/post/repository/PostRepository.java new file mode 100644 index 0000000..7a6fa09 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/domain/post/repository/PostRepository.java @@ -0,0 +1,11 @@ +package com.makefire.anonymous.domain.post.repository; + +import com.makefire.anonymous.domain.post.entity.Post; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PostRepository extends JpaRepository { + + +} diff --git a/src/main/java/com/makefire/anonymous/domain/user/entity/User.java b/src/main/java/com/makefire/anonymous/domain/user/entity/User.java deleted file mode 100644 index f9ae46b..0000000 --- a/src/main/java/com/makefire/anonymous/domain/user/entity/User.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.makefire.anonymous.domain.user.entity; - -/** - *packageName : com.makefire.anonymous - * fileName : User - * author : 최푸름 - * date : 22-01-14 - * description : 유저 엔티티 - * ================================= - * DATE AUTHOR NOTE - * 22-01-15 최푸름 - * --------------------------------- - */ -public class User { -} diff --git a/src/main/java/com/makefire/anonymous/rest/controller/api/PostController.java b/src/main/java/com/makefire/anonymous/rest/controller/api/PostController.java new file mode 100644 index 0000000..f20c482 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/rest/controller/api/PostController.java @@ -0,0 +1,50 @@ +package com.makefire.anonymous.rest.controller.api; + + +import com.makefire.anonymous.rest.RestSupport; +import com.makefire.anonymous.rest.dto.request.post.PostRequest; +import com.makefire.anonymous.rest.dto.response.Response; +import com.makefire.anonymous.service.post.PostService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/post") +@Slf4j +public class PostController extends RestSupport { + + private final PostService postService; + + @PostMapping + public ResponseEntity createPost( + @Valid @RequestBody PostRequest postRequest) { + log.info("createPost", postRequest.toString()); + return response(postService.createPost(postRequest)); + } + + @GetMapping("/{id}") + public ResponseEntity selectPost(@PathVariable("id") Long id) { + return response(postService.selectPost(id)); + } + + @GetMapping("/list") + public ResponseEntity selectPosts() { + return response(postService.selectPosts()); + } + + @PutMapping + public ResponseEntity updatePost(@Valid @RequestBody PostRequest postRequest) { + return response(postService.updatePost(postRequest)); + } + + @DeleteMapping("/{id}") + public ResponseEntity deletePost(@PathVariable("id") Long id) { + return response(postService.deletePost(id)); + } + +} + diff --git a/src/main/java/com/makefire/anonymous/rest/controller/api/UserController.java b/src/main/java/com/makefire/anonymous/rest/controller/api/UserController.java deleted file mode 100644 index de85eb5..0000000 --- a/src/main/java/com/makefire/anonymous/rest/controller/api/UserController.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.makefire.anonymous.rest.controller.api; - -import org.springframework.stereotype.Controller; - -/** - *packageName : com.makefire.anonymous - * fileName : UserController - * author : 최푸름 - * date : 22-01-14 - * description : 유저 E2E - * ================================= - * DATE AUTHOR NOTE - * 22-01-15 최푸름 - * --------------------------------- - */ -@Controller -public class UserController { -} diff --git a/src/main/java/com/makefire/anonymous/rest/dto/request/post/PostRequest.java b/src/main/java/com/makefire/anonymous/rest/dto/request/post/PostRequest.java new file mode 100644 index 0000000..0bdfe94 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/rest/dto/request/post/PostRequest.java @@ -0,0 +1,36 @@ +package com.makefire.anonymous.rest.dto.request.post; + +import com.makefire.anonymous.domain.post.entity.Post; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class PostRequest { + private Long id; + private String title; + private String content; + private String author; + private Long authorId; + + @Builder + public PostRequest(Long id, String title, String content, String author, Long authorId) { + this.id = id; + this.title = title; + this.content = content; + this.author = author; + this.authorId = authorId; + } + + public static Post toEntity(PostRequest postRequest) { + return Post.builder() + .title(postRequest.title) + .content(postRequest.content) + .author(postRequest.author) + .authorId(postRequest.authorId) + .build(); + + } + +} diff --git a/src/main/java/com/makefire/anonymous/rest/dto/response/Message.java b/src/main/java/com/makefire/anonymous/rest/dto/response/Message.java new file mode 100644 index 0000000..8cdd595 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/rest/dto/response/Message.java @@ -0,0 +1,17 @@ +package com.makefire.anonymous.rest.dto.response; + +import lombok.Data; + +@Data +public class Message { + + private StatusEnum status; + private String message; + private Object data; + + public Message() { + this.status = StatusEnum.BAD_REQUEST; + this.data = null; + this.message = null; + } +} diff --git a/src/main/java/com/makefire/anonymous/rest/dto/response/StatusEnum.java b/src/main/java/com/makefire/anonymous/rest/dto/response/StatusEnum.java new file mode 100644 index 0000000..29a0d94 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/rest/dto/response/StatusEnum.java @@ -0,0 +1,17 @@ +package com.makefire.anonymous.rest.dto.response; + +public enum StatusEnum { + + OK(200, "OK"), + BAD_REQUEST(400, "BAD_REQUEST"), + NOT_FOUND(404, "NOT_FOUND"), + INTERNAL_SERER_ERROR(500, "INTERNAL_SERVER_ERROR"); + + int statusCode; + String code; + + StatusEnum(int statusCode, String code) { + this.statusCode = statusCode; + this.code = code; + } +} diff --git a/src/main/java/com/makefire/anonymous/rest/dto/response/post/PostResponse.java b/src/main/java/com/makefire/anonymous/rest/dto/response/post/PostResponse.java new file mode 100644 index 0000000..2927b0b --- /dev/null +++ b/src/main/java/com/makefire/anonymous/rest/dto/response/post/PostResponse.java @@ -0,0 +1,63 @@ +package com.makefire.anonymous.rest.dto.response.post; + +import com.makefire.anonymous.domain.post.entity.Post; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class PostResponse { + + private Long id, authorId; + private String title, content, author; + private LocalDateTime createdDate, modifiedDate; + + + @Builder + public PostResponse(Long id, Long authorId, String title, String content, String author, LocalDateTime createdDate, LocalDateTime modifiedDate) { + this.id = id; + this.authorId = authorId; + this.title = title; + this.content = content; + this.author = author; + this.createdDate = createdDate; + this.modifiedDate = modifiedDate; + + } + + public static PostResponse from(Post post) { + return PostResponse.builder() + .id(post.getId()) + .authorId(post.getAuthorId()) + .title(post.getTitle()) + .content(post.getContent()) + .author(post.getAuthor()) + .createdDate(post.getCreatedDate()) + .modifiedDate(post.getModifiedDate()) + .build(); + } + + public static List fromList(List postList) { + List postResponseList = new ArrayList<>(); + for (Post post : postList + ) { + postResponseList.add(PostResponse.builder() + .id(post.getId()) + .authorId(post.getAuthorId()) + .title(post.getTitle()) + .content(post.getContent()) + .author(post.getAuthor()) + .createdDate(post.getCreatedDate()) + .modifiedDate(post.getModifiedDate()) + .build()); + } + return postResponseList; + } + +} diff --git a/src/main/java/com/makefire/anonymous/service/post/PostService.java b/src/main/java/com/makefire/anonymous/service/post/PostService.java new file mode 100644 index 0000000..654fd08 --- /dev/null +++ b/src/main/java/com/makefire/anonymous/service/post/PostService.java @@ -0,0 +1,47 @@ +package com.makefire.anonymous.service.post; + +import com.makefire.anonymous.domain.post.entity.Post; +import com.makefire.anonymous.domain.post.repository.PostRepository; +import com.makefire.anonymous.rest.dto.request.post.PostRequest; +import com.makefire.anonymous.rest.dto.response.post.PostResponse; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +import java.util.List; + +@Service +@AllArgsConstructor +public class PostService { + private final PostRepository postRepository; + + public PostResponse selectPost(Long id) { + Post post = postRepository.findById(id).orElseThrow(() -> new IllegalArgumentException()); + return PostResponse.from(post); + } + + public List selectPosts() { + List postList = postRepository.findAll(); + return PostResponse.fromList(postList); + } + + @Transactional + public PostResponse createPost(PostRequest postRequest) { + Post post = PostRequest.toEntity(postRequest); + return PostResponse.from(postRepository.save(post)); + } + + @Transactional(rollbackFor = IllegalArgumentException.class) + public PostResponse updatePost(PostRequest postRequest) { + Post post = postRepository.findById(postRequest.getId()).orElseThrow(() -> new IllegalArgumentException()); + post.update(postRequest); + return PostResponse.from(post); + } + + public Boolean deletePost(Long id) { + Post post = postRepository.findById(id).orElseThrow(() -> new IllegalArgumentException()); + postRepository.delete(post); + return true; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 175b424..70d389d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,4 +3,5 @@ spring: include: local, config.oauth mvc: pathmatch: - matching-strategy: ant_path_matcher \ No newline at end of file + matching-strategy: ant_path_matcher + diff --git a/src/test/java/com/makefire/anonymous/controller/post/PostControllerTest.java b/src/test/java/com/makefire/anonymous/controller/post/PostControllerTest.java new file mode 100644 index 0000000..63697bb --- /dev/null +++ b/src/test/java/com/makefire/anonymous/controller/post/PostControllerTest.java @@ -0,0 +1,106 @@ +package com.makefire.anonymous.controller.post; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.makefire.anonymous.domain.post.entity.Post; +import com.makefire.anonymous.rest.dto.request.post.PostRequest; +import com.makefire.anonymous.rest.dto.response.post.PostResponse; +import com.makefire.anonymous.service.post.PostService; +import com.makefire.anonymous.support.SpringMockMvcTestSupport; +import com.makefire.anonymous.support.fixture.PostFixture; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; + +import java.util.List; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class PostControllerTest extends SpringMockMvcTestSupport { + + @MockBean + private PostService postService; + + @Test + @DisplayName("게시판 생성 테스트") + void createPostTest() throws Exception{ + PostRequest postRequest = PostFixture.createPostRequest(); + when(postService.createPost(any())).thenReturn(PostResponse.from(PostRequest.toEntity(postRequest))); + + mockMvc.perform(post("/post") + .contentType(MediaType.APPLICATION_JSON) + .content(new ObjectMapper().writeValueAsString(postRequest))) + .andExpect(status().isOk()) + .andExpect(jsonPath("data.title").value(postRequest.getTitle())) + .andExpect(jsonPath("data.content").value(postRequest.getContent())) + .andExpect(jsonPath("data.author").value(postRequest.getAuthor())) + .andExpect(jsonPath("data.authorId").value(postRequest.getAuthorId())) + .andDo(print()); + + verify(postService).createPost(refEq(postRequest)); + } + + @Test + @DisplayName("게시판 전체조회 테스트") + void selectPostsTest() throws Exception { + List list= PostFixture.createPosts(); + when(postService.selectPosts()).thenReturn(PostResponse.fromList(list)); + + mockMvc.perform(get("/post/list")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.data[0].title").value(list.get(0).getTitle())) + .andDo(print()); + } + + @Test + @DisplayName("게시판 단건 조회 테스트") + void selectPostTest() throws Exception{ + PostResponse postResponse = PostFixture.createPostResponse(); + when(postService.selectPost(postResponse.getId())).thenReturn(postResponse); + + mockMvc.perform(get("/post/"+ postResponse.getId())) + .andExpect(status().isOk()) + .andExpect(jsonPath("data.title").value(postResponse.getTitle())) + .andExpect(jsonPath("data.content").value(postResponse.getContent())) + .andExpect(jsonPath("data.author").value(postResponse.getAuthor())) + .andExpect(jsonPath("data.authorId").value(postResponse.getAuthorId())) + .andDo(print()); + } + + @Test + @DisplayName("게시판 업데이트 테스트") + void updatePostTest() throws Exception { + PostRequest postUpdateRequest=PostFixture.updatePostRequest(); + PostResponse updatePostResponse=PostFixture.updatePostResponse(); + when(postService.updatePost(any())).thenReturn(updatePostResponse); + + mockMvc.perform(put("/post") + .contentType(MediaType.APPLICATION_JSON) + .content(new ObjectMapper().writeValueAsString(postUpdateRequest))) + .andExpect(status().isOk()) + .andExpect(jsonPath("data.title").value(postUpdateRequest.getTitle())) + .andExpect(jsonPath("data.author").value(postUpdateRequest.getAuthor())) + .andExpect(jsonPath("data.content").value(postUpdateRequest.getContent())) + .andDo(print()); + + } + + + + @Test + @DisplayName("게시판 삭제 ") + void deletePostTest()throws Exception{ + when(postService.deletePost(any())).thenReturn(true); + + mockMvc.perform(delete("/post/"+1L)) + .andExpect(status().isOk()) + .andDo(print()); + + verify(postService,times(1)).deletePost(eq(1L)); + } +} diff --git a/src/test/java/com/makefire/anonymous/domain/post/repository/PostRepositoryTest.java b/src/test/java/com/makefire/anonymous/domain/post/repository/PostRepositoryTest.java new file mode 100644 index 0000000..c9dd400 --- /dev/null +++ b/src/test/java/com/makefire/anonymous/domain/post/repository/PostRepositoryTest.java @@ -0,0 +1,65 @@ +package com.makefire.anonymous.domain.post.repository; + +import com.makefire.anonymous.domain.post.entity.Post; +import com.makefire.anonymous.support.SpringTestSupport; +import com.makefire.anonymous.support.fixture.PostFixture; + +import org.hamcrest.collection.IsEmptyCollection; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + + +import java.util.List; + + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + + +public class PostRepositoryTest extends SpringTestSupport { + @Autowired + private PostRepository postRepository; + + @BeforeEach + void setUp() { + List postData = PostFixture.createPosts(); + postRepository.saveAll(postData); + } + + @Test + @DisplayName("findById 테스트") + void getPostTest() { + Post post = postRepository.findById(1L).get(); + + Assertions.assertAll( + () -> assertEquals(post.getId(), 1L) + ); + } + + @Test + @DisplayName("findAll 테스트") + void getListOfPostTest() { + List posts = postRepository.findAll(); + + Assertions.assertAll( + () -> assertEquals(posts.size(), 3) + ); + } + + @Test + @DisplayName("deleteAll 테스트") + void deletePostTest() { + postRepository.deleteAll(); + List posts = postRepository.findAll(); + /** + * assertThat이 unitTest 에서 + * 가독성이나 유연성등의 측면에서 더 좋다는 + * 자료를 봐서 일단 적용해봄 + * 어떤게 더 날지 판단 부탁 + */ + assertThat(posts, IsEmptyCollection.empty()); + } +} diff --git a/src/test/java/com/makefire/anonymous/service/post/PostServiceTest.java b/src/test/java/com/makefire/anonymous/service/post/PostServiceTest.java new file mode 100644 index 0000000..0241331 --- /dev/null +++ b/src/test/java/com/makefire/anonymous/service/post/PostServiceTest.java @@ -0,0 +1,80 @@ +package com.makefire.anonymous.service.post; + +import com.makefire.anonymous.domain.post.entity.Post; +import com.makefire.anonymous.domain.post.repository.PostRepository; +import com.makefire.anonymous.rest.dto.request.post.PostRequest; +import com.makefire.anonymous.rest.dto.response.post.PostResponse; +import com.makefire.anonymous.support.SpringTestSupport; +import com.makefire.anonymous.support.fixture.PostFixture; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import org.mockito.InjectMocks; +import org.mockito.Mock; + + +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +public class PostServiceTest extends SpringTestSupport { + + @InjectMocks + PostService postService; + + @Mock + private PostRepository postRepository; + + @Nested + class CreateCommonRequest{ + PostRequest postRequest = PostFixture.createPostRequest(); + + @Test + @DisplayName("Post를 생성하여 저장한다.") + void createPostTest() { + when(postRepository.save(any())).thenReturn(PostRequest.toEntity(postRequest)); + PostResponse postResponse = postService.createPost(postRequest); + assertEquals(postRequest.getTitle(), postResponse.getTitle()); + } + + @Test + @DisplayName("Post를 생성하여 저장한다.") + void updatePostTest() { + PostRequest postRequest1 = PostFixture.createUpdatePost(); + when(postRepository.findById(any())).thenReturn(Optional.of(PostRequest.toEntity(postRequest))); + PostResponse postResponse = postService.updatePost(postRequest1); + assertEquals(postRequest1.getTitle(), postResponse.getTitle()); + } + + @Test + @DisplayName("Post를 단건 조회한다") + void getPostTest(){ + when(postRepository.findById(any())).thenReturn(Optional.ofNullable(PostRequest.toEntity(postRequest))); + PostResponse postResponse = postService.selectPost(1L); + assertEquals(postRequest.getTitle(), postResponse.getTitle()); + } + + @Test + @DisplayName("id 를 입력받아 데이터를 삭제한다.") + void deletePostTest() { + when(postRepository.findById(any())).thenReturn(Optional.of(PostRequest.toEntity(postRequest))); + Boolean result = postService.deletePost(1L); + assertEquals(true, result); + } + + } + + @Test + @DisplayName("모든 데이터를 찾아 반환한다.") + void selectPostListTest() { + List postList = PostFixture.createPosts(); + when(postRepository.findAll()).thenReturn(postList); + List postResponseList = postService.selectPosts(); + assertEquals(postList.size(), postResponseList.size()); + } + + +} diff --git a/src/test/java/com/makefire/anonymous/support/fixture/PostFixture.java b/src/test/java/com/makefire/anonymous/support/fixture/PostFixture.java new file mode 100644 index 0000000..ba46e99 --- /dev/null +++ b/src/test/java/com/makefire/anonymous/support/fixture/PostFixture.java @@ -0,0 +1,96 @@ +package com.makefire.anonymous.support.fixture; + + +import com.makefire.anonymous.domain.post.entity.Post; +import com.makefire.anonymous.rest.dto.request.post.PostRequest; +import com.makefire.anonymous.rest.dto.response.post.PostResponse; +import java.util.Arrays; +import java.util.List; + +public class PostFixture { + + public static PostRequest createPostRequest(){ + return PostRequest.builder() + .id(1L) + .title("testTitle") + .content("testContent") + .author("testAuthor") + .authorId(12L) + .build(); + } + + public static PostResponse createPostResponse(){ + return PostResponse.builder() + .id(1L) + .title("testTitle") + .content("testContent") + .author("testAuthor") + .authorId(12L) + .build(); + } + + public static PostResponse updatePostResponse(){ + return PostResponse.builder() + .id(1L) + .title("updateTitle") + .content("updateContent") + .author("updateAuthor") + .authorId(12L) + .build(); + } + + public static PostRequest updatePostRequest(){ + return PostRequest.builder() + .id(1L) + .title("updateTitle") + .content("updateContent") + .author("updateAuthor") + .authorId(12L) + .build(); + } + + + public static List createPosts(){ + Post post1 = Post.builder() + .title("testTitle") + .content("testContent") + .author("testAuthor") + .authorId(12L) + .build(); + + Post post2 = Post.builder() + .title("testTitle2") + .content("testContent2") + .author("testAuthor2") + .authorId(13L) + .build(); + + Post post3 = Post.builder() + .title("testTitle3") + .content("testContent3") + .author("testAuthor3") + .authorId(13L) + .build(); + + return Arrays.asList(post1, post2, post3); + } + + public static Post createPost(){ + return Post.builder() + .title("testTitle") + .content("testContent") + .author("testAuthor") + .authorId(12L) + .build(); + } + + public static PostRequest createUpdatePost(){ + return PostRequest.builder() + .id(1L) + .title("updateTitle") + .content("updateContent") + .author("updateAuthor") + .authorId(12L) + .build(); + } +}