From 912aa46ad15c7879222956cb78907ada10dd6bb6 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 16 Sep 2024 11:02:05 -0700 Subject: [PATCH] Clean up more comments. Clean up more comments. --- .../api/batchgraduation/rest/RESTService.java | 12 ++++-- ...RunCompletionNotificationListenerTest.java | 37 ------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java index 1ab9eb4d..c5e128de 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RESTService.java @@ -56,8 +56,10 @@ public T get(String url, Class clazz, String accessToken) { .onStatus(HttpStatusCode::is5xxServerError, clientResponse -> Mono.error(new ServiceException(getErrorMessage(url, ERROR_MESSAGE1), clientResponse.statusCode().value()))) .bodyToMono(clazz) - // only does retry if initial error was 5xx as service may be temporarily down - // 4xx errors will always happen if 404, 401, 403 etc., so does not retry + /* + - retry if initial error is 5xx as service may be temporarily down + - do not retry if 4xx errors happens like 404, 401, 403 etc. + */ .retryWhen(reactor.util.retry.Retry.backoff(constants.getDefaultRetryMaxAttempts(), Duration.ofSeconds(constants.getDefaultRetryWaitDurationSeconds())) .filter(ServiceException.class::isInstance) .onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> { @@ -87,8 +89,10 @@ public T get(String url, Class clazz) { .onStatus(HttpStatusCode::is5xxServerError, clientResponse -> Mono.error(new ServiceException(getErrorMessage(url, ERROR_MESSAGE1), clientResponse.statusCode().value()))) .bodyToMono(clazz) - // only does retry if initial error was 5xx as service may be temporarily down - // 4xx errors will always happen if 404, 401, 403 etc., so does not retry + /* + - retry if initial error is 5xx as service may be temporarily down + - do not retry if 4xx errors happens like 404, 401, 403 etc. + */ .retryWhen(reactor.util.retry.Retry.backoff(constants.getDefaultRetryMaxAttempts(), Duration.ofSeconds(constants.getDefaultRetryWaitDurationSeconds())) .filter(ServiceException.class::isInstance) .onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> { diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java index e7e87c42..23141d8e 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java @@ -22,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.core.ParameterizedTypeReference; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Mono; @@ -86,7 +85,6 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); - Map mapDist = new HashMap<>(); DistributionPrintRequest dpR = new DistributionPrintRequest(); @@ -154,24 +152,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut mapDist.put("05005001",dpR); DistributionDataParallelDTO dp = new DistributionDataParallelDTO(tList,cList); - ParameterizedTypeReference> tListRes = new ParameterizedTypeReference<>() { - }; - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getTranscriptDistributionList())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(tListRes)).thenReturn(Mono.just(tList)); - when(this.restService.get(constants.getTranscriptDistributionList(), List.class, "accessToken")).thenReturn(tList); - - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getTranscriptYearlyDistributionList())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(tListRes)).thenReturn(Mono.just(tList)); - when(this.restService.get(constants.getTranscriptYearlyDistributionList(), List.class, "accessToken")).thenReturn(tList); ReportGradStudentData reportGradStudentData = new ReportGradStudentData(); @@ -179,25 +160,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut reportGradStudentData.setFirstName(scd.getLegalFirstName()); reportGradStudentData.setLastName(scd.getLegalLastName()); -// ParameterizedTypeReference> repListRes = new ParameterizedTypeReference<>() { -// }; -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getStudentDataNonGradEarlyByMincode())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(repListRes)).thenReturn(Mono.just(List.of(reportGradStudentData))); - when(this.restService.get(constants.getStudentDataNonGradEarlyByMincode(), List.class, "accessToken")).thenReturn(List.of(reportGradStudentData)); - - ParameterizedTypeReference> cListRes = new ParameterizedTypeReference<>() { - }; - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getCertificateDistributionList())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(cListRes)).thenReturn(Mono.just(cList)); - when(this.restService.get(constants.getCertificateDistributionList(), List.class, "accessToken")).thenReturn(cList); ResponseObj obj = new ResponseObj();