-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from sjmjys954646/feature/3-branch-mentoring
Feature/3 branch mentoring
- Loading branch information
Showing
7 changed files
with
149 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ | |
import org.springframework.test.web.servlet.ResultActions; | ||
|
||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
|
@@ -60,7 +63,7 @@ void CreateMentorPostTest() { | |
|
||
//given | ||
User writer = User.builder() | ||
.email("anjdal6664@gmail.com") | ||
.email("john@example.com") | ||
.password("asdf1234!") | ||
.firstName("Jin") | ||
.lastName("Seung") | ||
|
@@ -91,7 +94,6 @@ void CreateMentorPostTest() { | |
MentorPostRequest.CreateDTO mentorPostRequest = new MentorPostRequest.CreateDTO(); | ||
mentorPostRequest.setTitle("title"); | ||
mentorPostRequest.setContent("content"); | ||
mentorPostRequest.setState(StateEnum.ACTIVE); | ||
mentorPostService.createMentorPost(mentorPostRequest, writer); | ||
|
||
MentorPost mentorPostFind = mentorPostJPARepostiory.findById(1); | ||
|
@@ -242,27 +244,17 @@ void updateMentorPostTest() | |
|
||
userJPARepository.save(writer); | ||
mentorPostService.createMentorPost(mentorPostRequest, writer); | ||
mentorPostService.updateMentorPost(mentorPostUpdated,1); | ||
mentorPostService.updateMentorPost(mentorPostUpdated,2); | ||
|
||
MentorPost mentorPostFind = mentorPostJPARepostiory.findById(1); | ||
Assertions.assertThat(1) | ||
MentorPost mentorPostFind = mentorPostJPARepostiory.findById(2); | ||
Assertions.assertThat(2) | ||
.isEqualTo(mentorPostFind.getId()); | ||
Assertions.assertThat(mentorPostUpdated.getTitle()) | ||
.isEqualTo(mentorPostFind.getTitle()); | ||
Assertions.assertThat(mentorPostUpdated.getContent()) | ||
.isEqualTo(mentorPostFind.getContent()); | ||
} | ||
|
||
|
||
@Test | ||
void mentorPostServiceTest() throws Exception { | ||
MentorPostResponse.MentorPostDTO mentorPostFind = mentorPostService.findMentorPost(1); | ||
|
||
String responseBody = om.writeValueAsString(mentorPostFind); | ||
|
||
System.out.println("test : " + responseBody); | ||
} | ||
|
||
@WithUserDetails(value = "[email protected]") | ||
@Test | ||
public void CreateMentorPostTestMVC() throws Exception { | ||
|
@@ -288,11 +280,10 @@ public void CreateMentorPostTestMVC() throws Exception { | |
//resultActions.andDo(MockMvcResultHandlers.print()).andDo(document); | ||
} | ||
|
||
@WithUserDetails(value = "[email protected]") | ||
@Test | ||
public void GetMentorPostTestMVC() throws Exception { | ||
|
||
int id = 1; | ||
int id = 2; | ||
|
||
// when | ||
ResultActions resultActions = mvc.perform( | ||
|
@@ -304,4 +295,32 @@ public void GetMentorPostTestMVC() throws Exception { | |
System.out.println("테스트 : "+responseBody); | ||
} | ||
|
||
@Test | ||
@DisplayName("DeleteTest") | ||
public void DeleteMentorPost() throws Exception{ | ||
int id = 2; | ||
mentorPostService.deleteMentorPost(id); | ||
|
||
MentorPost mentorPostFind = mentorPostJPARepostiory.findById(2); | ||
assertNull(mentorPostFind, "mentorPostNotFound"); | ||
} | ||
|
||
@Test | ||
@DisplayName("DoneTest") | ||
public void PatchDoneMentorPost() throws Exception{ | ||
int id = 1; | ||
|
||
MentorPostRequest.StateDTO stateDTO = new MentorPostRequest.StateDTO(); | ||
stateDTO.setStateEnum(StateEnum.DONE); | ||
mentorPostService.changeMentorPostStatus(stateDTO, id); | ||
} | ||
|
||
@Test | ||
void mentorPostServiceTest() throws Exception { | ||
List<MentorPostResponse.MentorPostAllWithTimeStampDTO> mentorPostFind = mentorPostService.findAllMentorPostWithTimeStamp(); | ||
|
||
String responseBody = om.writeValueAsString(mentorPostFind); | ||
|
||
System.out.println("전체조회테스트 : " + responseBody); | ||
} | ||
} |