-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JT-81] AuthenticationFilter 테스트 작성 #70
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions
7
module-domain/domain-member/src/test/java/shop/jtoon/MemberDomainApplicationTest.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 shop.jtoon; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class MemberDomainApplicationTest { | ||
} |
170 changes: 170 additions & 0 deletions
170
module-domain/domain-member/src/test/java/shop/jtoon/repository/MemberRepositoryTest.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,170 @@ | ||
package shop.jtoon.repository; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static shop.jtoon.entity.Gender.*; | ||
import static shop.jtoon.entity.LoginType.*; | ||
import static shop.jtoon.entity.Role.*; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
|
||
import shop.jtoon.config.JpaConfig; | ||
import shop.jtoon.entity.Gender; | ||
import shop.jtoon.entity.LoginType; | ||
import shop.jtoon.entity.Member; | ||
import shop.jtoon.entity.Role; | ||
|
||
@DataJpaTest | ||
@Import(JpaConfig.class) | ||
class MemberRepositoryTest { | ||
|
||
@Autowired | ||
MemberRepository memberRepository; | ||
|
||
Member member; | ||
|
||
@BeforeEach | ||
void initMember() { | ||
member = Member.builder() | ||
.email("abc@naver.com") | ||
.password("Testing!123") | ||
.name("HI") | ||
.nickname("Unique") | ||
.gender(MALE) | ||
.phone("01012345678") | ||
.role(USER) | ||
.loginType(LOCAL) | ||
.build(); | ||
} | ||
|
||
@Test | ||
@DisplayName("MemberRepository 빈 등록 성공") | ||
void MemberRepository_bean_NotNull() { | ||
assertThat(memberRepository).isNotNull(); | ||
} | ||
|
||
@Test | ||
@DisplayName("멤버 저장 성공") | ||
void MemberRepository_save_success() { | ||
// given, when | ||
Member saved = memberRepository.save(member); | ||
|
||
// then | ||
assertThat(saved.getId()).isNotNull(); | ||
} | ||
|
||
@Nested | ||
@DisplayName("멤버 엔티티 생성 실패 테스트") | ||
class MemberEntityTest { | ||
|
||
String email = "abc@gmail.com"; | ||
String password = "testing!123"; | ||
String name = "HI"; | ||
String nickname = "Unique"; | ||
Gender gender = MALE; | ||
String phone = "01012345678"; | ||
Role role = USER; | ||
LoginType loginType = LOCAL; | ||
|
||
@Test | ||
@DisplayName("멤버 엔티티 이메일 null 테스트") | ||
void Member_email_null_fail() { | ||
// given, when, then | ||
assertThatThrownBy(() -> Member.builder() | ||
.email(null) | ||
.password(password) | ||
.name(name) | ||
.nickname(nickname) | ||
.gender(gender) | ||
.phone(phone) | ||
.role(role) | ||
.loginType(loginType) | ||
.build()).isInstanceOf(NullPointerException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("멤버 엔티티 비밀번호 null 테스트") | ||
void Member_password_null_fail() { | ||
// given, when, then | ||
assertThatThrownBy(() -> Member.builder() | ||
.email(email) | ||
.password(null) | ||
.name(name) | ||
.nickname(nickname) | ||
.gender(gender) | ||
.phone(phone) | ||
.role(role) | ||
.loginType(loginType) | ||
.build()).isInstanceOf(NullPointerException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("멤버 엔티티 이름 null 테스트") | ||
void Member_name_null_fail() { | ||
// given, when, then | ||
assertThatThrownBy(() -> Member.builder() | ||
.email(email) | ||
.password(password) | ||
.name(null) | ||
.nickname(nickname) | ||
.gender(gender) | ||
.phone(phone) | ||
.role(role) | ||
.loginType(loginType) | ||
.build()).isInstanceOf(NullPointerException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("멤버 엔티티 닉네임 null 테스트") | ||
void Member_nickname_null_fail() { | ||
// given, when, then | ||
assertThatThrownBy(() -> Member.builder() | ||
.email(email) | ||
.password(password) | ||
.name(name) | ||
.nickname(null) | ||
.gender(gender) | ||
.phone(phone) | ||
.role(role) | ||
.loginType(loginType) | ||
.build()).isInstanceOf(NullPointerException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("멤버 엔티티 성별 null 테스트") | ||
void Member_gender_null_fail() { | ||
// given, when, then | ||
assertThatThrownBy(() -> Member.builder() | ||
.email(email) | ||
.password(password) | ||
.name(name) | ||
.nickname(nickname) | ||
.gender(null) | ||
.phone(phone) | ||
.role(role) | ||
.loginType(loginType) | ||
.build()).isInstanceOf(NullPointerException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("멤버 엔티티 전화번호 null 테스트") | ||
void Member_phone_null_fail() { | ||
// given, when, then | ||
assertThatThrownBy(() -> Member.builder() | ||
.email(email) | ||
.password(password) | ||
.name(name) | ||
.nickname(nickname) | ||
.gender(gender) | ||
.phone(null) | ||
.role(role) | ||
.loginType(loginType) | ||
.build()).isInstanceOf(NullPointerException.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
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
module-internal/core-web/src/test/java/shop/jtoon/security/SecurityApplicationTest.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 shop.jtoon.security; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SecurityApplicationTest { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기본 JPA Repo test까지 하셨네요.. 대박!