From 78775716686ad2802af8a615f1ea56584eba2d83 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 14 Jul 2025 18:10:10 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat=20:=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=ED=86=A0=EB=A1=A0=20=ED=83=80=EC=9E=84=20=EB=B0=95=EC=8A=A4=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customize/CustomizeTimeBoxDomain.java | 72 ++++++++++++++ .../domain/customize/NormalTimeBoxDomain.java | 50 ++++++++++ .../debatetimer/domain/customize/Stance.java | 5 + .../customize/TimeBasedTimeBoxDomain.java | 70 +++++++++++++ .../customize/CustomizeTimeBoxDomainTest.java | 98 +++++++++++++++++++ .../customize/NormalTimeBoxDomainTest.java | 43 ++++++++ .../customize/TimeBasedTimeBoxDomainTest.java | 95 ++++++++++++++++++ 7 files changed, 433 insertions(+) create mode 100644 src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java create mode 100644 src/main/java/com/debatetimer/domain/customize/NormalTimeBoxDomain.java create mode 100644 src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java create mode 100644 src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java create mode 100644 src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java create mode 100644 src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java diff --git a/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java b/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java new file mode 100644 index 00000000..8f688379 --- /dev/null +++ b/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java @@ -0,0 +1,72 @@ +package com.debatetimer.domain.customize; + +import com.debatetimer.exception.custom.DTClientErrorException; +import com.debatetimer.exception.errorcode.ClientErrorCode; +import org.springframework.lang.Nullable; + +public abstract class CustomizeTimeBoxDomain { + + public static final int SPEECH_TYPE_MAX_LENGTH = 10; + public static final int SPEAKER_MAX_LENGTH = 5; + + private final Stance stance; + + private final String speechType; + + @Nullable + private final String speaker; + + protected CustomizeTimeBoxDomain(Stance stance, String speechType, @Nullable String speaker) { + validateStance(stance); + validateSpeechType(speechType); + validateSpeaker(speaker); + + this.stance = stance; + this.speechType = speechType; + this.speaker = speaker; + } + + private void validateStance(Stance stance) { + if (!isValidStance(stance)) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_STANCE); + } + } + + protected abstract boolean isValidStance(Stance stance); + + private void validateSpeechType(String speechType) { + if (speechType == null || speechType.isBlank() || speechType.length() > SPEECH_TYPE_MAX_LENGTH) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_SPEECH_TYPE_LENGTH); + } + } + + private void validateSpeaker(String speaker) { + if (speaker != null && speaker.length() > SPEAKER_MAX_LENGTH) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_SPEAKER_LENGTH); + } + } + + public final Stance getStance() { + return stance; + } + + public final String getSpeechType() { + return speechType; + } + + @Nullable + public final String getSpeaker() { + return speaker; + } + + public abstract CustomizeBoxType getBoxType(); + + @Nullable + public abstract Integer getTime(); + + @Nullable + public abstract Integer getTimePerTeam(); + + @Nullable + public abstract Integer getTimePerSpeaking(); +} diff --git a/src/main/java/com/debatetimer/domain/customize/NormalTimeBoxDomain.java b/src/main/java/com/debatetimer/domain/customize/NormalTimeBoxDomain.java new file mode 100644 index 00000000..a17800d8 --- /dev/null +++ b/src/main/java/com/debatetimer/domain/customize/NormalTimeBoxDomain.java @@ -0,0 +1,50 @@ +package com.debatetimer.domain.customize; + +import com.debatetimer.exception.custom.DTClientErrorException; +import com.debatetimer.exception.errorcode.ClientErrorCode; +import org.springframework.lang.Nullable; + +public final class NormalTimeBoxDomain extends CustomizeTimeBoxDomain { + + private final int time; + + public NormalTimeBoxDomain(Stance stance, String speechType, @Nullable String speaker, Integer time) { + super(stance, speechType, speaker); + + validateTime(time); + this.time = time; + } + + private void validateTime(Integer time) { + if (time == null || time <= 0) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_TIME); + } + } + + @Override + protected boolean isValidStance(Stance stance) { + return true; + } + + @Override + public CustomizeBoxType getBoxType() { + return CustomizeBoxType.NORMAL; + } + + @Override + public Integer getTime() { + return time; + } + + @Nullable + @Override + public Integer getTimePerTeam() { + return null; + } + + @Nullable + @Override + public Integer getTimePerSpeaking() { + return null; + } +} diff --git a/src/main/java/com/debatetimer/domain/customize/Stance.java b/src/main/java/com/debatetimer/domain/customize/Stance.java index fd9b0975..0df12c9d 100644 --- a/src/main/java/com/debatetimer/domain/customize/Stance.java +++ b/src/main/java/com/debatetimer/domain/customize/Stance.java @@ -5,4 +5,9 @@ public enum Stance { PROS, CONS, NEUTRAL, + ; + + public boolean isNeutralStance() { + return this == NEUTRAL; + } } diff --git a/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java b/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java new file mode 100644 index 00000000..7d26610d --- /dev/null +++ b/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java @@ -0,0 +1,70 @@ +package com.debatetimer.domain.customize; + +import com.debatetimer.exception.custom.DTClientErrorException; +import com.debatetimer.exception.errorcode.ClientErrorCode; +import org.springframework.lang.Nullable; + +public class TimeBasedTimeBoxDomain extends CustomizeTimeBoxDomain { + + private final int timePerTeam; + + @Nullable + private final Integer timePerSpeaking; + + public TimeBasedTimeBoxDomain(Stance stance, + String speechType, + @Nullable String speaker, + Integer timePerTeam, + @Nullable Integer timePerSpeaking) { + super(stance, speechType, speaker); + + validateTimes(timePerTeam, timePerSpeaking); + this.timePerTeam = timePerTeam; + this.timePerSpeaking = timePerSpeaking; + } + + private void validateTimes(Integer timePerTeam, Integer timePerSpeaking) { + validateTime(timePerTeam); + if (timePerSpeaking == null) { + return; + } + + validateTime(timePerSpeaking); + if (timePerTeam < timePerSpeaking) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BASED_TIME); + } + } + + private void validateTime(Integer time) { + if (time == null || time <= 0) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_TIME); + } + } + + @Override + protected boolean isValidStance(Stance stance) { + return stance.isNeutralStance(); + } + + @Override + public CustomizeBoxType getBoxType() { + return CustomizeBoxType.TIME_BASED; + } + + @Override + @Nullable + public Integer getTime() { + return null; + } + + @Override + public Integer getTimePerTeam() { + return timePerTeam; + } + + @Override + @Nullable + public Integer getTimePerSpeaking() { + return timePerSpeaking; + } +} diff --git a/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java new file mode 100644 index 00000000..9fbc48fe --- /dev/null +++ b/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java @@ -0,0 +1,98 @@ +package com.debatetimer.domain.customize; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.debatetimer.exception.custom.DTClientErrorException; +import com.debatetimer.exception.errorcode.ClientErrorCode; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullAndEmptySource; +import org.junit.jupiter.params.provider.ValueSource; + +class CustomizeTimeBoxDomainTest { + + @Nested + class ValidateSpeechType { + + @Test + void 발언_종류는_특정_글자를_초과할_수_없다() { + String speechType = "a".repeat(CustomizeTimeBoxDomain.SPEECH_TYPE_MAX_LENGTH + 1); + + assertThatThrownBy(() -> new InheritedCustomizeTimeBoxDomain(Stance.PROS, speechType, "비토")) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_SPEECH_TYPE_LENGTH.getMessage()); + } + + @ParameterizedTest + @NullAndEmptySource + @ValueSource(strings = {" ", "\n\t"}) + void 발언_종류는_비어있을_수_없다(String emptySpeechType) { + assertThatThrownBy(() -> new InheritedCustomizeTimeBoxDomain(Stance.PROS, emptySpeechType, "비토")) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_SPEECH_TYPE_LENGTH.getMessage()); + } + + @Test + void 발언_종류는_특정_글자_이내이어야_한다() { + String speechType = "a".repeat(CustomizeTimeBoxDomain.SPEECH_TYPE_MAX_LENGTH); + + assertThatCode(() -> new InheritedCustomizeTimeBoxDomain(Stance.PROS, speechType, "비토")) + .doesNotThrowAnyException(); + } + } + + @Nested + class ValidateSpeaker { + + @Test + void 발언자_이름은_특정_글자를_초과할_수_없다() { + String speaker = "a".repeat(CustomizeTimeBoxDomain.SPEAKER_MAX_LENGTH + 1); + + assertThatThrownBy(() -> new InheritedCustomizeTimeBoxDomain(Stance.PROS, "비토", speaker)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_SPEAKER_LENGTH.getMessage()); + } + + @Test + void 발언자_이름은_비어있을_수_있다() { + assertThatCode(() -> new InheritedCustomizeTimeBoxDomain(Stance.PROS, "비토", null)) + .doesNotThrowAnyException(); + } + } + + + + static class InheritedCustomizeTimeBoxDomain extends CustomizeTimeBoxDomain { + + protected InheritedCustomizeTimeBoxDomain(Stance stance, String speechType, String speaker) { + super(stance, speechType, speaker); + } + + @Override + protected boolean isValidStance(Stance stance) { + return true; + } + + @Override + public CustomizeBoxType getBoxType() { + return null; + } + + @Override + public Integer getTime() { + return 0; + } + + @Override + public Integer getTimePerTeam() { + return 0; + } + + @Override + public Integer getTimePerSpeaking() { + return 0; + } + } +} diff --git a/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java new file mode 100644 index 00000000..cfdd4d16 --- /dev/null +++ b/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java @@ -0,0 +1,43 @@ +package com.debatetimer.domain.customize; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.debatetimer.exception.custom.DTClientErrorException; +import com.debatetimer.exception.errorcode.ClientErrorCode; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class NormalTimeBoxDomainTest { + + @Nested + class ValidateTime { + + @ParameterizedTest + @ValueSource(ints = {0, -1, Integer.MIN_VALUE}) + void 시간은_0보다_커야_한다(int time) { + assertThatThrownBy(() -> new NormalTimeBoxDomain(Stance.PROS, "비토", null, time)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); + } + + @Test + void 시간은_비어있지_않아야_한다() { + Integer time = null; + + assertThatThrownBy(() -> new NormalTimeBoxDomain(Stance.PROS, "비토", null, time)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); + } + + @Test + void 시간은_양수여야_한다() { + int time = 1; + + assertThatCode(() -> new NormalTimeBoxDomain(Stance.PROS, "비토", null, time)) + .doesNotThrowAnyException(); + } + } +} diff --git a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java new file mode 100644 index 00000000..1d970205 --- /dev/null +++ b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java @@ -0,0 +1,95 @@ +package com.debatetimer.domain.customize; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.debatetimer.exception.custom.DTClientErrorException; +import com.debatetimer.exception.errorcode.ClientErrorCode; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class TimeBasedTimeBoxDomainTest { + + @Nested + class ValidateStance { + + @Test + void 중립_스탠스가_아니면_예외가_발생한다() { + Stance stance = Stance.PROS; + + assertThatThrownBy( + () -> new TimeBasedTimeBoxDomain(stance, "자유발언", "비토", 120, 60)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_STANCE.getMessage()); + } + + @Test + void 중립_스탠스면_예외가_발생하지_않는다() { + Stance stance = Stance.NEUTRAL; + + assertThatCode( + () -> new TimeBasedTimeBoxDomain(stance, "자유발언", "비토", 120, 60)) + .doesNotThrowAnyException(); + } + } + + @Nested + class ValidateTimes { + + @ParameterizedTest + @ValueSource(ints = {0, -1, -100}) + void 팀_당_발언_시간이_양수이어야_한다(int timePerTeam) { + int timePerSpeaking = 1; + + assertThatThrownBy( + () -> new TimeBasedTimeBoxDomain(Stance.NEUTRAL, "자유발언", "비토", timePerTeam, timePerSpeaking)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); + } + + @Test + void 팀_당_발언_시간이_비어있으면_안된다() { + Integer timePerTeam = null; + int timePerSpeaking = 1; + + assertThatThrownBy( + () -> new TimeBasedTimeBoxDomain(Stance.NEUTRAL, "자유발언", "비토", timePerTeam, timePerSpeaking)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); + } + + @ParameterizedTest + @ValueSource(ints = {0, -1, -100}) + void 개인_당_시간이_양수이어야_한다(int timePerSpeaking) { + int timePerTeam = 1; + + assertThatThrownBy( + () -> new TimeBasedTimeBoxDomain(Stance.NEUTRAL, "자유발언", "비토", timePerTeam, timePerSpeaking)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); + } + + @Test + void 개인_당_발언_시간은_비어있을_수_있다() { + Integer timePerSpeaking = null; + int timePerTeam = 1; + + assertThatCode( + () -> new TimeBasedTimeBoxDomain(Stance.NEUTRAL, "자유발언", "비토", timePerTeam, timePerSpeaking)) + .doesNotThrowAnyException(); + } + + @ParameterizedTest + @ValueSource(ints = {1, 60, 120}) + void 팀_당_발언시간은_개인_발언시간보다_많거나_같아야_한다(int timePerTeam) { + int timePerSpeaking = timePerTeam + 1; + + assertThatThrownBy( + () -> new TimeBasedTimeBoxDomain(Stance.NEUTRAL, "자유발언", "비토", timePerTeam, timePerSpeaking)) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BASED_TIME.getMessage()); + } + } +} From 300ea8274221546451aa183a3244fbefba181d9b Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 14 Jul 2025 19:33:56 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat=20:=20stance=20NotNull=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customize/CustomizeTimeBoxDomain.java | 2 +- .../customize/CustomizeTimeBoxDomainTest.java | 19 +++++++++++++++++-- .../customize/TimeBasedTimeBoxDomainTest.java | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java b/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java index 8f688379..18ac7e84 100644 --- a/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java +++ b/src/main/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomain.java @@ -27,7 +27,7 @@ protected CustomizeTimeBoxDomain(Stance stance, String speechType, @Nullable Str } private void validateStance(Stance stance) { - if (!isValidStance(stance)) { + if (stance == null || !isValidStance(stance)) { throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_STANCE); } } diff --git a/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java index 9fbc48fe..be331821 100644 --- a/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java +++ b/src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java @@ -13,6 +13,23 @@ class CustomizeTimeBoxDomainTest { + @Nested + class ValidateStance { + + @Test + void 발언_입장은_비어있을_수_없다() { + assertThatThrownBy(() -> new InheritedCustomizeTimeBoxDomain(null, "비토", "발언자")) + .isInstanceOf(DTClientErrorException.class) + .hasMessage(ClientErrorCode.INVALID_TIME_BOX_STANCE.getMessage()); + } + + @Test + void 발언_입장은_유효한_값이어야_한다() { + assertThatCode(() -> new InheritedCustomizeTimeBoxDomain(Stance.PROS, "비토", "발언자")) + .doesNotThrowAnyException(); + } + } + @Nested class ValidateSpeechType { @@ -62,8 +79,6 @@ class ValidateSpeaker { } } - - static class InheritedCustomizeTimeBoxDomain extends CustomizeTimeBoxDomain { protected InheritedCustomizeTimeBoxDomain(Stance stance, String speechType, String speaker) { diff --git a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java index 1d970205..328693cb 100644 --- a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java +++ b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java @@ -1,7 +1,7 @@ package com.debatetimer.domain.customize; import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.debatetimer.exception.custom.DTClientErrorException; import com.debatetimer.exception.errorcode.ClientErrorCode; From 142f543e2daa98c64c31595d3995c9d81e6b7bfe Mon Sep 17 00:00:00 2001 From: leegwichan Date: Tue, 15 Jul 2025 16:32:14 +0900 Subject: [PATCH 3/5] =?UTF-8?q?test:=20=ED=8A=B9=EC=A0=95=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=97=90=20=EB=8C=80=ED=95=B4=20=EA=B2=BD?= =?UTF-8?q?=EA=B3=84=EA=B0=92=EC=9D=84=20=EC=9C=84=EC=A3=BC=EB=A1=9C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customize/NormalTimeBoxDomainTest.java | 11 +++++----- .../customize/TimeBasedTimeBoxDomainTest.java | 20 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java index cfdd4d16..810ea4ce 100644 --- a/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java +++ b/src/test/java/com/debatetimer/domain/customize/NormalTimeBoxDomainTest.java @@ -7,17 +7,16 @@ import com.debatetimer.exception.errorcode.ClientErrorCode; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; class NormalTimeBoxDomainTest { @Nested class ValidateTime { - @ParameterizedTest - @ValueSource(ints = {0, -1, Integer.MIN_VALUE}) - void 시간은_0보다_커야_한다(int time) { + @Test + void 시간은_0보다_커야_한다() { + Integer time = 0; + assertThatThrownBy(() -> new NormalTimeBoxDomain(Stance.PROS, "비토", null, time)) .isInstanceOf(DTClientErrorException.class) .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); @@ -34,7 +33,7 @@ class ValidateTime { @Test void 시간은_양수여야_한다() { - int time = 1; + Integer time = 1; assertThatCode(() -> new NormalTimeBoxDomain(Stance.PROS, "비토", null, time)) .doesNotThrowAnyException(); diff --git a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java index 328693cb..51f139ec 100644 --- a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java +++ b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java @@ -7,8 +7,6 @@ import com.debatetimer.exception.errorcode.ClientErrorCode; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; class TimeBasedTimeBoxDomainTest { @@ -38,9 +36,9 @@ class ValidateStance { @Nested class ValidateTimes { - @ParameterizedTest - @ValueSource(ints = {0, -1, -100}) - void 팀_당_발언_시간이_양수이어야_한다(int timePerTeam) { + @Test + void 팀_당_발언_시간이_양수이어야_한다() { + int timePerTeam = 0; int timePerSpeaking = 1; assertThatThrownBy( @@ -60,9 +58,9 @@ class ValidateTimes { .hasMessage(ClientErrorCode.INVALID_TIME_BOX_TIME.getMessage()); } - @ParameterizedTest - @ValueSource(ints = {0, -1, -100}) - void 개인_당_시간이_양수이어야_한다(int timePerSpeaking) { + @Test + void 개인_당_시간이_양수이어야_한다() { + int timePerSpeaking = 0; int timePerTeam = 1; assertThatThrownBy( @@ -81,9 +79,9 @@ class ValidateTimes { .doesNotThrowAnyException(); } - @ParameterizedTest - @ValueSource(ints = {1, 60, 120}) - void 팀_당_발언시간은_개인_발언시간보다_많거나_같아야_한다(int timePerTeam) { + @Test + void 팀_당_발언시간은_개인_발언시간보다_많거나_같아야_한다() { + int timePerTeam = 60; int timePerSpeaking = timePerTeam + 1; assertThatThrownBy( From bba9736ff3111c847360031b7d90a56bcf91d7b7 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Wed, 16 Jul 2025 14:43:24 +0900 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=ED=9A=8C=20=EB=8B=B9=20?= =?UTF-8?q?=EB=B0=9C=EC=96=B8=20=EC=8B=9C=EA=B0=84=20&=20=ED=8C=80=20?= =?UTF-8?q?=EB=8B=B9=20=EB=B0=9C=EC=96=B8=20=EC=8B=9C=EA=B0=84=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EB=A6=AC=ED=8C=A9=ED=84=B0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 특정 로직을 무리하게 재사용하지 않고, 두 검증 로직을 분리함 --- .../customize/TimeBasedTimeBoxDomain.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java b/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java index 7d26610d..30dba5ab 100644 --- a/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java +++ b/src/main/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomain.java @@ -24,23 +24,25 @@ public TimeBasedTimeBoxDomain(Stance stance, } private void validateTimes(Integer timePerTeam, Integer timePerSpeaking) { - validateTime(timePerTeam); - if (timePerSpeaking == null) { - return; - } - - validateTime(timePerSpeaking); - if (timePerTeam < timePerSpeaking) { + validateTimePerTeam(timePerTeam); + validateTimePerSpeaking(timePerSpeaking); + if (timePerSpeaking != null && timePerTeam < timePerSpeaking) { throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BASED_TIME); } } - private void validateTime(Integer time) { + private void validateTimePerTeam(Integer time) { if (time == null || time <= 0) { throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_TIME); } } + private void validateTimePerSpeaking(Integer timePerSpeaking) { + if (timePerSpeaking != null && timePerSpeaking <= 0) { + throw new DTClientErrorException(ClientErrorCode.INVALID_TIME_BOX_TIME); + } + } + @Override protected boolean isValidStance(Stance stance) { return stance.isNeutralStance(); From 062e8ede9eb82ac0585a5ed7702eae9df19b4998 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Wed, 16 Jul 2025 14:44:03 +0900 Subject: [PATCH 5/5] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=EC=97=90=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EC=9A=A9=EC=96=B4=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 개인 발언 시간 -> 회 당 발언 시간 --- .../domain/customize/TimeBasedTimeBoxDomainTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java index 51f139ec..484d0e1a 100644 --- a/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java +++ b/src/test/java/com/debatetimer/domain/customize/TimeBasedTimeBoxDomainTest.java @@ -59,7 +59,7 @@ class ValidateTimes { } @Test - void 개인_당_시간이_양수이어야_한다() { + void 회_당_시간이_양수이어야_한다() { int timePerSpeaking = 0; int timePerTeam = 1; @@ -70,7 +70,7 @@ class ValidateTimes { } @Test - void 개인_당_발언_시간은_비어있을_수_있다() { + void 회_당_발언_시간은_비어있을_수_있다() { Integer timePerSpeaking = null; int timePerTeam = 1; @@ -80,7 +80,7 @@ class ValidateTimes { } @Test - void 팀_당_발언시간은_개인_발언시간보다_많거나_같아야_한다() { + void 팀_당_발언시간은_회_당_발언시간보다_많거나_같아야_한다() { int timePerTeam = 60; int timePerSpeaking = timePerTeam + 1;