-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
import com.psq.backend.member.exception.NoSuchMemberException; | ||
import com.psq.backend.problem.domain.Category; | ||
import com.psq.backend.problem.domain.Problem; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -20,13 +19,13 @@ | |
|
||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class MemberServiceTest extends ServiceTest { | ||
private MockHttpSession session; | ||
private SessionInfo sessionInfo; | ||
@BeforeEach | ||
void setup() { | ||
member = new Member("[email protected]", encodePassword, salt); | ||
|
@@ -42,7 +41,6 @@ void setup() { | |
|
||
request = new MockHttpServletRequest(); | ||
session = new MockHttpSession(); | ||
sessionInfo = new SessionInfo(member.getId(), member.getEmail()); | ||
} | ||
|
||
@Test | ||
|
@@ -126,6 +124,13 @@ void logoutTest() { | |
memberService.logout(session); | ||
|
||
// then | ||
Assertions.assertThat(session.isInvalid()).isTrue(); | ||
assertThat(session.isInvalid()).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("계정을 삭제된다") | ||
public void deleteMemberTest() throws NoSuchMethodException { | ||
// given, when, then | ||
assertDoesNotThrow(() -> memberService.delete(member)); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -15,8 +15,10 @@ | |
|
||
import static com.psq.backend.common.docs.ApiDocumentUtil.getDocumentRequest; | ||
import static com.psq.backend.common.docs.ApiDocumentUtil.getDocumentResponse; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.*; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
|
@@ -30,9 +32,11 @@ void setup() { | |
member = new Member("[email protected]", "123", "salt"); | ||
ReflectionTestUtils.setField(member, "id", 1L); | ||
|
||
session = new MockHttpSession(); | ||
sessionInfo = new SessionInfo(member.getId(), member.getEmail()); | ||
session = new MockHttpSession(); | ||
|
||
session.setAttribute("sessionInfo", sessionInfo); | ||
when(sessionUtil.getSessionInfo()).thenReturn(sessionInfo); | ||
} | ||
|
||
@Test | ||
|
@@ -265,4 +269,19 @@ public void logoutTest() throws Exception { | |
getDocumentResponse() | ||
)); | ||
} | ||
|
||
@Test | ||
@DisplayName("계정을 삭제한다") | ||
public void deleteTest() throws Exception { | ||
// when, then | ||
mockMvc.perform(delete(baseURL) | ||
.session(session) | ||
.contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isNoContent()) | ||
.andDo(print()) | ||
.andDo(document("member/delete/success", | ||
getDocumentRequest(), | ||
getDocumentResponse() | ||
)); | ||
} | ||
} |