-
Notifications
You must be signed in to change notification settings - Fork 2
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
8 changed files
with
70 additions
and
37 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
7 changes: 7 additions & 0 deletions
7
...main/java/umc/kkijuk/server/common/domian/exception/ConfirmPasswordMismatchException.java
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package umc.kkijuk.server.common.domian.exception; | ||
|
||
public class ConfirmPasswordMismatchException extends RuntimeException { | ||
public ConfirmPasswordMismatchException() { | ||
super("Passwords do not match"); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import umc.kkijuk.server.member.domain.MarketingAgree; | ||
import umc.kkijuk.server.member.domain.Member; | ||
import umc.kkijuk.server.member.domain.State; | ||
import umc.kkijuk.server.member.dto.MemberJoinDto; | ||
import umc.kkijuk.server.member.service.MemberService; | ||
import umc.kkijuk.server.recruit.domain.Recruit; | ||
import umc.kkijuk.server.recruit.domain.RecruitStatus; | ||
|
@@ -76,9 +77,8 @@ class IntroduceControllerTest { | |
|
||
@BeforeEach | ||
public void Init() { | ||
Member member = new Member("[email protected]", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
Long savedId = memberService.join(member); | ||
requestMember = memberService.findOne(savedId); | ||
MemberJoinDto memberJoinDto = new MemberJoinDto("[email protected]", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
requestMember = memberService.join(memberJoinDto); | ||
} | ||
|
||
@Test | ||
|
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import umc.kkijuk.server.member.controller.response.MemberFieldResponse; | ||
import umc.kkijuk.server.member.controller.response.MemberInfoResponse; | ||
import umc.kkijuk.server.member.controller.response.ResultResponse; | ||
|
@@ -48,7 +49,8 @@ public void setup() { | |
// Given | ||
Member member1 = new Member("[email protected]", "홍길동", "010-1234-5678", | ||
LocalDate.parse("1999-03-31"), "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
memberJpaRepository.save(member1); | ||
Member savedMember = memberJpaRepository.save(member1); | ||
|
||
// When | ||
ResponseEntity<MemberInfoResponse> response = restTemplate.getForEntity("/member/myPage/info", MemberInfoResponse.class); | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package umc.kkijuk.server.member.service; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
@@ -9,6 +11,7 @@ | |
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import umc.kkijuk.server.common.domian.exception.ConfirmPasswordMismatchException; | ||
import umc.kkijuk.server.member.domain.MarketingAgree; | ||
import umc.kkijuk.server.member.domain.Member; | ||
import umc.kkijuk.server.member.domain.State; | ||
|
@@ -19,6 +22,8 @@ | |
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
|
@@ -34,20 +39,36 @@ public class MemberServiceTest { | |
@Autowired | ||
private TestRestTemplate restTemplate; | ||
|
||
private String testMemberEmail = "[email protected]"; | ||
@Test | ||
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD) | ||
public void 유저정보db저장및조회() throws Exception { | ||
// given | ||
Member member1 = new Member("[email protected]", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
MemberJoinDto memberJoinDto = new MemberJoinDto(testMemberEmail, "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
|
||
// when | ||
Long savedId = memberService.join(member1); | ||
Optional<Member> member2 = memberJpaRepository.findById(savedId); | ||
Member joinMember = memberService.join(memberJoinDto); | ||
|
||
// then | ||
assertEquals(member1, member2.get()); | ||
assertAll( | ||
() -> assertEquals(joinMember.getEmail(), testMemberEmail), | ||
() -> assertEquals(joinMember.getName(), "홍길동") | ||
); | ||
} | ||
|
||
@Test | ||
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD) | ||
public void joinExceptionWIthPasswordIncorrect() { | ||
// given | ||
MemberJoinDto memberJoinDto = new MemberJoinDto(testMemberEmail, "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", "incorrectPassword", MarketingAgree.BOTH, State.ACTIVATE); | ||
|
||
// when | ||
// then | ||
assertThatThrownBy(() -> memberService.join(memberJoinDto)) | ||
.isInstanceOf(ConfirmPasswordMismatchException.class); | ||
} | ||
|
||
|
||
@Test | ||
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD) | ||
public void 회원가입성공() { | ||
|
@@ -97,6 +118,4 @@ public class MemberServiceTest { | |
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); | ||
assertThat(response.getBody()).contains("Passwords do not match"); | ||
} | ||
|
||
|
||
} |