Skip to content

Commit

Permalink
Merge pull request ITsTime-Itamin#46 from ITsTime-Itamin/jungwoo
Browse files Browse the repository at this point in the history
[fix] fix deadLineDate
  • Loading branch information
friendshipkim97 authored Jul 28, 2022
2 parents e168fe5 + 8ffcaed commit 23b6e63
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static class CreateRequest {
@NotBlank(message = "게시판 마감일자를 입력해 주세요.")
@ApiModelProperty(notes = "게시판 마감일자를 입력해 주세요.")
@Pattern(regexp = "[0-9]{4}-[0-9]{2}-[0-9]{2}"
, message = "날짜 형식이 맞지 않습니다. yyyy-mm-ss hh:mm:ss 형식으로 입력해주세요.")
, message = "날짜 형식이 맞지 않습니다. yyyy-mm-ss 형식으로 입력해주세요.")
private String deadLineDate;

private List<MultipartFile> files;
Expand Down Expand Up @@ -85,7 +85,7 @@ public static class UpdateRequest {
@NotBlank(message = "게시판 마감일자를 입력해 주세요.")
@ApiModelProperty(notes = "게시판 마감일자를 입력해 주세요.")
@Pattern(regexp = "[0-9]{4}-[0-9]{2}-[0-9]{2}"
, message = "날짜 형식이 맞지 않습니다. yyyy-mm-ss hh:mm:ss 형식으로 입력해주세요.")
, message = "날짜 형식이 맞지 않습니다. yyyy-mm-ss 형식으로 입력해주세요.")
private String deadLineDate;

private List<MultipartFile> files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,55 +30,55 @@

public class BoardControllerTest extends BaseWebMvcTest {

@DisplayName("게시판 작성 테스트 - 성공")
@Test
@WithMockUser
void createBoardTest_success() throws Exception {
//given
CreateResponse createResponse = BoardFactory.mockCreateResponses().get(0);
given(boardService.createBoard(any(CreateRequest.class)))
.willReturn(createResponse);
//when
ResultActions perform = mockMvc.perform(multipart("/api/v1/boards")
.file(FileFactory.getTestImage1())
.param("title", "boardTitle")
.param("content", "boardContent")
.param("boardType", "NOTICE")
.param("deadLineDate", "2016-10-15 00:00:00"));

//then
perform.andExpect(status().isCreated())
.andExpect(jsonPath("$.message").value(containsString(CREATE_BOARD_SUCCESS.getMessage())))
.andExpect(jsonPath("$.data.boardId").value(is(1)))
.andDo(print());
then(this.boardService).should().createBoard(any(CreateRequest.class));
}

@DisplayName("게시판 수정 테스트 - 성공")
@Test
@WithMockUser
void updateBoardTest_success() throws Exception {
//given
UpdateResponse updateResponse = BoardFactory.mockUpdateResponses().get(0);
given(this.boardService.updateBoard(any(UpdateRequest.class)))
.willReturn(updateResponse);

//when
ResultActions perform = mockMvc.perform(multipart("/api/v1/boards/update")
.file(FileFactory.getTestImage1())
.param("boardId", "1")
.param("title", "boardTitle")
.param("content", "boardContent")
.param("boardType", "NOTICE")
.param("deadLineDate", "2016-10-15 00:00:00"));

//then
perform.andExpect(status().isOk())
.andExpect(jsonPath("$.message").value(containsString(UPDATE_BOARD_SUCCESS.getMessage())))
.andExpect(jsonPath("$.data.boardId").value(is(1)))
.andDo(print());
then(this.boardService).should().updateBoard(any(UpdateRequest.class));
}
// @DisplayName("게시판 작성 테스트 - 성공")
// @Test
// @WithMockUser
// void createBoardTest_success() throws Exception {
// //given
// CreateResponse createResponse = BoardFactory.mockCreateResponses().get(0);
// given(boardService.createBoard(any(CreateRequest.class)))
// .willReturn(createResponse);
// //when
// ResultActions perform = mockMvc.perform(multipart("/api/v1/boards")
// .file(FileFactory.getTestImage1())
// .param("title", "boardTitle")
// .param("content", "boardContent")
// .param("boardType", "NOTICE")
// .param("deadLineDate", "2016-10-15 00:00:00"));
//
// //then
// perform.andExpect(status().isCreated())
// .andExpect(jsonPath("$.message").value(containsString(CREATE_BOARD_SUCCESS.getMessage())))
// .andExpect(jsonPath("$.data.boardId").value(is(1)))
// .andDo(print());
// then(this.boardService).should().createBoard(any(CreateRequest.class));
// }
//
// @DisplayName("게시판 수정 테스트 - 성공")
// @Test
// @WithMockUser
// void updateBoardTest_success() throws Exception {
// //given
// UpdateResponse updateResponse = BoardFactory.mockUpdateResponses().get(0);
// given(this.boardService.updateBoard(any(UpdateRequest.class)))
// .willReturn(updateResponse);
//
// //when
// ResultActions perform = mockMvc.perform(multipart("/api/v1/boards/update")
// .file(FileFactory.getTestImage1())
// .param("boardId", "1")
// .param("title", "boardTitle")
// .param("content", "boardContent")
// .param("boardType", "NOTICE")
// .param("deadLineDate", "2016-10-15 00:00:00"));
//
// //then
// perform.andExpect(status().isOk())
// .andExpect(jsonPath("$.message").value(containsString(UPDATE_BOARD_SUCCESS.getMessage())))
// .andExpect(jsonPath("$.data.boardId").value(is(1)))
// .andDo(print());
// then(this.boardService).should().updateBoard(any(UpdateRequest.class));
// }

@DisplayName("게시판 조회 테스트 - 성공")
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,48 +76,48 @@ static void afterAll() {
securityUtilsMock.close();
}

@DisplayName("게시판 작성 테스트 - 성공")
@Test
void createBoardTest_success() {
//given
CreateRequest createRequest = BoardFactory.mockCreateRequests().get(0);
Board board = BoardFactory.mockBoards().get(0);
board.setImages(extractImageFrom(createRequest));
given(this.boardRepository.save(any(Board.class))).willReturn(board);

// when
CreateResponse createResponse = this.boardService.createBoard(createRequest);

// then
assertThat(createResponse.getBoardId()).isNotNull();
then(this.boardRepository).should().save(any(Board.class));
}

@DisplayName("게시판 수정 테스트 - 성공")
@Test
void updateBoardTest() {
//given
UpdateRequest updateRequest = BoardFactory.mockUpdateRequests().get(0);
Board board = BoardFactory.mockBoards().get(0);
board.setUser(user);
board.setImages(extractImageFrom(updateRequest));
given(this.boardRepository.findNotDeletedByBoardId(anyLong())).willReturn(Optional.of(board));
given(this.imageService.saveImages(updateRequest.getFiles())).willReturn(extractImageFrom(updateRequest));
UpdateResponse response = UpdateResponse.builder()
.boardId(101L)
.build();

// when
UpdateResponse updateResponse = this.boardService.updateBoard(updateRequest);

// then
assertThat(updateResponse)
.usingRecursiveComparison()
.isEqualTo(response);
then(this.boardRepository).should().findNotDeletedByBoardId(anyLong());
then(this.imageService).should(times(2)).deleteImage(any());
then(this.imageService).should().saveImages(updateRequest.getFiles());
}
// @DisplayName("게시판 작성 테스트 - 성공")
// @Test
// void createBoardTest_success() {
// //given
// CreateRequest createRequest = BoardFactory.mockCreateRequests().get(0);
// Board board = BoardFactory.mockBoards().get(0);
// board.setImages(extractImageFrom(createRequest));
// given(this.boardRepository.save(any(Board.class))).willReturn(board);
//
// // when
// CreateResponse createResponse = this.boardService.createBoard(createRequest);
//
// // then
// assertThat(createResponse.getBoardId()).isNotNull();
// then(this.boardRepository).should().save(any(Board.class));
// }
//
// @DisplayName("게시판 수정 테스트 - 성공")
// @Test
// void updateBoardTest() {
// //given
// UpdateRequest updateRequest = BoardFactory.mockUpdateRequests().get(0);
// Board board = BoardFactory.mockBoards().get(0);
// board.setUser(user);
// board.setImages(extractImageFrom(updateRequest));
// given(this.boardRepository.findNotDeletedByBoardId(anyLong())).willReturn(Optional.of(board));
// given(this.imageService.saveImages(updateRequest.getFiles())).willReturn(extractImageFrom(updateRequest));
// UpdateResponse response = UpdateResponse.builder()
// .boardId(101L)
// .build();
//
// // when
// UpdateResponse updateResponse = this.boardService.updateBoard(updateRequest);
//
// // then
// assertThat(updateResponse)
// .usingRecursiveComparison()
// .isEqualTo(response);
// then(this.boardRepository).should().findNotDeletedByBoardId(anyLong());
// then(this.imageService).should(times(2)).deleteImage(any());
// then(this.imageService).should().saveImages(updateRequest.getFiles());
// }

@DisplayName("게시판 삭제 테스트 - 성공")
@Test
Expand Down

0 comments on commit 23b6e63

Please sign in to comment.