Skip to content
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

feature/authTestCode #5

Open
wants to merge 14 commits into
base: feature/approve
Choose a base branch
from
Prev Previous commit
Next Next commit
tset execute_refreshTokenIsNull
  • Loading branch information
tlsgmltjd committed Mar 2, 2024
commit 20e101a1387a4f60e4a21318e7cac39d65e0d035
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package team.themoment.officialgsm.domain.auth.usecase;

import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import team.themoment.officialgsm.common.exception.CustomException;
import team.themoment.officialgsm.domain.auth.dto.ReissueTokenDto;
import team.themoment.officialgsm.domain.auth.spi.TokenProvider;
import team.themoment.officialgsm.domain.token.RefreshToken;
@@ -17,8 +17,11 @@
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.never;


@ExtendWith(MockitoExtension.class)
@@ -64,4 +67,14 @@ void execute() {
assertThat(reissueTokenDto.getAccessToken()).isEqualTo("1");
assertThat(reissueTokenDto.getRefreshToken()).isEqualTo("1");
}

@Test
void execute_refreshTokenIsNull() {
// given & when
assertThrows(CustomException.class, () -> tokenReissueUseCase.execute(null));

// then
verify(userRepository, never()).findByOauthId(any());
verify(refreshTokenRepository, never()).save(any());
}
}