-
Notifications
You must be signed in to change notification settings - Fork 13
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/refactoring #354
base: master
Are you sure you want to change the base?
Feature/refactoring #354
Conversation
…링, 메서드 이름 개선, 가독성 향상
private static final String COOKIE_NAME = "myCookie"; | ||
private static final String COOKIE_CONTENTS = "hello"; | ||
private static final int COOKIE_MAX_AGE = 180; | ||
|
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.
중복을 제거하고 가독성 향상을 위해 상수 추가
.clientId("1234") | ||
.redirectUri("http://localhost/api/login/oauth2/code/kakao") | ||
.scopes(Set.of("gender", "profile_image", "account_email", "profile_nickname")) | ||
.state("state1934") |
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.
중복되는 부분 함수로 처리
|
||
// when | ||
String serializedRequest = CookieUtils.serialize(request); | ||
|
||
// then | ||
assertTrue(Base64.isBase64(serializedRequest)); |
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.
assertTrue를 assertThat으로 변경
public void setUp() { | ||
repository = new HttpCookieOAuth2AuthorizationRequestRepository(); | ||
} | ||
|
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.
repository 객체를 각 테스트 메서드에서 개별적으로 초기화하는 대신 @beforeeach 메서드를 사용하여 모든 테스트가 실행되기 전에 한 번만 초기화하도록 한다.
assert savedCookie != null; | ||
assertTrue(Base64.isBase64(savedCookie.getValue())); | ||
assertThat(savedCookie).isNotNull(); | ||
assertThat(Base64.isBase64(savedCookie.getValue())).isTrue(); |
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.
assertTrue를 assertThat으로 수정
assertTrue(cookie.getValue().isBlank() && cookie.getMaxAge() == 0); | ||
assertThat(cookie).isNotNull(); | ||
assertThat(cookie.getValue()).isBlank(); | ||
assertThat(cookie.getMaxAge()).isEqualTo(0); |
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.
assertTrue를 assertThat으로 수정
} catch (InvocationTargetException | InstantiationException | IllegalAccessException ignored) { | ||
return null; | ||
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) { | ||
throw new RuntimeException("Failed to create OAuth2AuthorizationRequest", e); |
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.
예외처리시 null을 반환하는 것보다, 해당 정보를 반환하여 문제를 알리도록 변경
private static final String VALID_REDIRECT_URL = "https://www.inhabas.com"; | ||
private static final String INVALID_REDIRECT_URL = "https://www.unauthorized_url.com"; | ||
private static final String ERROR_CODE = OAuth2ErrorCodes.INVALID_REQUEST; | ||
|
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.
중복 방지와 가독성을 위한 상수 추가
@@ -12,7 +12,7 @@ public class CollegeTest { | |||
|
|||
@DisplayName("College 타입에 제목을 저장한다.") | |||
@Test | |||
public void College_is_OK() { | |||
public void saveValidCollegeName() { |
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.
메서드 이름 개선
add(majorInfo3); | ||
} | ||
}; | ||
|
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.
함수로 따로 처리하여 가독성 향상
cookie/CookieUtilsTest.java : JUnit방식의 전통적인 가독성이 떨어지는 코드를 개선, 중복 코드 분리, 가독성을 위해 상수 사용
cookie/HttpCookieOAuth2HttpCookieOAuth2AuthorizationRequestRepositoryTest.java : BeforeEach 추가, Unit방식의 전통적인 가독성이 떨어지는 코드를 개선, 중복 코드 분리, 가독성을 위해 상수 사용
handler/Oauth2AuthenticationFailureHandlerTest.java : 중복 코드 메서드 분리, URL과 같은 반복적으로 사용되는 문자열은 상수로 정의하여 코드의 가독성 증가
handler/Oauth2AuthenticationFailureHandlerTest.java : 중복 코드 메서드 분리, URL과 같은 반복적으로 사용되는 문자열은 상수로 정의하여 코드의 가독성 증가, 오타 수정
majorInfo/domain/valueObject/CollegeTest : 메서드 이름 개선
majorInfo/domain/valueObject/majorTest : 메서드 이름 개선
majorInfo/usecase/MajorInfoTest : createSampleMajorInfos와 createMajorInfo 메서드를 추가, 메서드 이름 개선
[build Message]
BUILD SUCCESSFUL in 27s