-
Notifications
You must be signed in to change notification settings - Fork 7
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
모임과 맴버, 채팅에 대한Test Fixture 구현 #162
Merged
Merged
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions
39
backend/src/test/java/mouda/backend/fixture/ChatFixture.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,39 @@ | ||
package mouda.backend.fixture; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
import mouda.backend.chat.domain.Chat; | ||
|
||
public class ChatFixture { | ||
|
||
public static Chat getChatWithHogeeAtBasketballMoim() { | ||
return Chat.builder() | ||
.time(LocalTime.now()) | ||
.date(LocalDate.now()) | ||
.content("ㅎㅇㅎㅇ") | ||
.member(MemberFixture.getHogee()) | ||
.moim(MoimFixture.getBasketballMoim()) | ||
.build(); | ||
} | ||
|
||
public static Chat getChatWithAnnaAtCoffeeMoim() { | ||
return Chat.builder() | ||
.time(LocalTime.now()) | ||
.date(LocalDate.now()) | ||
.content("반갑읍니다") | ||
.member(MemberFixture.getAnna()) | ||
.moim(MoimFixture.getCoffeeMoim()) | ||
.build(); | ||
} | ||
|
||
public static Chat getChatWithTebahAtSoccerMoim() { | ||
return Chat.builder() | ||
.time(LocalTime.now()) | ||
.date(LocalDate.now()) | ||
.content("ㅎㅇㅎㅇ") | ||
.member(MemberFixture.getTebah()) | ||
.moim(MoimFixture.getSoccerMoim()) | ||
.build(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/src/test/java/mouda/backend/fixture/MemberFixture.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,24 @@ | ||
package mouda.backend.fixture; | ||
|
||
import mouda.backend.member.domain.Member; | ||
|
||
public class MemberFixture { | ||
|
||
public static Member getHogee() { | ||
return Member.builder() | ||
.nickname("hogee") | ||
.build(); | ||
} | ||
|
||
public static Member getAnna() { | ||
return Member.builder() | ||
.nickname("anna") | ||
.build(); | ||
} | ||
|
||
public static Member getTebah() { | ||
return Member.builder() | ||
.nickname("tebah") | ||
.build(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
backend/src/test/java/mouda/backend/fixture/MoimFixture.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,42 @@ | ||
package mouda.backend.fixture; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
import mouda.backend.moim.domain.Moim; | ||
|
||
public class MoimFixture { | ||
|
||
public static Moim getSoccerMoim() { | ||
return Moim.builder() | ||
.title("풋살할 사람?") | ||
.time(LocalTime.now().plusHours(1)) | ||
.date(LocalDate.now().plusDays(1)) | ||
.place("잠실 종합운동장") | ||
.description("잘하는 사람만 와라") | ||
.maxPeople(22) | ||
.build(); | ||
} | ||
|
||
public static Moim getBasketballMoim() { | ||
return Moim.builder() | ||
.title("농구할 사람?") | ||
.time(LocalTime.now().plusHours(1)) | ||
.date(LocalDate.now().plusDays(1)) | ||
.place("테바 집") | ||
.description("파주로 와라") | ||
.maxPeople(10) | ||
.build(); | ||
} | ||
|
||
public static Moim getCoffeeMoim() { | ||
return Moim.builder() | ||
.title("커피 마실 사람?") | ||
.time(LocalTime.now().plusHours(1)) | ||
.date(LocalDate.now().plusDays(1)) | ||
.place("안나 집") | ||
.description("커피 머신 들고와라") | ||
.maxPeople(100) | ||
.build(); | ||
} | ||
} |
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
51 changes: 25 additions & 26 deletions
51
backend/src/test/java/mouda/backend/security/JwtProviderTest.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 |
---|---|---|
@@ -1,45 +1,44 @@ | ||
package mouda.backend.security; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import mouda.backend.config.DatabaseCleaner; | ||
import mouda.backend.member.domain.Member; | ||
import mouda.backend.member.repository.MemberRepository; | ||
import org.junit.jupiter.api.AfterEach; | ||
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; | ||
|
||
import mouda.backend.config.DatabaseCleaner; | ||
import mouda.backend.fixture.MemberFixture; | ||
import mouda.backend.member.domain.Member; | ||
import mouda.backend.member.repository.MemberRepository; | ||
|
||
@SpringBootTest | ||
class JwtProviderTest { | ||
|
||
@Autowired | ||
JwtProvider jwtProvider; | ||
@Autowired | ||
JwtProvider jwtProvider; | ||
|
||
@Autowired | ||
MemberRepository memberRepository; | ||
@Autowired | ||
MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private DatabaseCleaner databaseCleaner; | ||
@Autowired | ||
private DatabaseCleaner databaseCleaner; | ||
|
||
@AfterEach | ||
void cleanUp() { | ||
databaseCleaner.cleanUp(); | ||
} | ||
@AfterEach | ||
void cleanUp() { | ||
databaseCleaner.cleanUp(); | ||
} | ||
|
||
@DisplayName("토큰을 발급한다.") | ||
@Test | ||
void createToken() { | ||
String nickname = "테바"; | ||
Member member = Member.builder() | ||
.nickname(nickname) | ||
.build(); | ||
Member savedMember = memberRepository.save(member); | ||
String token = jwtProvider.createToken(savedMember); | ||
@DisplayName("토큰을 발급한다.") | ||
@Test | ||
void createToken() { | ||
Member member = MemberFixture.getTebah(); | ||
Member savedMember = memberRepository.save(member); | ||
String token = jwtProvider.createToken(savedMember); | ||
|
||
String savedNickname = jwtProvider.extractNickname(token); | ||
String savedNickname = jwtProvider.extractNickname(token); | ||
|
||
assertThat(savedNickname).isEqualTo(nickname); | ||
} | ||
assertThat(savedNickname).isEqualTo(member.getNickname()); | ||
} | ||
} |
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.
픽스쳐 만들기 귀찮았나요? ㅎㅎ