Skip to content

Commit

Permalink
fix: 빌드 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jihyo-j committed May 23, 2024
1 parent 256240e commit bd21f8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,15 @@ void setup() {
.refreshToken("null")
.build();

// JwtFactory를 사용하여 testReceiver에 대한 토큰 생성
JwtFactory jwtFactoryForReceiver = new JwtFactory(
testReceiver.getEmail(),
new Date(),
new Date(new Date().getTime() + 14 * 24 * 60 * 60 * 1000), // 14일 후 만료
new HashMap<>()
);

String receiverToken = jwtFactoryForReceiver.createToken(jwtProperties);
System.out.println();
testReceiver.updateRefreshToken(receiverToken);

// testMember 인증
when(memberRepository.save(any(Member.class))).thenReturn(testMember);
when(memberRepository.findByEmail("[email protected]")).thenReturn(Optional.of(testMember));
when(memberRepository.findById(1L)).thenReturn(Optional.of(testMember));

// testReceiver 인증
when(memberRepository.save(any(Member.class))).thenReturn(testReceiver);
when(memberRepository.findByEmail("[email protected]")).thenReturn(Optional.of(testReceiver));
when(memberRepository.findById(2L)).thenReturn(Optional.of(testReceiver));
when(memberRepository.findById(1L)).thenReturn(Optional.of(testReceiver));

//토큰 생성
refreshToken = tokenProvider.generateToken(testMember, Duration.ofDays(14)); // 임시 refreshToken 생성
refreshToken = tokenProvider.generateToken(testReceiver, Duration.ofDays(14));

Expand All @@ -153,7 +139,6 @@ void setup() {
testReceiver.updateRefreshToken(refreshToken);
when(memberRepository.save(testReceiver)).thenReturn(testReceiver);

// 토큰으로 사용자 return
when(memberRepository.findByRefreshToken(refreshToken)).thenReturn(Optional.of(testMember));
when(memberRepository.findByRefreshToken(refreshToken)).thenReturn(Optional.of(testReceiver));

Expand Down Expand Up @@ -225,7 +210,7 @@ public void getAllAnswersTest() throws Exception {
.andExpect(status().isOk())
.andExpect(jsonPath("$.content[0].content").value("이것은 답변입니다."));
}
/*
/*
@Test
@DisplayName("답변 수정 테스트(): 답변을 수정한다.")
public void updateAnswerTest() throws Exception {
Expand All @@ -242,25 +227,9 @@ public void updateAnswerTest() throws Exception {
testMember.getNickname(), "안녕", true, "https://link.com", "노래 제목", "가수 이름", "https://audio.url",
"https://image.url", LocalDateTime.now()
);
Music music = Music.builder()
.musicName("노래 제목")
.musicSinger("가수 이름")
.musicAudioUrl("https://audio.url")
.build();
Answer answer = Answer.builder()
.id(1L)
.question(testQuestion)
.member(testMember)
.content("이것은 답변입니다.")
.profileOnOff(true)
.linkAttachments("https://link.com")
.music(music)
.imageUrl("https://image.url")
.build();
// Mock 설정
when(answerRepository.findByAnswerId(1L)).thenReturn(Optional.of(answer));
when(answerRepository.findByAnswerId(1L)).thenReturn(Optional.of(testAnswer));
when(answerService.updateAnswer(eq(1L), any(AnswerCreateRequest.class), any(MockMultipartFile.class)))
.thenReturn(answerDetailResponse);
Expand Down Expand Up @@ -293,7 +262,7 @@ public void deleteAnswerTest() throws Exception {
.musicAudioUrl("https://audio.url")
.build();
Answer answer = Answer.builder()
testAnswer = Answer.builder()
.id(1L)
.question(testQuestion)
.member(testMember)
Expand All @@ -304,10 +273,7 @@ public void deleteAnswerTest() throws Exception {
.imageUrl("https://image.url")
.build();
when(answerRepository.save(any(Answer.class))).thenReturn(answer);
answer = answerRepository.save(answer);
when(answerRepository.findByAnswerId(1L)).thenReturn(Optional.of(answer));
when(answerRepository.findByAnswerId(1L)).thenReturn(Optional.of(testAnswer));
doNothing().when(answerService).deleteAnswer(eq(1L));
// When
Expand All @@ -316,7 +282,7 @@ public void deleteAnswerTest() throws Exception {
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNoContent());
}
*/
*/
@Test
@DisplayName("답변 반응 확인 테스트(): 답변에 대한 반응 상태를 확인한다.")
public void hasReactedTest() throws Exception {
Expand All @@ -329,4 +295,5 @@ public void hasReactedTest() throws Exception {
.andExpect(status().isOk())
.andExpect(jsonPath("$.length()").value(0));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void testOauthSignUp() throws Exception {
when(loginService.loginWithExistingUser(any(KakaoUserInfoDto.class), any(LoginRequest.SignUp.class))).thenReturn(signUpResponse);
when(loginService.signUpNewUser(any(KakaoUserInfoDto.class), any(LoginRequest.SignUp.class))).thenReturn(signUpResponse);

LoginRequest.SignUp signUpRequest = new LoginRequest.SignUp(MemberType.KAKAO, "김예찬", "fcmToken");
LoginRequest.SignUp signUpRequest = new LoginRequest.SignUp(MemberType.KAKAO, "김예찬");

// when
mockMvc.perform(post("/api/auth/login")
Expand Down

0 comments on commit bd21f8c

Please sign in to comment.