From 3d50bc4a7be7090cdb3a23d5b14e9b01e34a1647 Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Tue, 28 May 2024 16:52:06 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20#274=20-=20=EC=A7=84=EC=B2=99=EC=83=81?= =?UTF-8?q?=ED=99=A9=20=EC=9E=85=EB=A0=A5=20=EC=8B=9C=20=EC=9D=B4=EC=A0=84?= =?UTF-8?q?=20=EA=B0=92=EA=B3=BC=20=EB=8F=99=EC=9D=BC=ED=95=9C=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=98=88=EC=99=B8=20=EB=B0=9C=EC=83=9D=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 --- .../moonshot/log/service/LogServiceTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/moonshot-api/src/test/java/org/moonshot/log/service/LogServiceTest.java b/moonshot-api/src/test/java/org/moonshot/log/service/LogServiceTest.java index ba11bde2..ed396d1e 100644 --- a/moonshot-api/src/test/java/org/moonshot/log/service/LogServiceTest.java +++ b/moonshot-api/src/test/java/org/moonshot/log/service/LogServiceTest.java @@ -81,4 +81,26 @@ static void setUp() { assertThat(response.isEmpty()).isEqualTo(true); } + @Test + @DisplayName("KeyResult의 진척 상황의 값이 이전 진척 상황 값과 동일하여 예외가 발생합니다.") + void KeyResult의_진척상황_값이_이전_진척상황_값과_동일하여_예외가_발생합니다() { + //given + Objective testObjective = mock(Objective.class); + KeyResult testKeyResult = mock(KeyResult.class); + Log testPrevLog = mock(Log.class); + LogCreateRequestDto request = new LogCreateRequestDto(1L, 1000L, "new log content"); + + given(keyResultRepository.findKeyResultAndObjective(request.keyResultId())).willReturn(Optional.of(testKeyResult)); + given(testKeyResult.getObjective()).willReturn(testObjective); + given(testObjective.getUser()).willReturn(fakeUser); + + given(logRepository.findLatestLogByKeyResultId(eq(LogState.RECORD), anyLong())).willReturn(Optional.of(testPrevLog)); + given(testPrevLog.getCurrNum()).willReturn(1000L); + + //when, then + assertThatThrownBy(() -> logService.createRecordLog(fakeUser.getId(), request)) + .isInstanceOf(BadRequestException.class) + .hasMessage("Log 입력값은 이전 값과 동일할 수 없습니다."); + } + } \ No newline at end of file