- 테스트 코드 리팩토링: LocalDateTime -> Month 상수 활용
eapim-portal CI / build (push) Waiting to run
eapim-portal Test / test (push) Waiting to run

- assertEquals(false) -> assertFalse로 개선
- Boolean.FALSE 사용으로 코드 명확성 향상
This commit is contained in:
Rinjae(gf63)
2026-09-15 16:06:25 +09:00
parent f7531412be
commit 24103d47f9
2 changed files with 13 additions and 11 deletions
@@ -6,6 +6,7 @@ import com.eactive.apim.portal.apps.agreements.dto.AgreementTabDTO;
import com.eactive.apim.portal.apps.agreements.dto.AgreementsDTO; import com.eactive.apim.portal.apps.agreements.dto.AgreementsDTO;
import com.eactive.apim.portal.apps.agreements.service.AgreementsFacade; import com.eactive.apim.portal.apps.agreements.service.AgreementsFacade;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Month;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -21,6 +22,7 @@ import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -98,8 +100,8 @@ class AgreementsControllerTest {
@Test @Test
@DisplayName("tab 이 없으면 노출 목록의 첫 번째 약관을 연다") @DisplayName("tab 이 없으면 노출 목록의 첫 번째 약관을 연다")
void showTerms_defaultsToFirstDisplayType() { void showTerms_defaultsToFirstDisplayType() {
AgreementsDTO latest = agreement("이용약관 v2", LocalDateTime.of(2026, 3, 1, 0, 0)); AgreementsDTO latest = agreement("이용약관 v2", LocalDateTime.of(2026, Month.MARCH, 1, 0, 0));
AgreementsDTO older = agreement("이용약관 v1", LocalDateTime.of(2025, 1, 1, 0, 0)); AgreementsDTO older = agreement("이용약관 v1", LocalDateTime.of(2025, Month.JANUARY, 1, 0, 0));
when(agreementTypeConfigService.getDisplayTypes()).thenReturn(Arrays.asList( when(agreementTypeConfigService.getDisplayTypes()).thenReturn(Arrays.asList(
AgreementType.TERMS_OF_USE, AgreementType.NOTIFICATION_CONSENT)); AgreementType.TERMS_OF_USE, AgreementType.NOTIFICATION_CONSENT));
@@ -119,13 +121,13 @@ class AgreementsControllerTest {
assertEquals(Arrays.asList("terms", "notification"), assertEquals(Arrays.asList("terms", "notification"),
tabs.stream().map(AgreementTabDTO::getTab).collect(Collectors.toList())); tabs.stream().map(AgreementTabDTO::getTab).collect(Collectors.toList()));
assertTrue(tabs.get(0).isActive()); assertTrue(tabs.get(0).isActive());
assertEquals(false, tabs.get(1).isActive()); assertFalse(tabs.get(1).isActive());
} }
@Test @Test
@DisplayName("tab 슬러그가 노출 목록에 있으면 그 약관을 연다") @DisplayName("tab 슬러그가 노출 목록에 있으면 그 약관을 연다")
void showTerms_selectsRequestedTab() { void showTerms_selectsRequestedTab() {
AgreementsDTO notification = agreement("알림 수신 동의서", LocalDateTime.of(2026, 2, 1, 0, 0)); AgreementsDTO notification = agreement("알림 수신 동의서", LocalDateTime.of(2026, Month.FEBRUARY, 1, 0, 0));
when(agreementTypeConfigService.getDisplayTypes()).thenReturn(Arrays.asList( when(agreementTypeConfigService.getDisplayTypes()).thenReturn(Arrays.asList(
AgreementType.TERMS_OF_USE, AgreementType.NOTIFICATION_CONSENT)); AgreementType.TERMS_OF_USE, AgreementType.NOTIFICATION_CONSENT));
@@ -139,14 +141,14 @@ class AgreementsControllerTest {
assertEquals(AgreementType.NOTIFICATION_CONSENT.getCode(), model.getAttribute("agreementType")); assertEquals(AgreementType.NOTIFICATION_CONSENT.getCode(), model.getAttribute("agreementType"));
List<AgreementTabDTO> tabs = tabs(); List<AgreementTabDTO> tabs = tabs();
assertEquals(false, tabs.get(0).isActive()); assertFalse(tabs.get(0).isActive());
assertTrue(tabs.get(1).isActive()); assertTrue(tabs.get(1).isActive());
} }
@Test @Test
@DisplayName("노출 목록에 없는 tab 은 첫 번째 탭으로 보정한다") @DisplayName("노출 목록에 없는 tab 은 첫 번째 탭으로 보정한다")
void showTerms_unknownTabFallsBackToFirst() { void showTerms_unknownTabFallsBackToFirst() {
AgreementsDTO privacyCollect = agreement("개인정보수집동의서", LocalDateTime.of(2026, 1, 5, 0, 0)); AgreementsDTO privacyCollect = agreement("개인정보수집동의서", LocalDateTime.of(2026, Month.JANUARY, 5, 0, 0));
// notification 은 노출 대상이 아니다 // notification 은 노출 대상이 아니다
when(agreementTypeConfigService.getDisplayTypes()) when(agreementTypeConfigService.getDisplayTypes())
@@ -164,7 +166,7 @@ class AgreementsControllerTest {
@Test @Test
@DisplayName("빈 tab 문자열도 첫 번째 탭으로 보정한다") @DisplayName("빈 tab 문자열도 첫 번째 탭으로 보정한다")
void showTerms_emptyTabFallsBackToFirst() { void showTerms_emptyTabFallsBackToFirst() {
AgreementsDTO terms = agreement("이용약관", LocalDateTime.of(2026, 1, 1, 0, 0)); AgreementsDTO terms = agreement("이용약관", LocalDateTime.of(2026, Month.JANUARY, 1, 0, 0));
when(agreementTypeConfigService.getDisplayTypes()) when(agreementTypeConfigService.getDisplayTypes())
.thenReturn(Collections.singletonList(AgreementType.TERMS_OF_USE)); .thenReturn(Collections.singletonList(AgreementType.TERMS_OF_USE));
@@ -180,8 +182,8 @@ class AgreementsControllerTest {
@Test @Test
@DisplayName("publishedOn 이 주어지면 해당 제정일의 개정본을 고른다") @DisplayName("publishedOn 이 주어지면 해당 제정일의 개정본을 고른다")
void showTerms_picksAgreementByPublishedOn() { void showTerms_picksAgreementByPublishedOn() {
AgreementsDTO latest = agreement("v2", LocalDateTime.of(2026, 3, 1, 9, 30)); AgreementsDTO latest = agreement("v2", LocalDateTime.of(2026, Month.MARCH, 1, 9, 30));
AgreementsDTO older = agreement("v1", LocalDateTime.of(2025, 1, 15, 0, 0)); AgreementsDTO older = agreement("v1", LocalDateTime.of(2025, Month.JANUARY, 15, 0, 0));
when(agreementTypeConfigService.getDisplayTypes()) when(agreementTypeConfigService.getDisplayTypes())
.thenReturn(Collections.singletonList(AgreementType.TERMS_OF_USE)); .thenReturn(Collections.singletonList(AgreementType.TERMS_OF_USE));
@@ -197,7 +199,7 @@ class AgreementsControllerTest {
@Test @Test
@DisplayName("일치하는 제정일이 없으면 첫 항목으로 되돌린다") @DisplayName("일치하는 제정일이 없으면 첫 항목으로 되돌린다")
void showTerms_unmatchedPublishedOnFallsBackToFirst() { void showTerms_unmatchedPublishedOnFallsBackToFirst() {
AgreementsDTO latest = agreement("v2", LocalDateTime.of(2026, 3, 1, 0, 0)); AgreementsDTO latest = agreement("v2", LocalDateTime.of(2026, Month.MARCH, 1, 0, 0));
when(agreementTypeConfigService.getDisplayTypes()) when(agreementTypeConfigService.getDisplayTypes())
.thenReturn(Collections.singletonList(AgreementType.TERMS_OF_USE)); .thenReturn(Collections.singletonList(AgreementType.TERMS_OF_USE));
@@ -143,7 +143,7 @@ class UserRegisterControllerAgreementTest {
assertEquals("apps/register/userRegister", view); assertEquals("apps/register/userRegister", view);
assertEquals("personal", model.getAttribute("registrationType")); assertEquals("personal", model.getAttribute("registrationType"));
assertEquals(false, model.getAttribute("isInvited")); assertEquals(Boolean.FALSE, model.getAttribute("isInvited"));
assertAgreementSettingsApplied(); assertAgreementSettingsApplied();
} }