Skip to content

Commit

Permalink
[Chore] #274 - isKeyResultAchieved에 따른 로그 추가 테스트코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
0lynny committed May 28, 2024
1 parent 76b8616 commit 90a9178
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down Expand Up @@ -52,9 +54,10 @@ static void setUp() {
fakeUser = User.buildWithId().id(fakeUserId).nickname(fakeUserNickname).build();
}

@Test
@ParameterizedTest
@DisplayName("KeyResult의 진척 상황을 기록하고 체크인 로그를 추가합니다.")
void KeyResult의_진척상황을_기록하고_체크인_로그를_추가합니다() {
@CsvSource(value = {"1, true", "100, false"})
void KeyResult의_진척상황을_기록하고_체크인_로그를_추가합니다(short progress, boolean expected) {
// given
Objective testObjective = mock(Objective.class);
KeyResult testKeyResult = mock(KeyResult.class);
Expand All @@ -70,15 +73,15 @@ static void setUp() {
given(logRepository.save(any(Log.class))).willReturn(testLog);
given(testObjective.getKeyResultList()).willReturn(List.of(testKeyResult));

given(testObjective.getProgress()).willReturn((short)1);
given(testObjective.getProgress()).willReturn((short)progress);

//when
Optional<AchieveResponseDto> response = logService.createRecordLog(fakeUser.getId(), request);

//then
verify(testKeyResult, times(1)).modifyProgress(anyShort());
verify(testObjective, times(1)).modifyProgress(anyShort());
assertThat(response.isEmpty()).isEqualTo(true);
assertThat(response.isEmpty()).isEqualTo(expected);
}

@Test
Expand Down

0 comments on commit 90a9178

Please sign in to comment.