Skip to content

Commit

Permalink
Clean up more comments.
Browse files Browse the repository at this point in the history
Clean up more comments.
  • Loading branch information
infstar committed Sep 16, 2024
1 parent 15f076f commit 912aa46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ public <T> T get(String url, Class<T> 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) -> {
Expand Down Expand Up @@ -87,8 +89,10 @@ public <T> T get(String url, Class<T> 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) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +85,6 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut
jobExecution.setId(121L);
ExecutionContext jobContext = new ExecutionContext();


Map<String,DistributionPrintRequest> mapDist = new HashMap<>();
DistributionPrintRequest dpR = new DistributionPrintRequest();

Expand Down Expand Up @@ -154,50 +152,15 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut
mapDist.put("05005001",dpR);
DistributionDataParallelDTO dp = new DistributionDataParallelDTO(tList,cList);

ParameterizedTypeReference<List<StudentCredentialDistribution>> 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();
reportGradStudentData.setGraduationStudentRecordId(scd.getStudentID());
reportGradStudentData.setFirstName(scd.getLegalFirstName());
reportGradStudentData.setLastName(scd.getLegalLastName());

// ParameterizedTypeReference<List<ReportGradStudentData>> 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<List<StudentCredentialDistribution>> 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();
Expand Down

0 comments on commit 912aa46

Please sign in to comment.