Skip to content

Commit

Permalink
feat : (Admin)테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyaak committed Aug 29, 2024
1 parent b4f431d commit 627dece
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import com.talkka.server.admin.util.CollectedRouteProvider;
import com.talkka.server.api.core.exception.ApiClientException;
import com.talkka.server.api.datagg.service.BusApiService;
import com.talkka.server.bus.util.ApiCallNumberProvider;
import com.talkka.server.bus.util.BusLocationCollectProvider;

@ExtendWith(MockitoExtension.class)
class BlockedApiLocationCollectServiceTest {
@InjectMocks
private BlockedApiLocationCollectService blockedApiLocationCollectService;

@Mock
private BusLocationCollectProvider busLocationCollectProvider;
private CollectedRouteProvider collectedRouteProvider;
@Mock
private ApiCallNumberProvider apiCallNumberProvider;
@Mock
Expand All @@ -34,13 +34,13 @@ class BlockedApiLocationCollectServiceTest {
@DisplayName("target list 에 따라 bus location 을 수집한다.")
void collectLocations() {
// given
given(busLocationCollectProvider.getTargetIdList()).willReturn(List.of("200000150"));
given(collectedRouteProvider.getTargetIdList()).willReturn(List.of("200000150"));
given(apiCallNumberProvider.getApiCallNumber()).willReturn(1);
given(busApiService.getBusLocationInfo(anyString())).willReturn(List.of());
// when
blockedApiLocationCollectService.collectLocations();
// then
verify(busLocationCollectProvider).getTargetIdList();
verify(collectedRouteProvider).getTargetIdList();
verify(apiCallNumberProvider).getApiCallNumber();
verify(busApiService).getBusLocationInfo(anyString());
verify(busLocationService).saveBusLocations(anyList(), anyInt(), any());
Expand All @@ -50,25 +50,25 @@ void collectLocations() {
@DisplayName("target list 이 비어있을 때 bus location 을 수집하지 않는다.")
void collectLocationsWhenTargetListIsEmpty() {
// given
given(busLocationCollectProvider.getTargetIdList()).willReturn(List.of());
given(collectedRouteProvider.getTargetIdList()).willReturn(List.of());
// when
blockedApiLocationCollectService.collectLocations();
// then
verify(busLocationCollectProvider).getTargetIdList();
verify(collectedRouteProvider).getTargetIdList();
verifyNoInteractions(apiCallNumberProvider, busApiService, busLocationService);
}

@Test
@DisplayName("bus location 을 수집하는 도중 api client exception 이 발생하면 로그를 남긴다.")
void collectLocationsWhenApiClientExceptionOccurs() {
// given
given(busLocationCollectProvider.getTargetIdList()).willReturn(List.of("200000150"));
given(collectedRouteProvider.getTargetIdList()).willReturn(List.of("200000150"));
given(apiCallNumberProvider.getApiCallNumber()).willReturn(1);
given(busApiService.getBusLocationInfo(anyString())).willThrow(new ApiClientException("API client exception"));
// when
blockedApiLocationCollectService.collectLocations();
// then
verify(busLocationCollectProvider).getTargetIdList();
verify(collectedRouteProvider).getTargetIdList();
verify(apiCallNumberProvider).getApiCallNumber();
verify(busApiService).getBusLocationInfo(anyString());
verifyNoInteractions(busLocationService);
Expand Down

0 comments on commit 627dece

Please sign in to comment.