From 753dca90a481012a1d01d4368bb103edb01a0b95 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:30:22 +0900 Subject: [PATCH 01/94] =?UTF-8?q?feature=20(IoPrinter)=20:=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=EC=A0=81=EC=9D=B8=20=EC=B6=9C=EB=A0=A5=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/view/InputView.java | 22 +++++++++++++++++++ .../java/pairmatching/view/IoPrinter.java | 18 +++++++++++++++ .../java/pairmatching/view/OutputView.java | 5 +++++ 3 files changed, 45 insertions(+) create mode 100644 src/main/java/pairmatching/view/InputView.java create mode 100644 src/main/java/pairmatching/view/IoPrinter.java create mode 100644 src/main/java/pairmatching/view/OutputView.java diff --git a/src/main/java/pairmatching/view/InputView.java b/src/main/java/pairmatching/view/InputView.java new file mode 100644 index 0000000..6b2a7bb --- /dev/null +++ b/src/main/java/pairmatching/view/InputView.java @@ -0,0 +1,22 @@ +package pairmatching.view; + +import java.util.NoSuchElementException; + +import camp.nextstep.edu.missionutils.Console; + +public class InputView extends IoPrinter { + + + private String readLine() { + try { + return Console.readLine(); + } catch (NoSuchElementException exception) { + throw new IllegalStateException("더 이상 입력할 수 없습니다."); + } + } + + private String readLineBeforeNewLine() { + this.println(); + return this.readLine(); + } +} diff --git a/src/main/java/pairmatching/view/IoPrinter.java b/src/main/java/pairmatching/view/IoPrinter.java new file mode 100644 index 0000000..35f59ca --- /dev/null +++ b/src/main/java/pairmatching/view/IoPrinter.java @@ -0,0 +1,18 @@ +package pairmatching.view; + +public class IoPrinter { + + protected void print(final Object message) { + System.out.print(message); + } + + protected void println(final Object message) { + System.out.println(message); + } + + protected void println() { + this.println(""); + } + + +} diff --git a/src/main/java/pairmatching/view/OutputView.java b/src/main/java/pairmatching/view/OutputView.java new file mode 100644 index 0000000..15862d2 --- /dev/null +++ b/src/main/java/pairmatching/view/OutputView.java @@ -0,0 +1,5 @@ +package pairmatching.view; + +public class OutputView { + +} From 2d5b2c294083f62dfd3974f7b6917074917b167b Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:34:01 +0900 Subject: [PATCH 02/94] =?UTF-8?q?feature=20(PairmatchingContext)=20:=20?= =?UTF-8?q?=ED=8E=98=EC=96=B4=EB=A7=A4=EC=B9=AD=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20=EC=BB=A8=ED=85=8D?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/context/PairmatchingContext.java | 4 ++++ .../launcher/context/PairmatchingContextImpl.java | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/context/PairmatchingContext.java create mode 100644 src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java new file mode 100644 index 0000000..aaa4e5a --- /dev/null +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java @@ -0,0 +1,4 @@ +package pairmatching.launcher.context; + +public interface PairmatchingContext { +} diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java new file mode 100644 index 0000000..8b9a373 --- /dev/null +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java @@ -0,0 +1,4 @@ +package pairmatching.launcher.context; + +public class PairmatchingContextImpl implements PairmatchingContext { +} From 1ab4496976b656865743759a77ab5e4211eb4ca5 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:36:23 +0900 Subject: [PATCH 03/94] =?UTF-8?q?docs=20(PairmatchingStatus)=20:=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=9E=85=EB=A0=A5=EC=9D=98=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/README.md b/docs/README.md index e69de29..d31ebc8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -0,0 +1,8 @@ +## 도메인 요구사항 + +## 상태별 요구사항 + +- 매칭 초기화 초기상태 + - [ ] 매칭의 초기상태로 다음 상태는 사용자 입력 선택 상태입니다. +- 사용장 명령어 선택 상태 + - [ ] 사용자로부터 입력을 기능선택의 입력을 받아옵니다. From 0de5bbacb3ac07e76fe5969a0a4b231b2f54aabd Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:38:54 +0900 Subject: [PATCH 04/94] =?UTF-8?q?test=20(initStatus)=20:=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=EC=83=81=ED=83=9C=20=EC=83=81=ED=83=9C=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/status/InitStatusTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/java/pairmatching/launcher/status/InitStatusTest.java diff --git a/src/test/java/pairmatching/launcher/status/InitStatusTest.java b/src/test/java/pairmatching/launcher/status/InitStatusTest.java new file mode 100644 index 0000000..2980faf --- /dev/null +++ b/src/test/java/pairmatching/launcher/status/InitStatusTest.java @@ -0,0 +1,21 @@ +package pairmatching.launcher.status; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; + +import pairmatching.launcher.context.PairmatchingContextImpl; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class InitStatusTest { + + @Test + void 초기화_상태_다음은_사용자_기능선택_상태입니다() { + var actualStatus = new InitStatus().next(new PairmatchingContextImpl()); + var expectedStatus = new SelectFeatureStatus(); + Assertions.assertThat(actualStatus).isInstanceOf(expectedStatus.getClass()); + + } + +} \ No newline at end of file From 1a4f1046ef328d57236cbef68d95040df9650753 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:39:13 +0900 Subject: [PATCH 05/94] =?UTF-8?q?feature=20(PairmatchingStatus)=20:=20?= =?UTF-8?q?=ED=8E=98=EC=96=B4=EB=A7=A4=EC=B9=AD=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/status/PairmatchingStatus.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/PairmatchingStatus.java diff --git a/src/main/java/pairmatching/launcher/status/PairmatchingStatus.java b/src/main/java/pairmatching/launcher/status/PairmatchingStatus.java new file mode 100644 index 0000000..6d9a066 --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/PairmatchingStatus.java @@ -0,0 +1,9 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.context.PairmatchingContext; + +public interface PairmatchingStatus { + PairmatchingStatus next(PairmatchingContext pairmatchingContext); + + boolean runnable(); +} From 0ecf099a0c715e6da1dc2a2be23725e71f844709 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:39:27 +0900 Subject: [PATCH 06/94] =?UTF-8?q?feature=20(InitStauts)=20:=20=ED=8E=98?= =?UTF-8?q?=EC=96=B4=EB=A7=A4=EC=B9=AD=20=EC=B4=88=EA=B8=B0=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/status/InitStatus.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/InitStatus.java diff --git a/src/main/java/pairmatching/launcher/status/InitStatus.java b/src/main/java/pairmatching/launcher/status/InitStatus.java new file mode 100644 index 0000000..c1bd3d1 --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/InitStatus.java @@ -0,0 +1,15 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.context.PairmatchingContext; + +public class InitStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + return new SelectFeatureStatus(); + } + + @Override + public boolean runnable() { + return true; + } +} From 832d112134ca4532551caccf2a175bfef847bf1b Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:43:28 +0900 Subject: [PATCH 07/94] =?UTF-8?q?feature=20(PairmatchingView)=20:=20?= =?UTF-8?q?=ED=8E=98=EC=96=B4=EB=A7=A4=EC=B9=AD=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20view=EC=9D=98=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EA=B0=80=EC=A7=80=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/view/PairmatchingView.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/pairmatching/view/PairmatchingView.java diff --git a/src/main/java/pairmatching/view/PairmatchingView.java b/src/main/java/pairmatching/view/PairmatchingView.java new file mode 100644 index 0000000..3d681c3 --- /dev/null +++ b/src/main/java/pairmatching/view/PairmatchingView.java @@ -0,0 +1,19 @@ +package pairmatching.view; + +public class PairmatchingView { + private final InputView inputView; + private final OutputView outputView; + + public PairmatchingView(InputView inputView, OutputView outputView) { + this.inputView = inputView; + this.outputView = outputView; + } + + public InputView getInputView() { + return inputView; + } + + public OutputView getOutputView() { + return outputView; + } +} From 3be1a09eaeb7f16588e212a50630a707f20d882e Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:43:47 +0900 Subject: [PATCH 08/94] =?UTF-8?q?feature=20(PairmatchingContext)=20:=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B7=B0=EB=A5=BC=20=EC=A0=84=EB=8B=AC=EB=B0=9B=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/context/PairmatchingContext.java | 5 +++++ .../launcher/context/PairmatchingContextImpl.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java index aaa4e5a..e9bf118 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java @@ -1,4 +1,9 @@ package pairmatching.launcher.context; +import pairmatching.view.PairmatchingView; + public interface PairmatchingContext { + + + PairmatchingView getPairmatchingView(); } diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java index 8b9a373..5e3cc2d 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java @@ -1,4 +1,15 @@ package pairmatching.launcher.context; +import pairmatching.view.PairmatchingView; + public class PairmatchingContextImpl implements PairmatchingContext { + private final PairmatchingView pairmatchingView; + + public PairmatchingContextImpl(PairmatchingView pairmatchingView) { + this.pairmatchingView = pairmatchingView; + } + + public PairmatchingView getPairmatchingView() { + return this.pairmatchingView; + } } From fa01a6d0853d88e4272e0ac4d3128b75d53ddc81 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:44:07 +0900 Subject: [PATCH 09/94] =?UTF-8?q?test=20(FakePairmatchingContext)=20:=20?= =?UTF-8?q?=EA=B0=80=EC=A7=9C=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/context/FakePairmatchingContext.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java diff --git a/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java b/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java new file mode 100644 index 0000000..b94dae8 --- /dev/null +++ b/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java @@ -0,0 +1,11 @@ +package pairmatching.launcher.context; + +import pairmatching.view.PairmatchingView; + +public class FakePairmatchingContext implements PairmatchingContext { + + @Override + public PairmatchingView getPairmatchingView() { + return null; + } +} From 87920feb4d7358d9df21e964f5328010f15fe372 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:44:25 +0900 Subject: [PATCH 10/94] =?UTF-8?q?test=20(InitStatus)=20:=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20=EA=B0=80?= =?UTF-8?q?=EC=A7=9C=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=EB=A5=BC=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/launcher/status/InitStatusTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/pairmatching/launcher/status/InitStatusTest.java b/src/test/java/pairmatching/launcher/status/InitStatusTest.java index 2980faf..4a14326 100644 --- a/src/test/java/pairmatching/launcher/status/InitStatusTest.java +++ b/src/test/java/pairmatching/launcher/status/InitStatusTest.java @@ -5,14 +5,14 @@ import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; -import pairmatching.launcher.context.PairmatchingContextImpl; +import pairmatching.launcher.context.FakePairmatchingContext; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class InitStatusTest { @Test void 초기화_상태_다음은_사용자_기능선택_상태입니다() { - var actualStatus = new InitStatus().next(new PairmatchingContextImpl()); + var actualStatus = new InitStatus().next(new FakePairmatchingContext()); var expectedStatus = new SelectFeatureStatus(); Assertions.assertThat(actualStatus).isInstanceOf(expectedStatus.getClass()); From f744304ccef1318af7a8319307b857e4d7981cd7 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:48:50 +0900 Subject: [PATCH 11/94] =?UTF-8?q?test=20(FeatureCommandTest)=20:=20?= =?UTF-8?q?=EC=9E=98=EB=AA=BB=EB=90=9C=20=EB=AA=85=EB=A0=B9=EC=96=B4?= =?UTF-8?q?=EB=A5=BC=5F=EC=9E=85=EB=A0=A5=ED=95=98=EB=A9=B4=5F=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EA=B0=80=5F=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94?= =?UTF-8?q?=EC=A7=80=20=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/code/FeatureCommandTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/java/pairmatching/launcher/code/FeatureCommandTest.java diff --git a/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java b/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java new file mode 100644 index 0000000..b42d42f --- /dev/null +++ b/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java @@ -0,0 +1,18 @@ +package pairmatching.launcher.code; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class FeatureCommandTest { + + @ParameterizedTest + @ValueSource(strings = {" ", "4", "q"}) + void 잘못된_입력어를_입력하면_오류를_반환합니다(final String input) { + Assertions.assertThatIllegalArgumentException().isThrownBy(() -> FeatureCommand.from(input)); + } + +} \ No newline at end of file From 978bfabc412d17d2d70f62d6cab9de73e7063ed8 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:52:49 +0900 Subject: [PATCH 12/94] =?UTF-8?q?feature=20(FeautreCommand)=20:=20?= =?UTF-8?q?=EB=AA=85=EB=A0=B9=EC=97=90=20=EB=94=B0=EB=9D=BC=EC=84=9C=20?= =?UTF-8?q?=EC=98=AC=EB=B0=94=EB=A5=B8=20=EB=AA=85=EB=A0=B9=EC=96=B4?= =?UTF-8?q?=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/code/FeatureCommand.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/code/FeatureCommand.java diff --git a/src/main/java/pairmatching/launcher/code/FeatureCommand.java b/src/main/java/pairmatching/launcher/code/FeatureCommand.java new file mode 100644 index 0000000..f01de7c --- /dev/null +++ b/src/main/java/pairmatching/launcher/code/FeatureCommand.java @@ -0,0 +1,22 @@ +package pairmatching.launcher.code; + +import java.util.Arrays; + +public enum FeatureCommand { + MATCHING("1"), + FIND("2"), + INITIALIZE("3"), + QUIT("Q"); + + private final String command; + + FeatureCommand(final String command) { + this.command = command; + } + + public static FeatureCommand from(String input) { + return Arrays.stream(values()) + .filter(featureCommand -> featureCommand.command.equals(input)).findAny() + .orElseThrow(() -> new IllegalArgumentException()); + } +} From fce867a909c4f3573f97f35c736e3b1116e9ecee Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:54:50 +0900 Subject: [PATCH 13/94] =?UTF-8?q?test=20(FeatureCommandTest)=20:=20=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EB=AA=A9=EB=A1=9D=EC=9D=B4=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=EB=90=98=EB=8A=94=EC=A7=80=20=EA=B2=80=EC=A6=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/code/FeatureCommandTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java b/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java index b42d42f..90eff96 100644 --- a/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java +++ b/src/test/java/pairmatching/launcher/code/FeatureCommandTest.java @@ -3,6 +3,7 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -15,4 +16,13 @@ class FeatureCommandTest { Assertions.assertThatIllegalArgumentException().isThrownBy(() -> FeatureCommand.from(input)); } + @Test + void 기능명령어는_메시지를_가집니다() { + var actual = FeatureCommand.messages(); + var expected = "1. 페어 매칭\n" + + "2. 페어 조회\n" + + "3. 페어 초기화\n" + + "Q. 종료"; + Assertions.assertThat(actual).isEqualTo(expected); + } } \ No newline at end of file From 24c0e21815b3dc5e98d630ab3f7df845811edd71 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 10:58:25 +0900 Subject: [PATCH 14/94] =?UTF-8?q?feature=20(FeautreCommand)=20:=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=9C=EB=A0=A5=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/code/FeatureCommand.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/pairmatching/launcher/code/FeatureCommand.java b/src/main/java/pairmatching/launcher/code/FeatureCommand.java index f01de7c..b08a305 100644 --- a/src/main/java/pairmatching/launcher/code/FeatureCommand.java +++ b/src/main/java/pairmatching/launcher/code/FeatureCommand.java @@ -1,22 +1,33 @@ package pairmatching.launcher.code; import java.util.Arrays; +import java.util.stream.Collectors; public enum FeatureCommand { - MATCHING("1"), - FIND("2"), - INITIALIZE("3"), - QUIT("Q"); + MATCHING("1", "페어 매칭"), + FIND("2", "페어 조회"), + INITIALIZE("3", "페어 초기화"), + QUIT("Q", "종료"); + + private static final String MESSAGE_FORMAT = "%s. %s"; private final String command; + private final String message; - FeatureCommand(final String command) { + FeatureCommand(final String command, final String message) { this.command = command; + this.message = message; } public static FeatureCommand from(String input) { return Arrays.stream(values()) .filter(featureCommand -> featureCommand.command.equals(input)).findAny() - .orElseThrow(() -> new IllegalArgumentException()); + .orElseThrow(IllegalArgumentException::new); + } + + public static String messages() { + return Arrays.stream(values()) + .map(featureCommand -> String.format(MESSAGE_FORMAT, featureCommand.command, featureCommand.message)) + .collect(Collectors.joining("\n")); } } From 3b4d9794b958a57f59a6b9692b9438222f0f044a Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:21:05 +0900 Subject: [PATCH 15/94] =?UTF-8?q?feature=20(QuitStatus)=20:=20=EC=A2=85?= =?UTF-8?q?=EB=A3=8C=EC=83=81=ED=83=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/status/QuitStatus.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/QuitStatus.java diff --git a/src/main/java/pairmatching/launcher/status/QuitStatus.java b/src/main/java/pairmatching/launcher/status/QuitStatus.java new file mode 100644 index 0000000..8ea6d5d --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/QuitStatus.java @@ -0,0 +1,15 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.context.PairmatchingContext; + +public class QuitStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + return null; + } + + @Override + public boolean runnable() { + return false; + } +} From 7e97c1d3452142d6155965f87a50cedeec7f0519 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:23:32 +0900 Subject: [PATCH 16/94] =?UTF-8?q?feature=20(PairmatchingLauncher)=20:=20?= =?UTF-8?q?=EB=9F=B0=EC=B2=98=EB=A5=BC=20=ED=86=B5=ED=95=B4=EC=84=9C=20?= =?UTF-8?q?=ED=8E=98=EC=96=B4=EB=A7=A4=EC=B9=AD=EC=9D=84=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/Application.java | 4 ++- .../launcher/PairmatchingLauncher.java | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/pairmatching/launcher/PairmatchingLauncher.java diff --git a/src/main/java/pairmatching/Application.java b/src/main/java/pairmatching/Application.java index c619a21..bf20ad3 100644 --- a/src/main/java/pairmatching/Application.java +++ b/src/main/java/pairmatching/Application.java @@ -1,8 +1,10 @@ package pairmatching; +import pairmatching.launcher.PairmatchingLauncher; + public class Application { public static void main(String[] args) { // TODO 구현 진행 - + new PairmatchingLauncher().execute(); } } diff --git a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java new file mode 100644 index 0000000..1174440 --- /dev/null +++ b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java @@ -0,0 +1,27 @@ +package pairmatching.launcher; + +import pairmatching.launcher.context.PairmatchingContext; +import pairmatching.launcher.context.PairmatchingContextImpl; +import pairmatching.launcher.status.InitStatus; +import pairmatching.launcher.status.PairmatchingStatus; +import pairmatching.view.InputView; +import pairmatching.view.OutputView; +import pairmatching.view.PairmatchingView; + +public class PairmatchingLauncher { + private final PairmatchingContext pairmatchingContext; + private PairmatchingStatus pairmatchingStatus; + + PairmatchingLauncher() { + this.pairmatchingContext = new PairmatchingContextImpl(new PairmatchingView(new InputView(), new OutputView())); + this.pairmatchingStatus = new InitStatus(); + + } + + public void execute() { + while (pairmatchingStatus.runnable()) { + pairmatchingStatus = pairmatchingStatus.next(pairmatchingContext); + } + + } +} From b70a41b6dd6fc853d09154563909c776a3c8c28c Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:25:34 +0900 Subject: [PATCH 17/94] =?UTF-8?q?feature=20(SelectFeatureStatus)=20:=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=84=A0=ED=83=9D=EC=83=81=ED=83=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=8E=98=EC=96=B4=EB=A7=A4=EC=B9=AD=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=EC=9D=84=20=EC=9E=85=EB=A0=A5=EB=B0=9B=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/status/SelectFeatureStatus.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java diff --git a/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java b/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java new file mode 100644 index 0000000..9dc3107 --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java @@ -0,0 +1,19 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.code.CommandToStatusConvertor; +import pairmatching.launcher.context.PairmatchingContext; + +public class SelectFeatureStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + var pairmatchingView = pairmatchingContext.getPairmatchingView(); + var featureCommand = pairmatchingView.getInputView().readFeatureCommand(); + + return CommandToStatusConvertor.getNextStatus(featureCommand); + } + + @Override + public boolean runnable() { + return true; + } +} From 83292e3e065625b63a2b0ddc95e9b2fa3d41fa42 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:26:01 +0900 Subject: [PATCH 18/94] =?UTF-8?q?feature=20(CommandToStatusConvertor)=20:?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EC=84=A0=ED=83=9D=EC=9D=84=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=B4=EC=A3=BC?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code/CommandToStatusConvertor.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java diff --git a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java new file mode 100644 index 0000000..f6bcdb0 --- /dev/null +++ b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java @@ -0,0 +1,42 @@ +package pairmatching.launcher.code; + +import java.util.Arrays; + +import pairmatching.launcher.status.InputStatus; +import pairmatching.launcher.status.PairmatchingStatus; +import pairmatching.launcher.status.QuitStatus; + +public enum CommandToStatusConvertor { + MATCHING(FeatureCommand.MATCHING, new InputStatus()), + FIND(FeatureCommand.FIND), + INITIALIZE(FeatureCommand.INITIALIZE), + QUIT(FeatureCommand.QUIT), + UNKNOWN(); + + + private final FeatureCommand command; + private final PairmatchingStatus status; + + CommandToStatusConvertor(FeatureCommand command, PairmatchingStatus status) { + this.command = command; + this.status = status; + } + + CommandToStatusConvertor(FeatureCommand command) { + this.command = command; + this.status = new QuitStatus(); + } + + CommandToStatusConvertor() { + this.command = null; + this.status = new QuitStatus(); + } + + public static PairmatchingStatus getNextStatus(FeatureCommand featureCommand) { + return Arrays.stream(values()) + .filter(convertor -> convertor.command.equals(featureCommand)) + .findAny() + .orElse(UNKNOWN) + .status; + } +} From 1fbc668659bc661a5994546f8a86ae1b3e99481a Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:27:16 +0900 Subject: [PATCH 19/94] =?UTF-8?q?feature=20(InputView)=20:=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20=EB=AA=85=EB=A0=B9=EC=96=B4=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=9B=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/view/InputView.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/pairmatching/view/InputView.java b/src/main/java/pairmatching/view/InputView.java index 6b2a7bb..4739f03 100644 --- a/src/main/java/pairmatching/view/InputView.java +++ b/src/main/java/pairmatching/view/InputView.java @@ -3,9 +3,19 @@ import java.util.NoSuchElementException; import camp.nextstep.edu.missionutils.Console; +import pairmatching.launcher.code.FeatureCommand; public class InputView extends IoPrinter { + public FeatureCommand readFeatureCommand() { + this.println("기능을 선택하세요."); + this.println(FeatureCommand.messages()); + return FeatureCommand.from(readLine()); + } + + public String readPairmatchingDivision() { + return this.readLine(); + } private String readLine() { try { @@ -19,4 +29,6 @@ private String readLineBeforeNewLine() { this.println(); return this.readLine(); } + + } From 98d95c55fb8b9b7f33bdead0213801238198ebe0 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:31:31 +0900 Subject: [PATCH 20/94] =?UTF-8?q?test=20(CourseTest)=20:=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/code/CourseTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/java/pairmatching/domain/code/CourseTest.java diff --git a/src/test/java/pairmatching/domain/code/CourseTest.java b/src/test/java/pairmatching/domain/code/CourseTest.java new file mode 100644 index 0000000..7d39bef --- /dev/null +++ b/src/test/java/pairmatching/domain/code/CourseTest.java @@ -0,0 +1,28 @@ +package pairmatching.domain.code; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class CourseTest { + + @ParameterizedTest + @ValueSource(strings = {"풀스택", " ", ""}) + void 잘못된_입력을_할_경우_오류를_반환합니다(final String input) { + + } + + @Test + void 과정에_대한_메시지를_반환할_수_있습니다() { + var actual = Course.messages(); + var expected = "백엔드 | 프론트엔드"; + + Assertions.assertThat(actual).isEqualTo(expected); + } + + +} \ No newline at end of file From acd3a9a890f58ba319f3b328e088992a0af121c9 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:35:06 +0900 Subject: [PATCH 21/94] =?UTF-8?q?test=20(Course)=20:=20=EA=B3=BC=EC=A0=95?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/pairmatching/domain/code/CourseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/pairmatching/domain/code/CourseTest.java b/src/test/java/pairmatching/domain/code/CourseTest.java index 7d39bef..7df577e 100644 --- a/src/test/java/pairmatching/domain/code/CourseTest.java +++ b/src/test/java/pairmatching/domain/code/CourseTest.java @@ -13,7 +13,7 @@ class CourseTest { @ParameterizedTest @ValueSource(strings = {"풀스택", " ", ""}) void 잘못된_입력을_할_경우_오류를_반환합니다(final String input) { - + Assertions.assertThatIllegalArgumentException().isThrownBy(() -> Course.from(input)); } @Test From a1f103bf36d7056f61f77168d957e623e48b1ad0 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:35:18 +0900 Subject: [PATCH 22/94] =?UTF-8?q?feature=20(Course)=20:=20=EA=B5=90?= =?UTF-8?q?=EC=9C=A1=EA=B3=BC=EC=A0=95=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/domain/code/Course.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/pairmatching/domain/code/Course.java diff --git a/src/main/java/pairmatching/domain/code/Course.java b/src/main/java/pairmatching/domain/code/Course.java new file mode 100644 index 0000000..52af519 --- /dev/null +++ b/src/main/java/pairmatching/domain/code/Course.java @@ -0,0 +1,28 @@ +package pairmatching.domain.code; + +import java.util.Arrays; +import java.util.stream.Collectors; + +public enum Course { + BACKEND("백엔드"), + FRONTEND("프론트엔드"); + + private final String name; + + Course(final String name) { + this.name = name; + } + + public static String messages() { + return Arrays.stream(values()) + .map(course -> course.name) + .collect(Collectors.joining(" | ")); + } + + public static Course from(String input) { + return Arrays.stream(values()) + .filter(course -> course.name.equals(input.trim())) + .findAny() + .orElseThrow(IllegalArgumentException::new); + } +} From 1eef991a87fe574ba1bb8c592280bba635267d2f Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:42:58 +0900 Subject: [PATCH 23/94] =?UTF-8?q?test=20(SubjectTest)=20:=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=9C=EC=97=90=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/code/SubjectTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/java/pairmatching/domain/code/SubjectTest.java diff --git a/src/test/java/pairmatching/domain/code/SubjectTest.java b/src/test/java/pairmatching/domain/code/SubjectTest.java new file mode 100644 index 0000000..45fda0d --- /dev/null +++ b/src/test/java/pairmatching/domain/code/SubjectTest.java @@ -0,0 +1,19 @@ +package pairmatching.domain.code; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class SubjectTest { + + + @ParameterizedTest + @ValueSource(strings = {"자동차", "로", " ", ""}) + void 잘못된_과제를_입력하면_오류를_발생시킵니다(final String input) { + Assertions.assertThatIllegalArgumentException() + .isThrownBy(() -> Subject.from(input)); + } +} \ No newline at end of file From 157f2b27f2692c600fde1f599544300bc607cd71 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 11:44:29 +0900 Subject: [PATCH 24/94] =?UTF-8?q?feature=20(Subject):=20=EA=B3=BC=EC=A0=9C?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/code/Subject.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/pairmatching/domain/code/Subject.java diff --git a/src/main/java/pairmatching/domain/code/Subject.java b/src/main/java/pairmatching/domain/code/Subject.java new file mode 100644 index 0000000..46d034c --- /dev/null +++ b/src/main/java/pairmatching/domain/code/Subject.java @@ -0,0 +1,20 @@ +package pairmatching.domain.code; + +import java.util.Arrays; + +public enum Subject { + RACING("자동차경주"), LOTTO("로또"), BASEBALL("숫자야구게임"), SHOPPING("장바구니"), PAYMENT("결제"), IMPROVE_PERFORMANCE("지하철노선도"), DEPLOY("성능개선"); + + private final String name; + + Subject(final String input) { + this.name = input; + } + + public static Subject from(final String input) { + return Arrays.stream(values()) + .filter(subject -> subject.name.equals(input.trim())) + .findAny() + .orElseThrow(IllegalArgumentException::new); + } +} From 8fe16e8a2b0b33d8710badf3f962a5a864ff5289 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 13:51:27 +0900 Subject: [PATCH 25/94] =?UTF-8?q?test=20(LevelTest)=20:=20=EB=A0=88?= =?UTF-8?q?=EB=B2=A8=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/code/LevelTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/java/pairmatching/domain/code/LevelTest.java diff --git a/src/test/java/pairmatching/domain/code/LevelTest.java b/src/test/java/pairmatching/domain/code/LevelTest.java new file mode 100644 index 0000000..1a0536f --- /dev/null +++ b/src/test/java/pairmatching/domain/code/LevelTest.java @@ -0,0 +1,39 @@ +package pairmatching.domain.code; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.ValueSource; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class LevelTest { + + @ParameterizedTest + @ValueSource(strings = {"레벨0", "레벨", "레벨6"}) + void 등록되지_않는_레벨에_대한_입력은_오류를_발생시킵니다(final String input) { + Assertions.assertThatIllegalArgumentException() + .isThrownBy(() -> Level.from(input, Subject.RACING)); + } + + @ParameterizedTest + @CsvSource(value = {"레벨1:장바구니", "레벨2:배포"}, delimiterString = ":") + void 레벨에_맞지_않는_과목이면_오류를_발생시킵니다(final String levelName, final String subjectName) { + Assertions.assertThatIllegalArgumentException() + .isThrownBy(() -> Level.from(levelName, Subject.from(subjectName))); + } + + @Test + void 레벨에_대한_메시지를_확인할_수_있습니다() { + var actual = Level.messages(); + var expected = " - 레벨1: 자동차경주 | 로또 | 숫자야구게임\n" + + " - 레벨2: 장바구니 | 결제 | 지하철노선도\n" + + " - 레벨3: \n" + + " - 레벨4: 성능개선 | 배포\n" + + " - 레벨5: "; + + Assertions.assertThat(actual).isEqualTo(expected); + } +} \ No newline at end of file From e7e0137d8f1abf503046d5958d8908a6916297f4 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 13:53:32 +0900 Subject: [PATCH 26/94] =?UTF-8?q?refactor=20(Subject)=20:=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/code/Subject.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/domain/code/Subject.java b/src/main/java/pairmatching/domain/code/Subject.java index 46d034c..eaf7bb8 100644 --- a/src/main/java/pairmatching/domain/code/Subject.java +++ b/src/main/java/pairmatching/domain/code/Subject.java @@ -3,7 +3,8 @@ import java.util.Arrays; public enum Subject { - RACING("자동차경주"), LOTTO("로또"), BASEBALL("숫자야구게임"), SHOPPING("장바구니"), PAYMENT("결제"), IMPROVE_PERFORMANCE("지하철노선도"), DEPLOY("성능개선"); + RACING("자동차경주"), LOTTO("로또"), BASEBALL("숫자야구게임"), SHOPPING("장바구니"), PAYMENT("결제"), SUBWAY("지하철노선도"), IMPROVE_PERFORMANCE("성능개선"), DEPLOY("배포"); + private final String name; From f09cbe0aa09c27880cf6ceb47982ac257106ad92 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:17:20 +0900 Subject: [PATCH 27/94] =?UTF-8?q?feature=20(Subject)=20:=20=EA=B3=BC?= =?UTF-8?q?=EB=AA=A9=EC=9D=98=20=EC=9D=B4=EB=A6=84=EC=9D=84=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/code/Subject.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/domain/code/Subject.java b/src/main/java/pairmatching/domain/code/Subject.java index eaf7bb8..fef071a 100644 --- a/src/main/java/pairmatching/domain/code/Subject.java +++ b/src/main/java/pairmatching/domain/code/Subject.java @@ -3,7 +3,14 @@ import java.util.Arrays; public enum Subject { - RACING("자동차경주"), LOTTO("로또"), BASEBALL("숫자야구게임"), SHOPPING("장바구니"), PAYMENT("결제"), SUBWAY("지하철노선도"), IMPROVE_PERFORMANCE("성능개선"), DEPLOY("배포"); + RACING("자동차경주"), + LOTTO("로또"), + BASEBALL("숫자야구게임"), + SHOPPING("장바구니"), + PAYMENT("결제"), + SUBWAY("지하철노선도"), + IMPROVE_PERFORMANCE("성능개선"), + DEPLOY("배포"); private final String name; @@ -18,4 +25,8 @@ public static Subject from(final String input) { .findAny() .orElseThrow(IllegalArgumentException::new); } + + public String getName() { + return name; + } } From 6a7891ecae400c49e4d5e6fb3ac324aaa07ee61b Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:17:34 +0900 Subject: [PATCH 28/94] =?UTF-8?q?feature=20(Level)=20:=20=EB=A0=88?= =?UTF-8?q?=EB=B2=A8=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/domain/code/Level.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/pairmatching/domain/code/Level.java diff --git a/src/main/java/pairmatching/domain/code/Level.java b/src/main/java/pairmatching/domain/code/Level.java new file mode 100644 index 0000000..805db3a --- /dev/null +++ b/src/main/java/pairmatching/domain/code/Level.java @@ -0,0 +1,47 @@ +package pairmatching.domain.code; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public enum Level { + LEVEL1("레벨1", List.of(Subject.RACING, Subject.LOTTO, Subject.BASEBALL)), + LEVEL2("레벨2", List.of(Subject.SHOPPING, Subject.PAYMENT, Subject.SUBWAY)), + LEVEL3("레벨3"), + LEVEL4("레벨4", List.of(Subject.IMPROVE_PERFORMANCE, Subject.DEPLOY)), LEVEL5("레벨5"); + + private final String name; + private final List subjects; + + Level(final String name) { + this.name = name; + this.subjects = new ArrayList<>(); + } + + Level(final String name, final List subjects) { + this.name = name; + this.subjects = subjects; + } + + public static Level from(final String name, final Subject subject) { + return Arrays.stream(values()) + .filter(level -> level.name.equals(name)) + .filter(level -> level.subjects.contains(subject)) + .findAny() + .orElseThrow(IllegalArgumentException::new); + } + + public static String messages() { + return Arrays.stream(values()) + .map(Level::message) + .collect(Collectors.joining("\n")); + } + + private String message() { + var subjectNames = subjects.stream() + .map(Subject::getName) + .collect(Collectors.joining(" | ")); + return String.format(" - %s: %s", name, subjectNames); + } +} From 6e62a6a1ed1c3fd60900fc004398ef7d228a75b1 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:19:15 +0900 Subject: [PATCH 29/94] =?UTF-8?q?feature=20(IoPrinter)=20:=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=20=EC=83=81=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/view/IoPrinter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pairmatching/view/IoPrinter.java b/src/main/java/pairmatching/view/IoPrinter.java index 35f59ca..4905b42 100644 --- a/src/main/java/pairmatching/view/IoPrinter.java +++ b/src/main/java/pairmatching/view/IoPrinter.java @@ -1,6 +1,7 @@ package pairmatching.view; public class IoPrinter { + protected static final String DIVISION_HASH = "#############################################"; protected void print(final Object message) { System.out.print(message); From c2bd5d5fccc0fae849c1d6b58284e29cd3a55757 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:19:33 +0900 Subject: [PATCH 30/94] style --- config/WootecoStyle.xml | 141 +++++++++++++++++++++++++--------------- 1 file changed, 90 insertions(+), 51 deletions(-) diff --git a/config/WootecoStyle.xml b/config/WootecoStyle.xml index cac33a8..eccfcb4 100644 --- a/config/WootecoStyle.xml +++ b/config/WootecoStyle.xml @@ -1,56 +1,95 @@ - - \ No newline at end of file From 69869864282dc231ef7410aaae1dc9059bd0daf9 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:19:58 +0900 Subject: [PATCH 31/94] =?UTF-8?q?refactor=20(PairmatchingLaunceher)=20:=20?= =?UTF-8?q?=EB=9F=B0=EC=B2=98=20=EC=83=9D=EC=84=B1=EC=9E=90=EB=A5=BC=20pub?= =?UTF-8?q?lic=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/launcher/PairmatchingLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java index 1174440..26eb7c7 100644 --- a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java +++ b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java @@ -12,7 +12,7 @@ public class PairmatchingLauncher { private final PairmatchingContext pairmatchingContext; private PairmatchingStatus pairmatchingStatus; - PairmatchingLauncher() { + public PairmatchingLauncher() { this.pairmatchingContext = new PairmatchingContextImpl(new PairmatchingView(new InputView(), new OutputView())); this.pairmatchingStatus = new InitStatus(); From 268709ea94c289b15013d2f35f284ab346d4f9e1 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:49:59 +0900 Subject: [PATCH 32/94] =?UTF-8?q?test=20(MatchingDivisionTest)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=B6=84=EA=B0=92=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingDivisionTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/pairmatching/domain/matching/MatchingDivisionTest.java diff --git a/src/test/java/pairmatching/domain/matching/MatchingDivisionTest.java b/src/test/java/pairmatching/domain/matching/MatchingDivisionTest.java new file mode 100644 index 0000000..766df94 --- /dev/null +++ b/src/test/java/pairmatching/domain/matching/MatchingDivisionTest.java @@ -0,0 +1,37 @@ +package pairmatching.domain.matching; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.ValueSource; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class MatchingDivisionTest { + + @ParameterizedTest + @ValueSource(strings = {"가,", "", " ", " , , , "}) + void 구분자를_통해서_매칭_구분값을_입력받을_수_있습니다(final String input) { + Assertions.assertThatIllegalArgumentException() + .isThrownBy(() -> new MatchingDivision(input)); + } + + @ParameterizedTest + @ValueSource(strings = {"백엔드,레벨1,자동차경주"}) + void 구분과정이_같으면_같은_과정입니다(final String input) { + var expected = new MatchingDivision(input); + var actual = new MatchingDivision(input); + Assertions.assertThat(actual).isEqualTo(expected); + } + + @ParameterizedTest + @CsvSource(value = {"백엔드,레벨1,자동차경주:백엔드,레벨1,로또"}, delimiterString = ":") + void 구분값이_다르면_다른_과정입니다(final String originalInput, final String targetInput) { + var original = new MatchingDivision(originalInput); + var target = new MatchingDivision(targetInput); + + Assertions.assertThat(original).isNotEqualTo(target); + } + +} \ No newline at end of file From bffbaa268b5278f0d960879126355cc411da6d02 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 14:50:15 +0900 Subject: [PATCH 33/94] =?UTF-8?q?feature=20(MatchingDivision)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=B6=84=EA=B0=92=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingDivision.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/pairmatching/domain/matching/MatchingDivision.java diff --git a/src/main/java/pairmatching/domain/matching/MatchingDivision.java b/src/main/java/pairmatching/domain/matching/MatchingDivision.java new file mode 100644 index 0000000..826819a --- /dev/null +++ b/src/main/java/pairmatching/domain/matching/MatchingDivision.java @@ -0,0 +1,46 @@ +package pairmatching.domain.matching; + +import java.util.Objects; +import pairmatching.domain.code.Course; +import pairmatching.domain.code.Level; +import pairmatching.domain.code.Subject; + +public class MatchingDivision { + private static final int FIX_SIZE = 3; + + private final Course course; + private final Level level; + private final Subject subject; + + public MatchingDivision(String input) { + var splitStr = input.split(","); + validateSplitSize(splitStr.length); + + this.course = Course.from(splitStr[0]); + this.subject = Subject.from(splitStr[2]); + this.level = Level.from(splitStr[1], this.subject); + } + + private void validateSplitSize(int length) { + if (length != FIX_SIZE) { + throw new IllegalArgumentException(); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MatchingDivision that = (MatchingDivision) o; + return course == that.course && level == that.level && subject == that.subject; + } + + @Override + public int hashCode() { + return Objects.hash(course, level, subject); + } +} From cee799f58ebf098c395786b828b675eaee2b032d Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:42:10 +0900 Subject: [PATCH 34/94] =?UTF-8?q?test=20(CrewTest)=20:=20=ED=81=AC?= =?UTF-8?q?=EB=A3=A8=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=9A=94=EA=B5=AC=EC=82=AC=ED=95=AD=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/CrewTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/java/pairmatching/domain/matching/CrewTest.java diff --git a/src/test/java/pairmatching/domain/matching/CrewTest.java b/src/test/java/pairmatching/domain/matching/CrewTest.java new file mode 100644 index 0000000..84ec8da --- /dev/null +++ b/src/test/java/pairmatching/domain/matching/CrewTest.java @@ -0,0 +1,39 @@ +package pairmatching.domain.matching; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import pairmatching.domain.code.Course; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class CrewTest { + + + @ParameterizedTest + @ValueSource(strings = {" ", " ", " "}) + void 크루의_이름은_비어있을_수_없습니다(final String input) { + Assertions.assertThatIllegalArgumentException() + .isThrownBy(() -> new Crew(Course.BACKEND, input)); + } + + @ParameterizedTest + @ValueSource(strings = {"가", "나다"}) + void 크루의_이름과_강좌가_같으면_같은_크루입니다(final String input) { + var actual = new Crew(Course.BACKEND, input); + var expected = new Crew(Course.BACKEND, input); + + Assertions.assertThat(actual).isEqualTo(expected); + } + + @ParameterizedTest + @ValueSource(strings = {"가", "나"}) + void 크루의_이름이_같고_강좌가_다르면_다른_크루입니다(final String input) { + var target = new Crew(Course.BACKEND, input); + var original = new Crew(Course.FRONTEND input); + + Assertions.assertThat(original).isEqualTo(target); + } + +} \ No newline at end of file From c4a01b3e8f36fd22a3d0f9498bb8b6efbbfdee0e Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:42:36 +0900 Subject: [PATCH 35/94] =?UTF-8?q?fix=20(CrewTest)=20:=20=EC=BD=A4=EB=A7=88?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/pairmatching/domain/matching/CrewTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/pairmatching/domain/matching/CrewTest.java b/src/test/java/pairmatching/domain/matching/CrewTest.java index 84ec8da..6996a58 100644 --- a/src/test/java/pairmatching/domain/matching/CrewTest.java +++ b/src/test/java/pairmatching/domain/matching/CrewTest.java @@ -31,7 +31,7 @@ class CrewTest { @ValueSource(strings = {"가", "나"}) void 크루의_이름이_같고_강좌가_다르면_다른_크루입니다(final String input) { var target = new Crew(Course.BACKEND, input); - var original = new Crew(Course.FRONTEND input); + var original = new Crew(Course.FRONTEND, input); Assertions.assertThat(original).isEqualTo(target); } From 40d7744bee0351c8b2f1a15ca918b581d68c0fee Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:54:10 +0900 Subject: [PATCH 36/94] =?UTF-8?q?refactor=20(CrewTest)=20:=20=20=EA=B0=95?= =?UTF-8?q?=EC=A2=8C=EA=B0=80=20=EB=8B=A4=EB=A5=B8=20=ED=81=AC=EB=A3=A8=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/pairmatching/domain/matching/CrewTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/pairmatching/domain/matching/CrewTest.java b/src/test/java/pairmatching/domain/matching/CrewTest.java index 6996a58..9743832 100644 --- a/src/test/java/pairmatching/domain/matching/CrewTest.java +++ b/src/test/java/pairmatching/domain/matching/CrewTest.java @@ -33,7 +33,7 @@ class CrewTest { var target = new Crew(Course.BACKEND, input); var original = new Crew(Course.FRONTEND, input); - Assertions.assertThat(original).isEqualTo(target); + Assertions.assertThat(original).isNotEqualTo(target); } } \ No newline at end of file From e07f9f762aeead9e05ef4d228133008c3d9d2b1a Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:54:36 +0900 Subject: [PATCH 37/94] =?UTF-8?q?feature=20(Course)=20:=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=EC=97=90=EC=84=9C=20=EC=97=B0=EA=B2=B0=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=ED=8C=8C=EC=9D=BC=EB=AA=85=EC=9D=84=20=EA=B0=80?= =?UTF-8?q?=EC=A7=80=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/code/Course.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/pairmatching/domain/code/Course.java b/src/main/java/pairmatching/domain/code/Course.java index 52af519..f95d087 100644 --- a/src/main/java/pairmatching/domain/code/Course.java +++ b/src/main/java/pairmatching/domain/code/Course.java @@ -4,13 +4,15 @@ import java.util.stream.Collectors; public enum Course { - BACKEND("백엔드"), - FRONTEND("프론트엔드"); + BACKEND("백엔드", "backend-crew.md"), + FRONTEND("프론트엔드", "frontend-crew.md"); private final String name; + private final String fileName; - Course(final String name) { + Course(final String name, final String fileName) { this.name = name; + this.fileName = fileName; } public static String messages() { @@ -25,4 +27,8 @@ public static Course from(String input) { .findAny() .orElseThrow(IllegalArgumentException::new); } + + public String getFileName() { + return this.fileName; + } } From 2a604d6b249ab04d6de4cf75959dfd748e4684a2 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:55:05 +0900 Subject: [PATCH 38/94] =?UTF-8?q?feature=20(Crew)=20:=20=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/matching/Crew.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/pairmatching/domain/matching/Crew.java diff --git a/src/main/java/pairmatching/domain/matching/Crew.java b/src/main/java/pairmatching/domain/matching/Crew.java new file mode 100644 index 0000000..22facd9 --- /dev/null +++ b/src/main/java/pairmatching/domain/matching/Crew.java @@ -0,0 +1,41 @@ +package pairmatching.domain.matching; + +import java.util.Objects; +import pairmatching.domain.code.Course; + +public class Crew { + private static final int MIN_SIZE = 1; + private final Course course; + private final String name; + + public Crew(Course course, String name) { + var tempName = name.trim(); + validateNameSizeIsGreaterThanMinSize(tempName.length()); + this.course = course; + this.name = name; + } + + private void validateNameSizeIsGreaterThanMinSize(int length) { + if (length < MIN_SIZE) { + throw new IllegalArgumentException(); + } + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Crew crew = (Crew) o; + return course == crew.course && Objects.equals(name, crew.name); + } + + @Override + public int hashCode() { + return Objects.hash(course, name); + } +} From 3e543403428d41bb552ef265f290a039ed91673f Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:55:28 +0900 Subject: [PATCH 39/94] =?UTF-8?q?feature=20(ReadFile)=20:=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=9D=84=20=EC=9D=BD=EC=96=B4=EC=98=A4=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/generator/ReadFile.java | 7 ++++++ .../domain/generator/ReadFileImpl.java | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/pairmatching/domain/generator/ReadFile.java create mode 100644 src/main/java/pairmatching/domain/generator/ReadFileImpl.java diff --git a/src/main/java/pairmatching/domain/generator/ReadFile.java b/src/main/java/pairmatching/domain/generator/ReadFile.java new file mode 100644 index 0000000..7cca35c --- /dev/null +++ b/src/main/java/pairmatching/domain/generator/ReadFile.java @@ -0,0 +1,7 @@ +package pairmatching.domain.generator; + +import java.util.List; + +public interface ReadFile { + List readFile(String fileName); +} diff --git a/src/main/java/pairmatching/domain/generator/ReadFileImpl.java b/src/main/java/pairmatching/domain/generator/ReadFileImpl.java new file mode 100644 index 0000000..a3457fa --- /dev/null +++ b/src/main/java/pairmatching/domain/generator/ReadFileImpl.java @@ -0,0 +1,23 @@ +package pairmatching.domain.generator; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +public class ReadFileImpl implements ReadFile { + private static final String RESOURCES = "src/main/resources/"; + + @Override + public List readFile(String fileName) { + return this.read(fileName); + } + + private List read(String fileName) { + try { + return Files.readAllLines(Paths.get(RESOURCES + fileName)); + } catch (IOException exception) { + throw new IllegalStateException(); + } + } +} From 90265bf8f781f04f2eac4cdd7e8d4cce953c8e42 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:55:45 +0900 Subject: [PATCH 40/94] =?UTF-8?q?feature=20(ShuffleGenerator)=20:=20?= =?UTF-8?q?=EB=AC=B8=EC=9E=90=EC=97=B4=EC=9D=84=20=EC=84=9E=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/generator/ShuffleGenerator.java | 8 ++++++++ .../domain/generator/ShuffleGeneratorImpl.java | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/main/java/pairmatching/domain/generator/ShuffleGenerator.java create mode 100644 src/main/java/pairmatching/domain/generator/ShuffleGeneratorImpl.java diff --git a/src/main/java/pairmatching/domain/generator/ShuffleGenerator.java b/src/main/java/pairmatching/domain/generator/ShuffleGenerator.java new file mode 100644 index 0000000..ac9f9f6 --- /dev/null +++ b/src/main/java/pairmatching/domain/generator/ShuffleGenerator.java @@ -0,0 +1,8 @@ +package pairmatching.domain.generator; + +import java.util.List; + +public interface ShuffleGenerator { + + List shuffle(List input); +} diff --git a/src/main/java/pairmatching/domain/generator/ShuffleGeneratorImpl.java b/src/main/java/pairmatching/domain/generator/ShuffleGeneratorImpl.java new file mode 100644 index 0000000..b85822d --- /dev/null +++ b/src/main/java/pairmatching/domain/generator/ShuffleGeneratorImpl.java @@ -0,0 +1,12 @@ +package pairmatching.domain.generator; + +import camp.nextstep.edu.missionutils.Randoms; +import java.util.List; + +public class ShuffleGeneratorImpl implements ShuffleGenerator { + + @Override + public List shuffle(List input) { + return Randoms.shuffle(input); + } +} From 248f1d0304cd05e0724c5e273177703b10948728 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:56:13 +0900 Subject: [PATCH 41/94] =?UTF-8?q?feature=20(FackeFileReader)=20:=20?= =?UTF-8?q?=EA=B0=80=EC=A7=9C=20=ED=8C=8C=EC=9D=BC=20=EC=9D=BD=EA=B8=B0=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/generator/FakeFileReader.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/java/pairmatching/domain/generator/FakeFileReader.java diff --git a/src/test/java/pairmatching/domain/generator/FakeFileReader.java b/src/test/java/pairmatching/domain/generator/FakeFileReader.java new file mode 100644 index 0000000..9f7dda8 --- /dev/null +++ b/src/test/java/pairmatching/domain/generator/FakeFileReader.java @@ -0,0 +1,17 @@ +package pairmatching.domain.generator; + +import java.util.List; + +public class FakeFileReader implements ReadFile { + + private final List data; + + public FakeFileReader(List data) { + this.data = data; + } + + @Override + public List readFile(String fileName) { + return data; + } +} From c41940df68e098d62fab82ff59c696e8aa017caf Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:56:31 +0900 Subject: [PATCH 42/94] =?UTF-8?q?feature=20(FakeShuffle)=20:=20=EA=B0=80?= =?UTF-8?q?=EC=A7=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=84=9E=EA=B8=B0=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/generator/FakeShuffle.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/test/java/pairmatching/domain/generator/FakeShuffle.java diff --git a/src/test/java/pairmatching/domain/generator/FakeShuffle.java b/src/test/java/pairmatching/domain/generator/FakeShuffle.java new file mode 100644 index 0000000..8e95ad8 --- /dev/null +++ b/src/test/java/pairmatching/domain/generator/FakeShuffle.java @@ -0,0 +1,10 @@ +package pairmatching.domain.generator; + +import java.util.List; + +public class FakeShuffle implements ShuffleGenerator { + @Override + public List shuffle(List input) { + return input; + } +} From 0a54d28781f0b45d96f001e895bc3d8e57b29db2 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 15:56:55 +0900 Subject: [PATCH 43/94] =?UTF-8?q?feature=20(Level)=20:=20=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=EC=97=B4=EC=9D=84=20=EC=9E=85=EB=A0=A5=EB=B0=9B?= =?UTF-8?q?=EC=9D=84=EB=95=8C=20=EA=B3=B5=EB=B0=B1=EC=9D=84=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/code/Level.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/domain/code/Level.java b/src/main/java/pairmatching/domain/code/Level.java index 805db3a..2ed4b91 100644 --- a/src/main/java/pairmatching/domain/code/Level.java +++ b/src/main/java/pairmatching/domain/code/Level.java @@ -26,7 +26,7 @@ public enum Level { public static Level from(final String name, final Subject subject) { return Arrays.stream(values()) - .filter(level -> level.name.equals(name)) + .filter(level -> level.name.equals(name.trim())) .filter(level -> level.subjects.contains(subject)) .findAny() .orElseThrow(IllegalArgumentException::new); From f1de8d10d190da0653ba9f879f4488a3c59ce848 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 16:03:42 +0900 Subject: [PATCH 44/94] =?UTF-8?q?test=20(CrewGeneratorTest)=20:=20?= =?UTF-8?q?=EC=84=9E=EC=9D=B8=20=ED=81=AC=EB=A3=A8=EB=A5=BC=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/generator/CrewGeneratorTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/java/pairmatching/domain/generator/CrewGeneratorTest.java diff --git a/src/test/java/pairmatching/domain/generator/CrewGeneratorTest.java b/src/test/java/pairmatching/domain/generator/CrewGeneratorTest.java new file mode 100644 index 0000000..6e12fd0 --- /dev/null +++ b/src/test/java/pairmatching/domain/generator/CrewGeneratorTest.java @@ -0,0 +1,44 @@ +package pairmatching.domain.generator; + +import java.util.List; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import pairmatching.domain.code.Course; +import pairmatching.domain.matching.Crew; + + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class CrewGeneratorTest { + + @Test + void 임의의_값을_넣을때_크루가_만들어지는가() { + var crewGenerator = new CrewGenerator(new FakeFileReader(List.of("가나", "가나다")), new FakeShuffle()); + + var crews = crewGenerator.generateCrews(Course.BACKEND); + + Assertions.assertThat(crews) + .isEqualTo(List.of(new Crew(Course.BACKEND, "가나"), new Crew(Course.BACKEND, "가나다"))); + } + + + @Test + void 입력받은_파일에서_크기가_2보다_작은경우_에러를_발생시킵니다() { + Assertions.assertThatIllegalStateException() + .isThrownBy(() -> { + var generator = new CrewGenerator(new FakeFileReader(List.of("가나")), new FakeShuffle()); + generator.generateCrews(Course.BACKEND); + }); + } + + @Test + void 입력받은_파일에서_중복되는_이름을_가지는_크루가_있으면_에러를_발생시킵니다() { + Assertions.assertThatIllegalStateException() + .isThrownBy(() -> { + var generator = new CrewGenerator(new FakeFileReader(List.of("가나", "가나")), new FakeShuffle()); + generator.generateCrews(Course.BACKEND); + }); + } + +} \ No newline at end of file From 7104905712526b87f2a12f9bdda1d225d2544f1b Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 16:03:56 +0900 Subject: [PATCH 45/94] =?UTF-8?q?feature=20(CrewGenerator)=20:=20=ED=81=AC?= =?UTF-8?q?=EB=A3=A8=EB=93=A4=EC=9D=84=20=EC=83=9D=EC=84=B1=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/generator/CrewGenerator.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/pairmatching/domain/generator/CrewGenerator.java diff --git a/src/main/java/pairmatching/domain/generator/CrewGenerator.java b/src/main/java/pairmatching/domain/generator/CrewGenerator.java new file mode 100644 index 0000000..7aa2357 --- /dev/null +++ b/src/main/java/pairmatching/domain/generator/CrewGenerator.java @@ -0,0 +1,48 @@ +package pairmatching.domain.generator; + +import java.util.HashSet; +import java.util.List; +import java.util.stream.Collectors; +import pairmatching.domain.code.Course; +import pairmatching.domain.matching.Crew; + +public class CrewGenerator { + private final ReadFile readFile; + private final ShuffleGenerator shuffleGenerator; + + + public CrewGenerator(ReadFile readFile, ShuffleGenerator shuffleGenerator) { + this.readFile = readFile; + this.shuffleGenerator = shuffleGenerator; + } + + public List generateCrews(Course course) { + var crewNames = this.readFileByCrews(course.getFileName()); + + var generatedCrews = this.shuffleGenerator.shuffle(crewNames) + .stream() + .map(name -> new Crew(course, name)) + .collect(Collectors.toList()); + + validateCrewSizeIsGreaterThanMinSize(generatedCrews.size()); + validateDuplicatedCrew(generatedCrews); + + return generatedCrews; + } + + private void validateDuplicatedCrew(List generatedCrews) { + if (generatedCrews.size() != new HashSet<>(generatedCrews).size()) { + throw new IllegalStateException(); + } + } + + private void validateCrewSizeIsGreaterThanMinSize(int size) { + if (size < 2) { + throw new IllegalStateException(); + } + } + + private List readFileByCrews(final String fileName) { + return readFile.readFile(fileName); + } +} From 989e903bb8d7045437931154a906836b2dbdc15c Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 16:06:39 +0900 Subject: [PATCH 46/94] =?UTF-8?q?feature=20(InputView)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EA=B5=AC=EB=B6=84=EA=B0=92=EC=9D=84=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EB=B0=9B=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/view/InputView.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/pairmatching/view/InputView.java b/src/main/java/pairmatching/view/InputView.java index 4739f03..b51959f 100644 --- a/src/main/java/pairmatching/view/InputView.java +++ b/src/main/java/pairmatching/view/InputView.java @@ -1,8 +1,10 @@ package pairmatching.view; -import java.util.NoSuchElementException; - import camp.nextstep.edu.missionutils.Console; +import java.util.NoSuchElementException; +import pairmatching.domain.code.Course; +import pairmatching.domain.code.Level; +import pairmatching.domain.matching.MatchingDivision; import pairmatching.launcher.code.FeatureCommand; public class InputView extends IoPrinter { @@ -13,8 +15,14 @@ public FeatureCommand readFeatureCommand() { return FeatureCommand.from(readLine()); } - public String readPairmatchingDivision() { - return this.readLine(); + public MatchingDivision readPairmatchingDivision() { + this.println(DIVISION_HASH); + this.println(String.format("과정 : %s", Course.messages())); + this.println(Level.messages()); + this.println(DIVISION_HASH); + this.println("과정, 레벨, 미션을 선택하세요."); + this.println("ex) 백엔드, 레벨1, 자동차경주"); + return new MatchingDivision(this.readLine()); } private String readLine() { From b406bb037b213b52c7aa11e67eab46019a24f5d6 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 16:07:13 +0900 Subject: [PATCH 47/94] =?UTF-8?q?feature=20(PairmatchingContext)=20:=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EA=B5=AC=EB=B6=84=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/context/PairmatchingContext.java | 3 +++ .../launcher/context/FakePairmatchingContext.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java index e9bf118..196bae2 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java @@ -1,9 +1,12 @@ package pairmatching.launcher.context; +import pairmatching.domain.matching.MatchingDivision; import pairmatching.view.PairmatchingView; public interface PairmatchingContext { PairmatchingView getPairmatchingView(); + + void inputMatchingDivision(MatchingDivision matchingDivision); } diff --git a/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java b/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java index b94dae8..b9c78f7 100644 --- a/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java +++ b/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java @@ -1,5 +1,6 @@ package pairmatching.launcher.context; +import pairmatching.domain.matching.MatchingDivision; import pairmatching.view.PairmatchingView; public class FakePairmatchingContext implements PairmatchingContext { @@ -8,4 +9,9 @@ public class FakePairmatchingContext implements PairmatchingContext { public PairmatchingView getPairmatchingView() { return null; } + + @Override + public void inputMatchingDivision(MatchingDivision matchingDivision) { + + } } From 522aeacc92e895e386be48ea3392d5a484e68025 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 16:07:51 +0900 Subject: [PATCH 48/94] =?UTF-8?q?feature=20(PairmatchingContextImpl)=20:?= =?UTF-8?q?=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=97=90=20=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=ED=81=AC=EB=A3=A8=20=EC=83=9D=EC=84=B1=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EB=A5=BC=20=EC=A3=BC=EC=9E=85=EB=B0=9B=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/PairmatchingLauncher.java | 8 +++++++- .../launcher/context/PairmatchingContextImpl.java | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java index 26eb7c7..9be1001 100644 --- a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java +++ b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java @@ -1,5 +1,8 @@ package pairmatching.launcher; +import pairmatching.domain.generator.CrewGenerator; +import pairmatching.domain.generator.ReadFileImpl; +import pairmatching.domain.generator.ShuffleGeneratorImpl; import pairmatching.launcher.context.PairmatchingContext; import pairmatching.launcher.context.PairmatchingContextImpl; import pairmatching.launcher.status.InitStatus; @@ -13,7 +16,10 @@ public class PairmatchingLauncher { private PairmatchingStatus pairmatchingStatus; public PairmatchingLauncher() { - this.pairmatchingContext = new PairmatchingContextImpl(new PairmatchingView(new InputView(), new OutputView())); + this.pairmatchingContext = new PairmatchingContextImpl( + new PairmatchingView(new InputView(), new OutputView()), + new CrewGenerator(new ReadFileImpl(), new ShuffleGeneratorImpl()) + ); this.pairmatchingStatus = new InitStatus(); } diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java index 5e3cc2d..1150b05 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java @@ -1,15 +1,26 @@ package pairmatching.launcher.context; +import pairmatching.domain.generator.CrewGenerator; +import pairmatching.domain.matching.MatchingDivision; import pairmatching.view.PairmatchingView; public class PairmatchingContextImpl implements PairmatchingContext { private final PairmatchingView pairmatchingView; + private final CrewGenerator crewGenerator; + private MatchingDivision matchingDivision; - public PairmatchingContextImpl(PairmatchingView pairmatchingView) { + public PairmatchingContextImpl(PairmatchingView pairmatchingView, CrewGenerator crewGenerator) { this.pairmatchingView = pairmatchingView; + this.crewGenerator = crewGenerator; } public PairmatchingView getPairmatchingView() { return this.pairmatchingView; } + + @Override + public void inputMatchingDivision(MatchingDivision matchingDivision) { + this.matchingDivision = matchingDivision; + } + } From d0179c8334bb7f4fb45c47d9ca7200610a9dacd0 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:21:25 +0900 Subject: [PATCH 49/94] =?UTF-8?q?refactor=20(PairmatchingLauncher)=20:=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=ED=95=A0=EB=95=8C=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=EC=83=81=ED=83=9C=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/launcher/PairmatchingLauncher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java index 9be1001..5bb5953 100644 --- a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java +++ b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java @@ -20,11 +20,12 @@ public PairmatchingLauncher() { new PairmatchingView(new InputView(), new OutputView()), new CrewGenerator(new ReadFileImpl(), new ShuffleGeneratorImpl()) ); - this.pairmatchingStatus = new InitStatus(); } public void execute() { + this.pairmatchingStatus = new InitStatus(); + while (pairmatchingStatus.runnable()) { pairmatchingStatus = pairmatchingStatus.next(pairmatchingContext); } From f2bd8076b280d4b98d742e6459be49b377642105 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:21:49 +0900 Subject: [PATCH 50/94] =?UTF-8?q?feature=20(MatchedCrew)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=ED=81=AC=EB=A3=A8=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EB=A5=BC=20=EA=B0=80=EC=A7=80=EB=8A=94=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchedCrew.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/pairmatching/domain/matching/MatchedCrew.java diff --git a/src/main/java/pairmatching/domain/matching/MatchedCrew.java b/src/main/java/pairmatching/domain/matching/MatchedCrew.java new file mode 100644 index 0000000..08ca4ce --- /dev/null +++ b/src/main/java/pairmatching/domain/matching/MatchedCrew.java @@ -0,0 +1,16 @@ +package pairmatching.domain.matching; + +import java.util.LinkedHashSet; +import java.util.Set; + +public class MatchedCrew { + private final Set matchedCrew; + + public MatchedCrew() { + this.matchedCrew = new LinkedHashSet<>(); + } + + public void add(Crew crew) { + this.matchedCrew.add(crew); + } +} From 618a72cffe0d3bde802b4b9b1dcaade009b66b57 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:22:08 +0900 Subject: [PATCH 51/94] =?UTF-8?q?feature=20(MatchedCrews)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=ED=81=AC=EB=A3=A8=20=EC=A7=91=ED=95=A9?= =?UTF-8?q?=EC=9D=84=20=EA=B0=80=EC=A7=80=EB=8A=94=20=EC=9D=BC=EA=B8=89=20?= =?UTF-8?q?=EC=BB=AC=EB=A0=89=EC=85=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchedCrews.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/pairmatching/domain/matching/MatchedCrews.java diff --git a/src/main/java/pairmatching/domain/matching/MatchedCrews.java b/src/main/java/pairmatching/domain/matching/MatchedCrews.java new file mode 100644 index 0000000..29fa8bd --- /dev/null +++ b/src/main/java/pairmatching/domain/matching/MatchedCrews.java @@ -0,0 +1,17 @@ +package pairmatching.domain.matching; + +import java.util.ArrayList; +import java.util.List; + +public class MatchedCrews { + private final List matchedCrewList; + + public MatchedCrews() { + this.matchedCrewList = new ArrayList<>(); + } + + + public void add(MatchedCrew matchedCrew) { + this.matchedCrewList.add(matchedCrew); + } +} From e247dadce0f107a4445110356f09d97de087299e Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:22:25 +0900 Subject: [PATCH 52/94] =?UTF-8?q?feature=20(MatchingResult)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EB=90=9C=20=EA=B2=B0=EA=B3=BC=EB=A5=BC=20?= =?UTF-8?q?=EA=B0=80=EC=A7=80=EB=8A=94=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingResult.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/pairmatching/domain/matching/MatchingResult.java diff --git a/src/main/java/pairmatching/domain/matching/MatchingResult.java b/src/main/java/pairmatching/domain/matching/MatchingResult.java new file mode 100644 index 0000000..906873b --- /dev/null +++ b/src/main/java/pairmatching/domain/matching/MatchingResult.java @@ -0,0 +1,32 @@ +package pairmatching.domain.matching; + +import java.util.List; +import java.util.Map; +import java.util.Queue; + +public class MatchingResult { + private Map matchingResult; + + private static MatchedCrew generateMatchedCrew(Queue crewsQueue) { + var matchedCrew = new MatchedCrew(); + for (int i = 0; i <= 1; i++) { + matchedCrew.add(crewsQueue.poll()); + } + return matchedCrew; + } + + public void matchPair(MatchingDivision matchingDivision, List crews) { + var matchedCrews = new MatchedCrews(); + Queue crewsQueue = (Queue) crews; + + while (crewsQueue.size() > 3) { + MatchedCrew matchedCrew = generateMatchedCrew(crewsQueue); + matchedCrews.add(matchedCrew); + } + var matchedCrew = new MatchedCrew(); + while (!crewsQueue.isEmpty()) { + matchedCrew.add(crewsQueue.poll()); + } + matchedCrews.add(matchedCrew); + } +} From 06b49469e215d328562b77601708f3fef265a7f3 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:22:50 +0900 Subject: [PATCH 53/94] =?UTF-8?q?feature=20(PairmatchingContext)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=EC=97=90=20=EC=A7=80?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/context/PairmatchingContext.java | 2 ++ .../launcher/context/PairmatchingContextImpl.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java index 196bae2..27094cb 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java @@ -9,4 +9,6 @@ public interface PairmatchingContext { PairmatchingView getPairmatchingView(); void inputMatchingDivision(MatchingDivision matchingDivision); + + String matchPair(); } diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java index 1150b05..a0bb60e 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java @@ -23,4 +23,9 @@ public void inputMatchingDivision(MatchingDivision matchingDivision) { this.matchingDivision = matchingDivision; } + @Override + public String matchPair() { + return null; + } + } From 308553cc5533c2219d28702d48580e8523a0bca4 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:23:02 +0900 Subject: [PATCH 54/94] =?UTF-8?q?feature=20(InputStatus)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=B4=88=EA=B8=B0=EC=83=81=ED=83=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/status/InputStatus.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/InputStatus.java diff --git a/src/main/java/pairmatching/launcher/status/InputStatus.java b/src/main/java/pairmatching/launcher/status/InputStatus.java new file mode 100644 index 0000000..373d98b --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/InputStatus.java @@ -0,0 +1,21 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.context.PairmatchingContext; + +public class InputStatus implements PairmatchingStatus { + + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + var pairmatchingView = pairmatchingContext.getPairmatchingView(); + var matchingDivision = pairmatchingView.getInputView().readPairmatchingDivision(); + + pairmatchingContext.inputMatchingDivision(matchingDivision); + + return new MatchingProcessStatus(); + } + + @Override + public boolean runnable() { + return true; + } +} From 204c52b3f788854994651857c456dc188e45af3d Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Thu, 8 Dec 2022 17:23:17 +0900 Subject: [PATCH 55/94] =?UTF-8?q?feature=20(MatchingProcessStatus)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B2=98=EB=A6=AC=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/status/MatchingProcessStatus.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java diff --git a/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java b/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java new file mode 100644 index 0000000..b679b34 --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java @@ -0,0 +1,16 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.context.PairmatchingContext; + +public class MatchingProcessStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + pairmatchingContext.matchPair(); + return null; + } + + @Override + public boolean runnable() { + return true; + } +} From fc346e7f6fe2cbab4f735c42068789e65932dc70 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:08:36 +0900 Subject: [PATCH 56/94] =?UTF-8?q?feature=20(CustomException)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EA=B3=BC=20=EA=B4=80=EB=A0=A8=EB=90=9C=20?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80=20=EC=98=88=EC=99=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DuplicatedMatchingDivisionException.java | 12 ++++++++++++ .../exception/MatchingDivisionDidNotExists.java | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 src/main/java/pairmatching/exception/DuplicatedMatchingDivisionException.java create mode 100644 src/main/java/pairmatching/exception/MatchingDivisionDidNotExists.java diff --git a/src/main/java/pairmatching/exception/DuplicatedMatchingDivisionException.java b/src/main/java/pairmatching/exception/DuplicatedMatchingDivisionException.java new file mode 100644 index 0000000..1b87e1f --- /dev/null +++ b/src/main/java/pairmatching/exception/DuplicatedMatchingDivisionException.java @@ -0,0 +1,12 @@ +package pairmatching.exception; + +public class DuplicatedMatchingDivisionException extends RuntimeException { + + public DuplicatedMatchingDivisionException(final String message) { + super(message); + } + + public DuplicatedMatchingDivisionException() { + super(""); + } +} diff --git a/src/main/java/pairmatching/exception/MatchingDivisionDidNotExists.java b/src/main/java/pairmatching/exception/MatchingDivisionDidNotExists.java new file mode 100644 index 0000000..816d947 --- /dev/null +++ b/src/main/java/pairmatching/exception/MatchingDivisionDidNotExists.java @@ -0,0 +1,5 @@ +package pairmatching.exception; + +public class MatchingDivisionDidNotExists extends RuntimeException { + +} From eb93093bab26d1f3edbbe3bde64efcb15b3d2545 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:08:58 +0900 Subject: [PATCH 57/94] =?UTF-8?q?test=20(MatchedCrewsTest)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=ED=81=AC=EB=A3=A8=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchedCrewsTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/java/pairmatching/domain/matching/MatchedCrewsTest.java diff --git a/src/test/java/pairmatching/domain/matching/MatchedCrewsTest.java b/src/test/java/pairmatching/domain/matching/MatchedCrewsTest.java new file mode 100644 index 0000000..6c1e0f3 --- /dev/null +++ b/src/test/java/pairmatching/domain/matching/MatchedCrewsTest.java @@ -0,0 +1,33 @@ +package pairmatching.domain.matching; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import pairmatching.domain.code.Course; +import pairmatching.utils.TestUtils; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class MatchedCrewsTest { + + @Test + void 매칭된_크루_목록의_결과를_반환할_수_있습니다() { + var matchedCrews = new MatchedCrews(); + + matchedCrews.add(generateMatchedCrew(Course.BACKEND, "마,바")); + matchedCrews.add(generateMatchedCrew(Course.BACKEND, "가,나,다")); + + var actual = matchedCrews.result().split("\n"); + + Assertions.assertThat(actual[0]).isEqualTo("마 : 바"); + Assertions.assertThat(actual[1]).isEqualTo("가 : 나 : 다"); + } + + + private MatchedCrew generateMatchedCrew(Course course, final String name) { + var matchedCrew = new MatchedCrew(); + matchedCrew.addAll(TestUtils.convertStringToCrews(course, name)); + return matchedCrew; + } + +} \ No newline at end of file From 4737c37de09d2bd38dc5774067d6844db7bc204a Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:10:21 +0900 Subject: [PATCH 58/94] =?UTF-8?q?test=20(MatchingResultTest)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EA=B2=B0=EA=B3=BC=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingResultTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/java/pairmatching/domain/matching/MatchingResultTest.java diff --git a/src/test/java/pairmatching/domain/matching/MatchingResultTest.java b/src/test/java/pairmatching/domain/matching/MatchingResultTest.java new file mode 100644 index 0000000..d9142d3 --- /dev/null +++ b/src/test/java/pairmatching/domain/matching/MatchingResultTest.java @@ -0,0 +1,39 @@ +package pairmatching.domain.matching; + + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static pairmatching.utils.TestUtils.convertStringToCrews; + +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import pairmatching.domain.code.Course; +import pairmatching.exception.DuplicatedMatchingDivisionException; +import pairmatching.exception.MatchingDivisionDidNotExists; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class MatchingResultTest { + + @Test + void 중복되는_키가_있는_경우_에러를_발생시킵니다() { + var matchingResult = new MatchingResult(); + var matchingDivision = new MatchingDivision("백엔드,레벨1,자동차경주"); + + assertThatThrownBy(() -> { + matchingResult.matchPair(matchingDivision, convertStringToCrews(Course.BACKEND, "가,나,다")); + matchingResult.matchPair(matchingDivision, convertStringToCrews(Course.BACKEND, "가,나,다")); + }).isInstanceOf(DuplicatedMatchingDivisionException.class); + } + + @Test + void 키를_통해서_매칭_결과를_조회할때_데이터가_없는_경우_에러를_발생시킵니다() { + var matchingResult = new MatchingResult(); + var matchingDivision = new MatchingDivision("백엔드,레벨1,자동차경주"); + + assertThatThrownBy(() -> { + matchingResult.findByMatchingDivision(matchingDivision); + }).isInstanceOf(MatchingDivisionDidNotExists.class); + } + + +} \ No newline at end of file From 8dc1bb4fcbb24b96d2ef7b2f723ebe838a6be0f7 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:10:35 +0900 Subject: [PATCH 59/94] =?UTF-8?q?feature=20(Crew)=20:=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EC=9D=84=20=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/matching/Crew.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/pairmatching/domain/matching/Crew.java b/src/main/java/pairmatching/domain/matching/Crew.java index 22facd9..54677f0 100644 --- a/src/main/java/pairmatching/domain/matching/Crew.java +++ b/src/main/java/pairmatching/domain/matching/Crew.java @@ -38,4 +38,8 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(course, name); } + + public String name() { + return this.name; + } } From 2e8aade3be1b5bb815212c1db0618f0f23601c90 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:11:14 +0900 Subject: [PATCH 60/94] =?UTF-8?q?feature=20(MatchedCrew)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=ED=81=AC=EB=A3=A8=EC=9D=98=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9D=84=20=EA=B5=AC=EB=B6=84=EC=A7=80=EC=96=B4=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/matching/MatchedCrew.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/pairmatching/domain/matching/MatchedCrew.java b/src/main/java/pairmatching/domain/matching/MatchedCrew.java index 08ca4ce..241961f 100644 --- a/src/main/java/pairmatching/domain/matching/MatchedCrew.java +++ b/src/main/java/pairmatching/domain/matching/MatchedCrew.java @@ -1,7 +1,9 @@ package pairmatching.domain.matching; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; +import java.util.stream.Collectors; public class MatchedCrew { private final Set matchedCrew; @@ -13,4 +15,14 @@ public MatchedCrew() { public void add(Crew crew) { this.matchedCrew.add(crew); } + + public void addAll(List crews) { + this.matchedCrew.addAll(crews); + } + + public String result() { + return matchedCrew.stream() + .map(Crew::name) + .collect(Collectors.joining(" : ")); + } } From 6a41f5f6d72d313a7d0758338f66f37878234ccc Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:11:40 +0900 Subject: [PATCH 61/94] =?UTF-8?q?feature=20(MatchedCrews)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=ED=81=AC=EB=A3=A8=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B2=B0=EA=B3=BC=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/domain/matching/MatchedCrews.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/domain/matching/MatchedCrews.java b/src/main/java/pairmatching/domain/matching/MatchedCrews.java index 29fa8bd..dc1a2be 100644 --- a/src/main/java/pairmatching/domain/matching/MatchedCrews.java +++ b/src/main/java/pairmatching/domain/matching/MatchedCrews.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class MatchedCrews { private final List matchedCrewList; @@ -10,8 +11,13 @@ public MatchedCrews() { this.matchedCrewList = new ArrayList<>(); } - public void add(MatchedCrew matchedCrew) { this.matchedCrewList.add(matchedCrew); } + + public String result() { + return this.matchedCrewList.stream() + .map(MatchedCrew::result) + .collect(Collectors.joining("\n")); + } } From f71e69a79024278b153c14353829ab014f1002ae Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:11:59 +0900 Subject: [PATCH 62/94] =?UTF-8?q?feature=20(MatchingResult)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EA=B2=B0=EA=B3=BC=EB=A5=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=98=EA=B3=A0=20=EC=A1=B0=ED=9A=8C=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingResult.java | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/main/java/pairmatching/domain/matching/MatchingResult.java b/src/main/java/pairmatching/domain/matching/MatchingResult.java index 906873b..e73daf0 100644 --- a/src/main/java/pairmatching/domain/matching/MatchingResult.java +++ b/src/main/java/pairmatching/domain/matching/MatchingResult.java @@ -1,32 +1,56 @@ package pairmatching.domain.matching; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; +import pairmatching.exception.DuplicatedMatchingDivisionException; +import pairmatching.exception.MatchingDivisionDidNotExists; public class MatchingResult { - private Map matchingResult; + private final Map matchingResult; - private static MatchedCrew generateMatchedCrew(Queue crewsQueue) { - var matchedCrew = new MatchedCrew(); - for (int i = 0; i <= 1; i++) { - matchedCrew.add(crewsQueue.poll()); - } - return matchedCrew; + public MatchingResult() { + this.matchingResult = new HashMap<>(); } public void matchPair(MatchingDivision matchingDivision, List crews) { + validateDuplicatedKey(matchingDivision); + + this.matchingResult.put(matchingDivision, generateMatchedCrews(new LinkedList<>(crews))); + } + + private void validateDuplicatedKey(MatchingDivision matchingDivision) { + if (this.matchingResult.containsKey(matchingDivision)) { + throw new DuplicatedMatchingDivisionException(); + } + } + + private MatchedCrews generateMatchedCrews(LinkedList crews) { var matchedCrews = new MatchedCrews(); - Queue crewsQueue = (Queue) crews; - while (crewsQueue.size() > 3) { - MatchedCrew matchedCrew = generateMatchedCrew(crewsQueue); - matchedCrews.add(matchedCrew); + while (crews.size() > 3) { + matchedCrews.add(generateMatchedCrew(crews, 2)); } + + matchedCrews.add(generateMatchedCrew(crews, crews.size())); + + return matchedCrews; + } + + private MatchedCrew generateMatchedCrew(Queue crewQueue, final int size) { var matchedCrew = new MatchedCrew(); - while (!crewsQueue.isEmpty()) { - matchedCrew.add(crewsQueue.poll()); + for (int i = 0; i < size; i++) { + matchedCrew.add(crewQueue.poll()); + } + return matchedCrew; + } + + public String findByMatchingDivision(MatchingDivision matchingDivision) { + if (!this.matchingResult.containsKey(matchingDivision)) { + throw new MatchingDivisionDidNotExists(); } - matchedCrews.add(matchedCrew); + return this.matchingResult.get(matchingDivision).result(); } } From 810632a51be27a00714141524fc3427e82a25e5f Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:12:15 +0900 Subject: [PATCH 63/94] =?UTF-8?q?test=20(TestUtils)=20:=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/pairmatching/utils/TestUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/java/pairmatching/utils/TestUtils.java diff --git a/src/test/java/pairmatching/utils/TestUtils.java b/src/test/java/pairmatching/utils/TestUtils.java new file mode 100644 index 0000000..f8de626 --- /dev/null +++ b/src/test/java/pairmatching/utils/TestUtils.java @@ -0,0 +1,16 @@ +package pairmatching.utils; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import pairmatching.domain.code.Course; +import pairmatching.domain.matching.Crew; + +public class TestUtils { + + public static List convertStringToCrews(Course course, final String input) { + return Arrays.stream(input.split(",")) + .map(name -> new Crew(course, name)) + .collect(Collectors.toList()); + } +} From f163974955e10de79f04a6a79b053473919a6f5f Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:33:43 +0900 Subject: [PATCH 64/94] =?UTF-8?q?feature=20(BeforeMathcedCrewException)=20?= =?UTF-8?q?:=20=EC=9D=B4=EC=A0=84=EC=97=90=20=EB=A7=A4=EC=B9=AD=ED=95=9C?= =?UTF-8?q?=EC=A0=81=EC=9D=B4=20=EC=9E=88=EB=8A=94=20=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/BeforeMatchedCrewException.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/pairmatching/exception/BeforeMatchedCrewException.java diff --git a/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java b/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java new file mode 100644 index 0000000..7ba65ce --- /dev/null +++ b/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java @@ -0,0 +1,11 @@ +package pairmatching.exception; + +public class BeforeMatchedCrewException extends RuntimeException { + public BeforeMatchedCrewException(final String message) { + super(message); + } + + public BeforeMatchedCrewException() { + super(""); + } +} From e9f0d7ef5aae6f12e2f07c1cee01e5883b24cfc5 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:34:16 +0900 Subject: [PATCH 65/94] =?UTF-8?q?test=20(MatchingResultTest)=20:=20?= =?UTF-8?q?=EA=B0=99=EC=9D=80=20=EB=A0=88=EB=B2=A8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EB=90=9C=20=EA=B2=B0=EA=B3=BC=EA=B0=80=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=EC=A7=80=20=EA=B2=80=EC=A6=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingResultTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/pairmatching/domain/matching/MatchingResultTest.java b/src/test/java/pairmatching/domain/matching/MatchingResultTest.java index d9142d3..02aee88 100644 --- a/src/test/java/pairmatching/domain/matching/MatchingResultTest.java +++ b/src/test/java/pairmatching/domain/matching/MatchingResultTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import pairmatching.domain.code.Course; +import pairmatching.exception.BeforeMatchedCrewException; import pairmatching.exception.DuplicatedMatchingDivisionException; import pairmatching.exception.MatchingDivisionDidNotExists; @@ -35,5 +36,18 @@ class MatchingResultTest { }).isInstanceOf(MatchingDivisionDidNotExists.class); } + @Test + void 같은_레벨에서_페어를_맺은적이_있는_크루가_있는_경우_오류를_발생시킵니다() { + var matchingResult = new MatchingResult(); + var matchingDivision = new MatchingDivision("백엔드,레벨1,자동차경주"); + + var newMatchingDivision = new MatchingDivision("백엔드,레벨1,로또"); + assertThatThrownBy(() -> { + matchingResult.matchPair(matchingDivision, convertStringToCrews(Course.BACKEND, "가,나,다")); + + matchingResult.matchPair(newMatchingDivision, convertStringToCrews(Course.BACKEND, "가,나,다")); + }).isInstanceOf(BeforeMatchedCrewException.class); + + } } \ No newline at end of file From 9fe770b6e76f143c1799c9da37ca50f6c831de45 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:34:41 +0900 Subject: [PATCH 66/94] =?UTF-8?q?feature=20(MatchingDivision)=20:=20?= =?UTF-8?q?=EA=B0=99=EC=9D=80=20=EB=A0=88=EB=B2=A8=EC=9D=B8=EC=A7=80=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=AC=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/matching/MatchingDivision.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/pairmatching/domain/matching/MatchingDivision.java b/src/main/java/pairmatching/domain/matching/MatchingDivision.java index 826819a..1f111dc 100644 --- a/src/main/java/pairmatching/domain/matching/MatchingDivision.java +++ b/src/main/java/pairmatching/domain/matching/MatchingDivision.java @@ -43,4 +43,12 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(course, level, subject); } + + public Course getCourse() { + return this.course; + } + + public boolean isSameLevel(MatchingDivision matchingDivision) { + return this.level.equals(matchingDivision.level); + } } From 12affbe60573e6cc21560ea9004a4283fc45a8cd Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:35:15 +0900 Subject: [PATCH 67/94] =?UTF-8?q?feature=20(MatchedCrew)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=EC=A0=81=EC=9D=B4=20=EC=9E=88=EB=8A=94?= =?UTF-8?q?=EC=A7=80=20=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/matching/MatchedCrew.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/pairmatching/domain/matching/MatchedCrew.java b/src/main/java/pairmatching/domain/matching/MatchedCrew.java index 241961f..89a5695 100644 --- a/src/main/java/pairmatching/domain/matching/MatchedCrew.java +++ b/src/main/java/pairmatching/domain/matching/MatchedCrew.java @@ -1,5 +1,6 @@ package pairmatching.domain.matching; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -25,4 +26,15 @@ public String result() { .map(Crew::name) .collect(Collectors.joining(" : ")); } + + public boolean hasMatchedAtBefore(List targetMatchedCrews) { + return targetMatchedCrews.stream() + .anyMatch(targetMatchedCrew -> targetMatchedCrew.hasMatchedAtBefore(this)); + } + + private boolean hasMatchedAtBefore(MatchedCrew matchedCrew) { + var union = new HashSet<>(matchedCrew.matchedCrew); + union.retainAll(this.matchedCrew); + return union.size() >= 2; + } } From 312c6766b59f0fe4f544c179e13e2da1a8df273e Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:35:48 +0900 Subject: [PATCH 68/94] =?UTF-8?q?feature=20(MathcedCrews)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=9C=20=ED=81=AC=EB=A3=A8=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9D=B4=EB=AF=B8=20=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=ED=95=9C=EC=A0=81=EC=9D=B4=20=EC=9E=88=EB=8A=94=EC=A7=80=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/matching/MatchedCrews.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/pairmatching/domain/matching/MatchedCrews.java b/src/main/java/pairmatching/domain/matching/MatchedCrews.java index dc1a2be..304d45c 100644 --- a/src/main/java/pairmatching/domain/matching/MatchedCrews.java +++ b/src/main/java/pairmatching/domain/matching/MatchedCrews.java @@ -20,4 +20,9 @@ public String result() { .map(MatchedCrew::result) .collect(Collectors.joining("\n")); } + + public boolean hasMatchedAtBefore(MatchedCrews targetMatchedCrews) { + return matchedCrewList.stream() + .anyMatch(matchedCrew -> matchedCrew.hasMatchedAtBefore(targetMatchedCrews.matchedCrewList)); + } } From 4466f7575f1e7696a3349ba76a83a7ee30bb4501 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 10:36:23 +0900 Subject: [PATCH 69/94] =?UTF-8?q?feature=20(MatchingResult)=20:=20?= =?UTF-8?q?=EA=B0=99=EC=9D=80=20=EB=A0=88=EB=B2=A8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EB=A7=A4=EC=B9=AD=ED=95=9C=20=EA=B2=BD?= =?UTF-8?q?=ED=97=98=EC=9D=B4=20=EC=9E=88=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=EB=A5=BC=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingResult.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/domain/matching/MatchingResult.java b/src/main/java/pairmatching/domain/matching/MatchingResult.java index e73daf0..72f8a42 100644 --- a/src/main/java/pairmatching/domain/matching/MatchingResult.java +++ b/src/main/java/pairmatching/domain/matching/MatchingResult.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Queue; +import pairmatching.exception.BeforeMatchedCrewException; import pairmatching.exception.DuplicatedMatchingDivisionException; import pairmatching.exception.MatchingDivisionDidNotExists; @@ -18,7 +19,26 @@ public MatchingResult() { public void matchPair(MatchingDivision matchingDivision, List crews) { validateDuplicatedKey(matchingDivision); - this.matchingResult.put(matchingDivision, generateMatchedCrews(new LinkedList<>(crews))); + var matchedResult = generateMatchedCrews(new LinkedList<>(crews)); + + validateSameLevelExistsMatchedCrew(matchingDivision, matchedResult); + this.matchingResult.put(matchingDivision, matchedResult); + } + + /** + * 같은 레벨에서 매칭된 크루가 잇는지 검증합니다. + * + * @param matchedResult + */ + private void validateSameLevelExistsMatchedCrew(MatchingDivision matchingDivision, MatchedCrews matchedResult) { + + var hasSameLevelMatchedCrews = this.matchingResult.entrySet().stream() + .filter(entry -> entry.getKey().isSameLevel(matchingDivision)) + .anyMatch(entry -> entry.getValue().hasMatchedAtBefore(matchedResult)); + + if (hasSameLevelMatchedCrews) { + throw new BeforeMatchedCrewException(); + } } private void validateDuplicatedKey(MatchingDivision matchingDivision) { From 9fffc9a59745653e8e1de7c0cd87303670a3cb7a Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:21:25 +0900 Subject: [PATCH 70/94] =?UTF-8?q?feature=20(OutputView)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EA=B2=B0=EA=B3=BC=EB=A5=BC=20=EC=B6=9C=EB=A0=A5?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/view/OutputView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/view/OutputView.java b/src/main/java/pairmatching/view/OutputView.java index 15862d2..d327eae 100644 --- a/src/main/java/pairmatching/view/OutputView.java +++ b/src/main/java/pairmatching/view/OutputView.java @@ -1,5 +1,9 @@ package pairmatching.view; -public class OutputView { +public class OutputView extends IoPrinter { + public void printMatchingResultCrews(String matchedCrewNames) { + this.println("페어 매칭 결과입니다."); + this.println(matchedCrewNames); + } } From bc3af25c7048b2518a8e7abae1865f179cd8a51e Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:21:45 +0900 Subject: [PATCH 71/94] =?UTF-8?q?feature=20(InputView)=20:=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EC=9D=84=20=EB=8B=A4=EC=8B=9C=20=EC=8B=9C=EB=8F=84?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/view/InputView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/pairmatching/view/InputView.java b/src/main/java/pairmatching/view/InputView.java index b51959f..7bab54f 100644 --- a/src/main/java/pairmatching/view/InputView.java +++ b/src/main/java/pairmatching/view/InputView.java @@ -6,6 +6,7 @@ import pairmatching.domain.code.Level; import pairmatching.domain.matching.MatchingDivision; import pairmatching.launcher.code.FeatureCommand; +import pairmatching.launcher.code.RematchingCommand; public class InputView extends IoPrinter { @@ -39,4 +40,9 @@ private String readLineBeforeNewLine() { } + public RematchingCommand readReMatchingCommand() { + this.println("매칭 정보가 있습니다. 다시 매칭하시겠습니까?"); + this.println(RematchingCommand.message()); + return RematchingCommand.from(this.readLine()); + } } From b5dee8d2d70f3f0a533eb883fb7f2ef1be4bfb87 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:22:07 +0900 Subject: [PATCH 72/94] =?UTF-8?q?feature=20(RetryCount)=20:=20=EC=9E=AC?= =?UTF-8?q?=EC=8B=9C=EB=8F=84=ED=9A=9F=EC=88=98=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/domain/count/RetryCount.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/pairmatching/domain/count/RetryCount.java diff --git a/src/main/java/pairmatching/domain/count/RetryCount.java b/src/main/java/pairmatching/domain/count/RetryCount.java new file mode 100644 index 0000000..f5f5076 --- /dev/null +++ b/src/main/java/pairmatching/domain/count/RetryCount.java @@ -0,0 +1,24 @@ +package pairmatching.domain.count; + +public class RetryCount { + private static final int INITIALIZE_COUNT = 0; + private static final int PLUS_COUNT = 1; + private static final int MAX_COUNT = 3; + private final int count; + + private RetryCount(final int count) { + if (count > MAX_COUNT) { + throw new IllegalStateException("더이상 시도할 수 없습니다."); + } + this.count = count; + } + + public static RetryCount generateInitializeCount() { + return new RetryCount(INITIALIZE_COUNT); + } + + public RetryCount plusRetry() { + return new RetryCount(this.count + PLUS_COUNT); + } + +} From b597461b56915ae761cb55c96baf1d2f230c7069 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:22:39 +0900 Subject: [PATCH 73/94] =?UTF-8?q?refactor=20(MatchingResult)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=EA=B3=BC=20=EC=9E=AC=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/matching/MatchingResult.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/pairmatching/domain/matching/MatchingResult.java b/src/main/java/pairmatching/domain/matching/MatchingResult.java index 72f8a42..462fc3b 100644 --- a/src/main/java/pairmatching/domain/matching/MatchingResult.java +++ b/src/main/java/pairmatching/domain/matching/MatchingResult.java @@ -17,11 +17,18 @@ public MatchingResult() { } public void matchPair(MatchingDivision matchingDivision, List crews) { - validateDuplicatedKey(matchingDivision); + this.validateDuplicatedKey(matchingDivision); var matchedResult = generateMatchedCrews(new LinkedList<>(crews)); - validateSameLevelExistsMatchedCrew(matchingDivision, matchedResult); + this.validateSameLevelExistsMatchedCrew(matchingDivision, matchedResult); + this.matchingResult.put(matchingDivision, matchedResult); + } + + public void rematchPair(MatchingDivision matchingDivision, List crews) { + var matchedResult = generateMatchedCrews(new LinkedList<>(crews)); + + this.validateSameLevelExistsMatchedCrew(matchingDivision, matchedResult); this.matchingResult.put(matchingDivision, matchedResult); } @@ -31,7 +38,7 @@ public void matchPair(MatchingDivision matchingDivision, List crews) { * @param matchedResult */ private void validateSameLevelExistsMatchedCrew(MatchingDivision matchingDivision, MatchedCrews matchedResult) { - + var hasSameLevelMatchedCrews = this.matchingResult.entrySet().stream() .filter(entry -> entry.getKey().isSameLevel(matchingDivision)) .anyMatch(entry -> entry.getValue().hasMatchedAtBefore(matchedResult)); @@ -73,4 +80,6 @@ public String findByMatchingDivision(MatchingDivision matchingDivision) { } return this.matchingResult.get(matchingDivision).result(); } + + } From 52067a0f8ac3af609dfd09b8c0dadaa2a28faaae Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:23:08 +0900 Subject: [PATCH 74/94] =?UTF-8?q?refactor=20(CommandToStatusConvertor)=20:?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=EC=97=90=EC=84=9C=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=B4=EC=A3=BC=EB=8A=94=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/code/CommandToStatusConvertor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java index f6bcdb0..8bb7168 100644 --- a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java +++ b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java @@ -1,14 +1,15 @@ package pairmatching.launcher.code; import java.util.Arrays; - +import pairmatching.launcher.status.FindMatchingResultStatus; import pairmatching.launcher.status.InputStatus; +import pairmatching.launcher.status.MatchingProcessStatus; import pairmatching.launcher.status.PairmatchingStatus; import pairmatching.launcher.status.QuitStatus; public enum CommandToStatusConvertor { - MATCHING(FeatureCommand.MATCHING, new InputStatus()), - FIND(FeatureCommand.FIND), + MATCHING(FeatureCommand.MATCHING, new InputStatus(new MatchingProcessStatus())), + FIND(FeatureCommand.FIND, new InputStatus(new FindMatchingResultStatus())), INITIALIZE(FeatureCommand.INITIALIZE), QUIT(FeatureCommand.QUIT), UNKNOWN(); From e77d571c81136c9319f5cd5ed231106d87fd6840 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:23:25 +0900 Subject: [PATCH 75/94] =?UTF-8?q?feature=20(RematchingCommand)=20:=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=EB=A7=A4=EC=B9=AD=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/code/RematchingCommand.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/code/RematchingCommand.java diff --git a/src/main/java/pairmatching/launcher/code/RematchingCommand.java b/src/main/java/pairmatching/launcher/code/RematchingCommand.java new file mode 100644 index 0000000..d80f84c --- /dev/null +++ b/src/main/java/pairmatching/launcher/code/RematchingCommand.java @@ -0,0 +1,38 @@ +package pairmatching.launcher.code; + +import java.util.Arrays; +import java.util.stream.Collectors; +import pairmatching.launcher.status.BeforeMatchingIgnoreProcessStatus; +import pairmatching.launcher.status.InputStatus; +import pairmatching.launcher.status.MatchingProcessStatus; +import pairmatching.launcher.status.PairmatchingStatus; + +public enum RematchingCommand { + YES("네", new InputStatus(new MatchingProcessStatus())), + NO("아니오", new InputStatus(new BeforeMatchingIgnoreProcessStatus())); + + private final String command; + private final PairmatchingStatus nextStatus; + + RematchingCommand(final String command, PairmatchingStatus nextStatus) { + this.command = command; + this.nextStatus = nextStatus; + } + + public static RematchingCommand from(final String input) { + return Arrays.stream(values()) + .filter(rematchingCommand -> rematchingCommand.command.equals(input.trim())) + .findAny() + .orElseThrow(IllegalArgumentException::new); + } + + public static String message() { + return Arrays.stream(values()) + .map(rematchingCommand -> rematchingCommand.command) + .collect(Collectors.joining(" | ")); + } + + public PairmatchingStatus getNextStatus() { + return nextStatus; + } +} \ No newline at end of file From 9bd9d3d66d952a67bf2141fb9973255841dfdde4 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:40:50 +0900 Subject: [PATCH 76/94] =?UTF-8?q?test=20(SelectFeatureStatusTest)=20:=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EA=B3=A0=EB=A5=B4=EB=8A=94=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../status/SelectFeatureStatusTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java diff --git a/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java b/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java new file mode 100644 index 0000000..a52e3d7 --- /dev/null +++ b/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java @@ -0,0 +1,46 @@ +package pairmatching.launcher.status; + +import camp.nextstep.edu.missionutils.test.NsTest; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import pairmatching.launcher.code.MatchingInitializeStatus; +import pairmatching.launcher.context.FakePairmatchingContext; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class SelectFeatureStatusTest extends NsTest { + + PairmatchingStatus getNextStatus() { + return new SelectFeatureStatus().next(new FakePairmatchingContext()); + } + + @ParameterizedTest + @ValueSource(strings = {"1", "2"}) + void 기능선택하는상태에서_1_2를_입력하면_다음은_입력상태로_넘어간다(final String input) { + run(input); + Assertions.assertThat(this.getNextStatus()) + .isInstanceOf(InputStatus.class); + } + + @Test + void 기능선택상태에서_3을_입력하면_매칭_초기화_상태가_된다() { + run("3"); + Assertions.assertThat(this.getNextStatus()) + .isInstanceOf(MatchingInitializeStatus.class); + } + + @Test + void 기능선택상태에서_Q_를_입력하면_종료상태가_된다() { + run("Q"); + Assertions.assertThat(this.getNextStatus()) + .isInstanceOf(QuitStatus.class); + } + + @Override + protected void runMain() { + + } +} \ No newline at end of file From 1d957e084cc20c4791ab4779fee71c3ebbcaff0b Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:41:24 +0900 Subject: [PATCH 77/94] =?UTF-8?q?feature=20(CommandToStatusConvertor)=20:?= =?UTF-8?q?=20=EC=A2=85=EB=A3=8C=20=EC=83=81=ED=83=9C=EC=99=80=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pairmatching/launcher/code/CommandToStatusConvertor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java index 8bb7168..82d28ee 100644 --- a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java +++ b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java @@ -10,8 +10,8 @@ public enum CommandToStatusConvertor { MATCHING(FeatureCommand.MATCHING, new InputStatus(new MatchingProcessStatus())), FIND(FeatureCommand.FIND, new InputStatus(new FindMatchingResultStatus())), - INITIALIZE(FeatureCommand.INITIALIZE), - QUIT(FeatureCommand.QUIT), + INITIALIZE(FeatureCommand.INITIALIZE, new MatchingInitializeStatus()), + QUIT(FeatureCommand.QUIT, new QuitStatus()), UNKNOWN(); From 0ba0ceba6d5518a713fefce2762c31af5fdd6464 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 13:41:53 +0900 Subject: [PATCH 78/94] =?UTF-8?q?feature=20(MatchingInitalizeStatus)=20:?= =?UTF-8?q?=20=EB=A7=A4=EC=B9=AD=20=EC=B4=88=EA=B8=B0=ED=99=94=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code/MatchingInitializeStatus.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/code/MatchingInitializeStatus.java diff --git a/src/main/java/pairmatching/launcher/code/MatchingInitializeStatus.java b/src/main/java/pairmatching/launcher/code/MatchingInitializeStatus.java new file mode 100644 index 0000000..4501440 --- /dev/null +++ b/src/main/java/pairmatching/launcher/code/MatchingInitializeStatus.java @@ -0,0 +1,22 @@ +package pairmatching.launcher.code; + +import pairmatching.launcher.context.PairmatchingContext; +import pairmatching.launcher.status.PairmatchingStatus; +import pairmatching.launcher.status.SelectFeatureStatus; + +public class MatchingInitializeStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + var pairmatchingView = pairmatchingContext.getPairmatchingView(); + + pairmatchingContext.initializeMatchingResult(); + pairmatchingView.getOutputView().printInitializeMessage(); + + return new SelectFeatureStatus(); + } + + @Override + public boolean runnable() { + return true; + } +} From 0ce3832cc25cabba22ba356c0cb73550ac027ee2 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 14:48:20 +0900 Subject: [PATCH 79/94] =?UTF-8?q?refactor=20(MatchingInitalizeStatus)=20:?= =?UTF-8?q?=20=EB=A7=A4=EC=B9=AD=20=EC=B4=88=EA=B8=B0=ED=99=94=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/{code => status}/MatchingInitializeStatus.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/pairmatching/launcher/{code => status}/MatchingInitializeStatus.java (100%) diff --git a/src/main/java/pairmatching/launcher/code/MatchingInitializeStatus.java b/src/main/java/pairmatching/launcher/status/MatchingInitializeStatus.java similarity index 100% rename from src/main/java/pairmatching/launcher/code/MatchingInitializeStatus.java rename to src/main/java/pairmatching/launcher/status/MatchingInitializeStatus.java From b56bd5ff2c8eb138ee5ad9b681cc9b536ba8f7e5 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:22:23 +0900 Subject: [PATCH 80/94] =?UTF-8?q?refactor=20(RetryCount)=20:=20=EC=9E=AC?= =?UTF-8?q?=EC=8B=9C=EB=8F=84=20=ED=9A=9F=EC=88=98=20=EC=B4=88=EA=B3=BC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/count/RetryCount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/domain/count/RetryCount.java b/src/main/java/pairmatching/domain/count/RetryCount.java index f5f5076..bad72ee 100644 --- a/src/main/java/pairmatching/domain/count/RetryCount.java +++ b/src/main/java/pairmatching/domain/count/RetryCount.java @@ -8,7 +8,7 @@ public class RetryCount { private RetryCount(final int count) { if (count > MAX_COUNT) { - throw new IllegalStateException("더이상 시도할 수 없습니다."); + throw new IllegalStateException("3회이상 매칭을 시도할 수 없습니다."); } this.count = count; } From f757bced0df1de2f4eef7ce9bb2ee5b8e8f478fb Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:22:57 +0900 Subject: [PATCH 81/94] =?UTF-8?q?refactor=20(MatchingResult)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EB=90=9C=20=EA=B2=B0=EA=B3=BC=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B3=B8=EC=9D=B8=EC=9D=84=20=EC=A0=9C=EC=99=B8?= =?UTF-8?q?=ED=95=98=EA=B3=A0=20=ED=83=90=EC=83=89=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pairmatching/domain/matching/MatchingResult.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pairmatching/domain/matching/MatchingResult.java b/src/main/java/pairmatching/domain/matching/MatchingResult.java index 462fc3b..5d3b003 100644 --- a/src/main/java/pairmatching/domain/matching/MatchingResult.java +++ b/src/main/java/pairmatching/domain/matching/MatchingResult.java @@ -41,6 +41,7 @@ private void validateSameLevelExistsMatchedCrew(MatchingDivision matchingDivisio var hasSameLevelMatchedCrews = this.matchingResult.entrySet().stream() .filter(entry -> entry.getKey().isSameLevel(matchingDivision)) + .filter(entry -> !entry.getKey().equals(matchingDivision)) // 등록된 구분값을 제외함 .anyMatch(entry -> entry.getValue().hasMatchedAtBefore(matchedResult)); if (hasSameLevelMatchedCrews) { From e567fead9b5a1884744ea749586d10f455f4d97e Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:23:21 +0900 Subject: [PATCH 82/94] =?UTF-8?q?refactor=20(RematchingCommand)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EB=AA=85=EB=A0=B9=EC=96=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=83=81=ED=83=9C=EB=A5=BC=20=EA=B0=80=EC=A7=80?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/code/RematchingCommand.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/pairmatching/launcher/code/RematchingCommand.java b/src/main/java/pairmatching/launcher/code/RematchingCommand.java index d80f84c..8e76709 100644 --- a/src/main/java/pairmatching/launcher/code/RematchingCommand.java +++ b/src/main/java/pairmatching/launcher/code/RematchingCommand.java @@ -2,28 +2,20 @@ import java.util.Arrays; import java.util.stream.Collectors; -import pairmatching.launcher.status.BeforeMatchingIgnoreProcessStatus; -import pairmatching.launcher.status.InputStatus; -import pairmatching.launcher.status.MatchingProcessStatus; -import pairmatching.launcher.status.PairmatchingStatus; public enum RematchingCommand { - YES("네", new InputStatus(new MatchingProcessStatus())), - NO("아니오", new InputStatus(new BeforeMatchingIgnoreProcessStatus())); + YES("네"), NO("아니오"); private final String command; - private final PairmatchingStatus nextStatus; - RematchingCommand(final String command, PairmatchingStatus nextStatus) { + RematchingCommand(final String command) { this.command = command; - this.nextStatus = nextStatus; } public static RematchingCommand from(final String input) { return Arrays.stream(values()) .filter(rematchingCommand -> rematchingCommand.command.equals(input.trim())) - .findAny() - .orElseThrow(IllegalArgumentException::new); + .findAny().orElseThrow(IllegalArgumentException::new); } public static String message() { @@ -32,7 +24,7 @@ public static String message() { .collect(Collectors.joining(" | ")); } - public PairmatchingStatus getNextStatus() { - return nextStatus; + public boolean isRematching() { + return this == YES; } } \ No newline at end of file From f92ac279ed4481cfdf892fe9bdcd643612c7a3c1 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:23:49 +0900 Subject: [PATCH 83/94] =?UTF-8?q?feature=20(PairmatchingContextImpl)=20:?= =?UTF-8?q?=20=EB=A7=A4=EC=B9=AD=EC=97=90=EC=84=9C=20=EC=9E=AC=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EC=9D=84=20=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/context/PairmatchingContext.java | 10 +++++ .../context/PairmatchingContextImpl.java | 40 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java index 27094cb..9f676a9 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContext.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContext.java @@ -11,4 +11,14 @@ public interface PairmatchingContext { void inputMatchingDivision(MatchingDivision matchingDivision); String matchPair(); + + String rematchPair(); + + String findMatchedCrewsByMatchingDivision(); + + void plusTryCount(); + + void initializeRetryCount(); + + void initializeMatchingResult(); } diff --git a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java index a0bb60e..1dca7ae 100644 --- a/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java +++ b/src/main/java/pairmatching/launcher/context/PairmatchingContextImpl.java @@ -1,17 +1,22 @@ package pairmatching.launcher.context; +import pairmatching.domain.count.RetryCount; import pairmatching.domain.generator.CrewGenerator; import pairmatching.domain.matching.MatchingDivision; +import pairmatching.domain.matching.MatchingResult; import pairmatching.view.PairmatchingView; public class PairmatchingContextImpl implements PairmatchingContext { private final PairmatchingView pairmatchingView; private final CrewGenerator crewGenerator; + private MatchingResult matchingResult; private MatchingDivision matchingDivision; + private RetryCount retryCount; public PairmatchingContextImpl(PairmatchingView pairmatchingView, CrewGenerator crewGenerator) { this.pairmatchingView = pairmatchingView; this.crewGenerator = crewGenerator; + this.matchingResult = new MatchingResult(); } public PairmatchingView getPairmatchingView() { @@ -25,7 +30,40 @@ public void inputMatchingDivision(MatchingDivision matchingDivision) { @Override public String matchPair() { - return null; + var generatedCrews = crewGenerator.generateCrews(this.matchingDivision.getCourse()); + + this.matchingResult.matchPair(this.matchingDivision, generatedCrews); + + return this.matchingResult.findByMatchingDivision(matchingDivision); + } + + @Override + public String rematchPair() { + var generatedCrews = crewGenerator.generateCrews(this.matchingDivision.getCourse()); + + this.matchingResult.rematchPair(this.matchingDivision, generatedCrews); + + return this.matchingResult.findByMatchingDivision(matchingDivision); + } + + @Override + public String findMatchedCrewsByMatchingDivision() { + return this.matchingResult.findByMatchingDivision(matchingDivision); + } + + @Override + public void plusTryCount() { + this.retryCount = this.retryCount.plusRetry(); + + } + + public void initializeRetryCount() { + this.retryCount = RetryCount.generateInitializeCount(); + } + + @Override + public void initializeMatchingResult() { + this.matchingResult = new MatchingResult(); } } From 01cf996fccb41ffa75efda10d335d94fde0954cd Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:24:11 +0900 Subject: [PATCH 84/94] =?UTF-8?q?refactor=20(PairmatchingLauncher)=20:=20?= =?UTF-8?q?=EB=9F=B0=EC=B2=98=EC=97=90=EC=84=9C=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=EB=A5=BC=20=ED=95=B8=EB=93=A4=EB=A7=81=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/PairmatchingLauncher.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java index 5bb5953..cf5a861 100644 --- a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java +++ b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java @@ -7,6 +7,7 @@ import pairmatching.launcher.context.PairmatchingContextImpl; import pairmatching.launcher.status.InitStatus; import pairmatching.launcher.status.PairmatchingStatus; +import pairmatching.launcher.status.QuitStatus; import pairmatching.view.InputView; import pairmatching.view.OutputView; import pairmatching.view.PairmatchingView; @@ -16,10 +17,8 @@ public class PairmatchingLauncher { private PairmatchingStatus pairmatchingStatus; public PairmatchingLauncher() { - this.pairmatchingContext = new PairmatchingContextImpl( - new PairmatchingView(new InputView(), new OutputView()), - new CrewGenerator(new ReadFileImpl(), new ShuffleGeneratorImpl()) - ); + this.pairmatchingContext = new PairmatchingContextImpl(new PairmatchingView(new InputView(), new OutputView()), + new CrewGenerator(new ReadFileImpl(), new ShuffleGeneratorImpl())); } @@ -27,7 +26,14 @@ public void execute() { this.pairmatchingStatus = new InitStatus(); while (pairmatchingStatus.runnable()) { - pairmatchingStatus = pairmatchingStatus.next(pairmatchingContext); + try { + pairmatchingStatus = pairmatchingStatus.next(pairmatchingContext); + } catch (IllegalArgumentException exception) { + new OutputView().printError(exception.getMessage()); + } catch (IllegalStateException exception) { + new OutputView().printError(exception.getMessage()); + pairmatchingStatus = new QuitStatus(); + } } } From 9d8d6b6dde5b9ddcc5e9a1401ea3afb32d2414d7 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:24:34 +0900 Subject: [PATCH 85/94] =?UTF-8?q?feature=20(AskRematchingStatus)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=9E=AC=EC=8B=9C=EB=8F=84=EB=A5=BC=20?= =?UTF-8?q?=EB=AC=BB=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/status/AskRematchingStatus.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/AskRematchingStatus.java diff --git a/src/main/java/pairmatching/launcher/status/AskRematchingStatus.java b/src/main/java/pairmatching/launcher/status/AskRematchingStatus.java new file mode 100644 index 0000000..52cc509 --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/AskRematchingStatus.java @@ -0,0 +1,24 @@ +package pairmatching.launcher.status; + +import pairmatching.launcher.context.PairmatchingContext; + +public class AskRematchingStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + var pairMatchingView = pairmatchingContext.getPairmatchingView(); + var inputView = pairMatchingView.getInputView(); + + var rematchingCommand = inputView.readReMatchingCommand(); + if (rematchingCommand.isRematching()) { + return new BeforeMatchingIgnoreProcessStatus(); + } + + pairmatchingContext.inputMatchingDivision(inputView.readPairmatchingDivision()); + return new MatchingProcessStatus(); + } + + @Override + public boolean runnable() { + return true; + } +} From 630a698106bfe1b15bac5f5fcd39250b725e3f29 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:24:59 +0900 Subject: [PATCH 86/94] =?UTF-8?q?feature=20(FindMatchingResultStatus)=20:?= =?UTF-8?q?=20=EB=A7=A4=EC=B9=AD=20=EA=B2=B0=EA=B3=BC=EB=A5=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../status/FindMatchingResultStatus.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/FindMatchingResultStatus.java diff --git a/src/main/java/pairmatching/launcher/status/FindMatchingResultStatus.java b/src/main/java/pairmatching/launcher/status/FindMatchingResultStatus.java new file mode 100644 index 0000000..bcb7002 --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/FindMatchingResultStatus.java @@ -0,0 +1,26 @@ +package pairmatching.launcher.status; + +import pairmatching.exception.MatchingDivisionDidNotExists; +import pairmatching.launcher.context.PairmatchingContext; + +public class FindMatchingResultStatus implements PairmatchingStatus { + + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + var pairmatchingView = pairmatchingContext.getPairmatchingView(); + var outputView = pairmatchingView.getOutputView(); + + try { + outputView.printMatchingResultCrews(pairmatchingContext.findMatchedCrewsByMatchingDivision()); + } catch (MatchingDivisionDidNotExists matchingDivisionDidNotExists) { + throw new IllegalArgumentException("매칭 이력이 없습니다."); + } + + return new SelectFeatureStatus(); + } + + @Override + public boolean runnable() { + return true; + } +} From 22d29537c3688eb1ac0d6cfce9fa0c392476d733 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:25:56 +0900 Subject: [PATCH 87/94] =?UTF-8?q?feature=20(BeforeMatchingIgnoreProcessSta?= =?UTF-8?q?tus)=20:=20=EC=9D=B4=EC=A0=84=EC=97=90=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EA=B2=BD=ED=97=98=EC=9D=84=20=EB=AC=B4=EC=8B=9C=ED=95=98?= =?UTF-8?q?=EA=B3=A0=20=EB=8B=A4=EC=8B=9C=20=EB=A7=A4=EC=B9=AD=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforeMatchingIgnoreProcessStatus.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/pairmatching/launcher/status/BeforeMatchingIgnoreProcessStatus.java diff --git a/src/main/java/pairmatching/launcher/status/BeforeMatchingIgnoreProcessStatus.java b/src/main/java/pairmatching/launcher/status/BeforeMatchingIgnoreProcessStatus.java new file mode 100644 index 0000000..1c2e79e --- /dev/null +++ b/src/main/java/pairmatching/launcher/status/BeforeMatchingIgnoreProcessStatus.java @@ -0,0 +1,23 @@ +package pairmatching.launcher.status; + +import pairmatching.exception.BeforeMatchedCrewException; +import pairmatching.launcher.context.PairmatchingContext; + +public class BeforeMatchingIgnoreProcessStatus implements PairmatchingStatus { + @Override + public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { + var outputView = pairmatchingContext.getPairmatchingView().getOutputView(); + pairmatchingContext.plusTryCount(); + try { + outputView.printMatchingResultCrews(pairmatchingContext.rematchPair()); + return new SelectFeatureStatus(); + } catch (BeforeMatchedCrewException | IllegalStateException exception) { + return this; + } + } + + @Override + public boolean runnable() { + return true; + } +} From ac1ed228c9f506a79cfe2d1d20227f71778fea87 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:27:02 +0900 Subject: [PATCH 88/94] =?UTF-8?q?feature=20(SelectFeautrStatus)=20:=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=84=A0=ED=83=9D=EC=83=81=ED=83=9C?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=8B=9C=EB=8F=84=ED=9A=9F=EC=88=98=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=ED=99=94=ED=95=98=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/launcher/status/SelectFeatureStatus.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java b/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java index 9dc3107..cbcd80b 100644 --- a/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java +++ b/src/main/java/pairmatching/launcher/status/SelectFeatureStatus.java @@ -9,6 +9,7 @@ public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { var pairmatchingView = pairmatchingContext.getPairmatchingView(); var featureCommand = pairmatchingView.getInputView().readFeatureCommand(); + pairmatchingContext.initializeRetryCount(); return CommandToStatusConvertor.getNextStatus(featureCommand); } From a68cb991bfed2154d1882ef863f1e57b31abd87b Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:28:02 +0900 Subject: [PATCH 89/94] =?UTF-8?q?refactor=20(MatchingProcessStatus)=20:=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=20=EC=B2=98=EB=A6=AC=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../status/MatchingProcessStatus.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java b/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java index b679b34..06c5d0a 100644 --- a/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java +++ b/src/main/java/pairmatching/launcher/status/MatchingProcessStatus.java @@ -1,12 +1,29 @@ package pairmatching.launcher.status; +import pairmatching.exception.BeforeMatchedCrewException; +import pairmatching.exception.DuplicatedMatchingDivisionException; import pairmatching.launcher.context.PairmatchingContext; +import pairmatching.view.OutputView; public class MatchingProcessStatus implements PairmatchingStatus { @Override public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { - pairmatchingContext.matchPair(); - return null; + var pairmatchingView = pairmatchingContext.getPairmatchingView(); + var outputView = pairmatchingView.getOutputView(); + + pairmatchingContext.plusTryCount(); + return this.getNextStatus(pairmatchingContext, outputView); + } + + private PairmatchingStatus getNextStatus(PairmatchingContext pairmatchingContext, OutputView outputView) { + try { + outputView.printMatchingResultCrews(pairmatchingContext.matchPair()); + return new SelectFeatureStatus(); + } catch (DuplicatedMatchingDivisionException duplicatedMatchingDivisionException) { + return new AskRematchingStatus(); + } catch (BeforeMatchedCrewException | IllegalStateException exception) { + return this; + } } @Override From 0026285736d5526949bc45ab68012999f0d945c6 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:28:42 +0900 Subject: [PATCH 90/94] =?UTF-8?q?refacotr=20(View)=20:=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=EC=B6=9C=EB=A0=A5=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20Inp?= =?UTF-8?q?utVIew=EC=97=90=EC=84=9C=20OutputView=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pairmatching/view/InputView.java | 25 ++++++++----------- .../java/pairmatching/view/OutputView.java | 18 +++++++++++++ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/pairmatching/view/InputView.java b/src/main/java/pairmatching/view/InputView.java index 7bab54f..b243e72 100644 --- a/src/main/java/pairmatching/view/InputView.java +++ b/src/main/java/pairmatching/view/InputView.java @@ -2,8 +2,6 @@ import camp.nextstep.edu.missionutils.Console; import java.util.NoSuchElementException; -import pairmatching.domain.code.Course; -import pairmatching.domain.code.Level; import pairmatching.domain.matching.MatchingDivision; import pairmatching.launcher.code.FeatureCommand; import pairmatching.launcher.code.RematchingCommand; @@ -13,17 +11,14 @@ public class InputView extends IoPrinter { public FeatureCommand readFeatureCommand() { this.println("기능을 선택하세요."); this.println(FeatureCommand.messages()); - return FeatureCommand.from(readLine()); + return FeatureCommand.from(this.readLineAfterPrintNewLine()); } public MatchingDivision readPairmatchingDivision() { - this.println(DIVISION_HASH); - this.println(String.format("과정 : %s", Course.messages())); - this.println(Level.messages()); - this.println(DIVISION_HASH); + this.println("과정, 레벨, 미션을 선택하세요."); this.println("ex) 백엔드, 레벨1, 자동차경주"); - return new MatchingDivision(this.readLine()); + return new MatchingDivision(this.readLineAfterPrintNewLine()); } private String readLine() { @@ -34,15 +29,15 @@ private String readLine() { } } - private String readLineBeforeNewLine() { - this.println(); - return this.readLine(); - } - - public RematchingCommand readReMatchingCommand() { this.println("매칭 정보가 있습니다. 다시 매칭하시겠습니까?"); this.println(RematchingCommand.message()); - return RematchingCommand.from(this.readLine()); + return RematchingCommand.from(this.readLineAfterPrintNewLine()); + } + + private String readLineAfterPrintNewLine() { + var input = this.readLine(); + this.println(); + return input; } } diff --git a/src/main/java/pairmatching/view/OutputView.java b/src/main/java/pairmatching/view/OutputView.java index d327eae..4537ce9 100644 --- a/src/main/java/pairmatching/view/OutputView.java +++ b/src/main/java/pairmatching/view/OutputView.java @@ -1,9 +1,27 @@ package pairmatching.view; +import pairmatching.domain.code.Course; +import pairmatching.domain.code.Level; + public class OutputView extends IoPrinter { public void printMatchingResultCrews(String matchedCrewNames) { this.println("페어 매칭 결과입니다."); this.println(matchedCrewNames); } + + public void printInitializeMessage() { + this.println("초기화 되었습니다. "); + } + + public void printError(final Object message) { + this.println("[ERROR]" + message); + } + + public void printMatchingMenu() { + this.println(DIVISION_HASH); + this.println(String.format("과정 : %s", Course.messages())); + this.println(Level.messages()); + this.println(DIVISION_HASH); + } } From 1ed6a1a5fbf0746f6334cb27bb52bde30c8f4b12 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:29:04 +0900 Subject: [PATCH 91/94] =?UTF-8?q?refactor=20(InputStatus)=20:=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20=EC=B6=9C=EB=A0=A5=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/status/InputStatus.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/pairmatching/launcher/status/InputStatus.java b/src/main/java/pairmatching/launcher/status/InputStatus.java index 373d98b..ea7178d 100644 --- a/src/main/java/pairmatching/launcher/status/InputStatus.java +++ b/src/main/java/pairmatching/launcher/status/InputStatus.java @@ -4,14 +4,24 @@ public class InputStatus implements PairmatchingStatus { + private final PairmatchingStatus nextStatus; + + public InputStatus(PairmatchingStatus nextStatus) { + this.nextStatus = nextStatus; + } + @Override public PairmatchingStatus next(PairmatchingContext pairmatchingContext) { var pairmatchingView = pairmatchingContext.getPairmatchingView(); - var matchingDivision = pairmatchingView.getInputView().readPairmatchingDivision(); + var inputView = pairmatchingView.getInputView(); + var outputView = pairmatchingView.getOutputView(); + + pairmatchingContext.initializeRetryCount(); - pairmatchingContext.inputMatchingDivision(matchingDivision); + outputView.printMatchingMenu(); + pairmatchingContext.inputMatchingDivision(inputView.readPairmatchingDivision()); - return new MatchingProcessStatus(); + return nextStatus; } @Override From 34644b8ae4e8303164daf3bee7f663ed360d99d4 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:29:14 +0900 Subject: [PATCH 92/94] clean --- .../java/pairmatching/domain/generator/CrewGenerator.java | 4 ++-- src/main/java/pairmatching/domain/generator/ReadFileImpl.java | 2 +- .../pairmatching/exception/BeforeMatchedCrewException.java | 2 +- .../pairmatching/launcher/code/CommandToStatusConvertor.java | 1 + .../launcher/status/MatchingInitializeStatus.java | 4 +--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/pairmatching/domain/generator/CrewGenerator.java b/src/main/java/pairmatching/domain/generator/CrewGenerator.java index 7aa2357..4266469 100644 --- a/src/main/java/pairmatching/domain/generator/CrewGenerator.java +++ b/src/main/java/pairmatching/domain/generator/CrewGenerator.java @@ -32,13 +32,13 @@ public List generateCrews(Course course) { private void validateDuplicatedCrew(List generatedCrews) { if (generatedCrews.size() != new HashSet<>(generatedCrews).size()) { - throw new IllegalStateException(); + throw new IllegalStateException("크루의 이름이 중복됩니다."); } } private void validateCrewSizeIsGreaterThanMinSize(int size) { if (size < 2) { - throw new IllegalStateException(); + throw new IllegalStateException("매칭할 수 없습니다."); } } diff --git a/src/main/java/pairmatching/domain/generator/ReadFileImpl.java b/src/main/java/pairmatching/domain/generator/ReadFileImpl.java index a3457fa..60d6a77 100644 --- a/src/main/java/pairmatching/domain/generator/ReadFileImpl.java +++ b/src/main/java/pairmatching/domain/generator/ReadFileImpl.java @@ -17,7 +17,7 @@ private List read(String fileName) { try { return Files.readAllLines(Paths.get(RESOURCES + fileName)); } catch (IOException exception) { - throw new IllegalStateException(); + throw new IllegalStateException("잘못된 파일이거나 읽을 수 없습니다."); } } } diff --git a/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java b/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java index 7ba65ce..c6bf274 100644 --- a/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java +++ b/src/main/java/pairmatching/exception/BeforeMatchedCrewException.java @@ -6,6 +6,6 @@ public BeforeMatchedCrewException(final String message) { } public BeforeMatchedCrewException() { - super(""); + super("이전에 매칭된 경험이 있는 크루가 존재합니다."); } } diff --git a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java index 82d28ee..fdba4e3 100644 --- a/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java +++ b/src/main/java/pairmatching/launcher/code/CommandToStatusConvertor.java @@ -3,6 +3,7 @@ import java.util.Arrays; import pairmatching.launcher.status.FindMatchingResultStatus; import pairmatching.launcher.status.InputStatus; +import pairmatching.launcher.status.MatchingInitializeStatus; import pairmatching.launcher.status.MatchingProcessStatus; import pairmatching.launcher.status.PairmatchingStatus; import pairmatching.launcher.status.QuitStatus; diff --git a/src/main/java/pairmatching/launcher/status/MatchingInitializeStatus.java b/src/main/java/pairmatching/launcher/status/MatchingInitializeStatus.java index 4501440..372f7b4 100644 --- a/src/main/java/pairmatching/launcher/status/MatchingInitializeStatus.java +++ b/src/main/java/pairmatching/launcher/status/MatchingInitializeStatus.java @@ -1,8 +1,6 @@ -package pairmatching.launcher.code; +package pairmatching.launcher.status; import pairmatching.launcher.context.PairmatchingContext; -import pairmatching.launcher.status.PairmatchingStatus; -import pairmatching.launcher.status.SelectFeatureStatus; public class MatchingInitializeStatus implements PairmatchingStatus { @Override From 3429bc8ca9e766ca83eae652d2d09cef721d4f33 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:29:26 +0900 Subject: [PATCH 93/94] test --- .../java/pairmatching/ApplicationTest.java | 17 ++++++++++ .../context/FakePairmatchingContext.java | 34 ++++++++++++++++++- .../status/MatchingProcessStatusTest.java | 18 ++++++++++ .../status/SelectFeatureStatusTest.java | 1 - 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/test/java/pairmatching/launcher/status/MatchingProcessStatusTest.java diff --git a/src/test/java/pairmatching/ApplicationTest.java b/src/test/java/pairmatching/ApplicationTest.java index 289af26..d2d7701 100644 --- a/src/test/java/pairmatching/ApplicationTest.java +++ b/src/test/java/pairmatching/ApplicationTest.java @@ -11,6 +11,7 @@ class ApplicationTest extends NsTest { private static final String ERROR_MESSAGE = "[ERROR]"; + @Test void 짝수_인원_페어_매칭() { assertShuffleTest( @@ -31,6 +32,22 @@ class ApplicationTest extends NsTest { } ); } + + @Test + void _3회_실패에_대한_에러처리() { + assertShuffleTest( + () -> { + var command = new String[]{"1", "백엔드,레벨1,자동차경주", "1", "백엔드,레벨1,로또"}; + runException(command); + assertThat(output()).contains(ERROR_MESSAGE); + }, + Arrays.asList("태웅", "백호", "치수", "태섭"), + Arrays.asList("태웅", "백호", "치수", "태섭"), + Arrays.asList("태웅", "백호", "치수", "태섭"), + Arrays.asList("태웅", "백호", "치수", "태섭") + ); + } + @Override public void runMain() { Application.main(new String[]{}); diff --git a/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java b/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java index b9c78f7..f1d4e80 100644 --- a/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java +++ b/src/test/java/pairmatching/launcher/context/FakePairmatchingContext.java @@ -1,17 +1,49 @@ package pairmatching.launcher.context; import pairmatching.domain.matching.MatchingDivision; +import pairmatching.view.InputView; +import pairmatching.view.OutputView; import pairmatching.view.PairmatchingView; public class FakePairmatchingContext implements PairmatchingContext { @Override public PairmatchingView getPairmatchingView() { - return null; + return new PairmatchingView(new InputView(), new OutputView()); } @Override public void inputMatchingDivision(MatchingDivision matchingDivision) { } + + @Override + public String matchPair() { + return null; + } + + @Override + public String rematchPair() { + return null; + } + + @Override + public String findMatchedCrewsByMatchingDivision() { + return null; + } + + @Override + public void plusTryCount() { + + } + + @Override + public void initializeRetryCount() { + + } + + @Override + public void initializeMatchingResult() { + + } } diff --git a/src/test/java/pairmatching/launcher/status/MatchingProcessStatusTest.java b/src/test/java/pairmatching/launcher/status/MatchingProcessStatusTest.java new file mode 100644 index 0000000..776921e --- /dev/null +++ b/src/test/java/pairmatching/launcher/status/MatchingProcessStatusTest.java @@ -0,0 +1,18 @@ +package pairmatching.launcher.status; + +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import pairmatching.launcher.context.FakePairmatchingContext; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class MatchingProcessStatusTest { + + + @Test + void 매칭_처리상태에서_중복된_매칭이_일어난_경우_다시매칭한다() { + + new MatchingProcessStatus().next(new FakePairmatchingContext()); + } + +} \ No newline at end of file diff --git a/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java b/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java index a52e3d7..d76a6f6 100644 --- a/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java +++ b/src/test/java/pairmatching/launcher/status/SelectFeatureStatusTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import pairmatching.launcher.code.MatchingInitializeStatus; import pairmatching.launcher.context.FakePairmatchingContext; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) From a8c6d06b386c97aa8638341c81430001d8a30e87 Mon Sep 17 00:00:00 2001 From: JaehongDev Date: Fri, 9 Dec 2022 15:33:25 +0900 Subject: [PATCH 94/94] =?UTF-8?q?refactor=20(PairmatchingLauncher)=20:=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/PairmatchingLauncher.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java index cf5a861..e5bb269 100644 --- a/src/main/java/pairmatching/launcher/PairmatchingLauncher.java +++ b/src/main/java/pairmatching/launcher/PairmatchingLauncher.java @@ -14,27 +14,28 @@ public class PairmatchingLauncher { private final PairmatchingContext pairmatchingContext; - private PairmatchingStatus pairmatchingStatus; + private final InputView inputView = new InputView(); + private final OutputView outputView = new OutputView(); + + private PairmatchingStatus pairmatchingStatus = new InitStatus(); public PairmatchingLauncher() { - this.pairmatchingContext = new PairmatchingContextImpl(new PairmatchingView(new InputView(), new OutputView()), - new CrewGenerator(new ReadFileImpl(), new ShuffleGeneratorImpl())); + var pairMatchingView = new PairmatchingView(inputView, outputView); + var crewGenerator = new CrewGenerator(new ReadFileImpl(), new ShuffleGeneratorImpl()); + this.pairmatchingContext = new PairmatchingContextImpl(pairMatchingView, crewGenerator); } public void execute() { - this.pairmatchingStatus = new InitStatus(); - while (pairmatchingStatus.runnable()) { try { pairmatchingStatus = pairmatchingStatus.next(pairmatchingContext); } catch (IllegalArgumentException exception) { - new OutputView().printError(exception.getMessage()); + outputView.printError(exception.getMessage()); } catch (IllegalStateException exception) { - new OutputView().printError(exception.getMessage()); + outputView.printError(exception.getMessage()); pairmatchingStatus = new QuitStatus(); } } - } }