Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs/Fix for flaky push rich text repsonses to contentful error #260

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ private void createRichTextQuestionsInContentful(final GrantAdvert advert, final
contentfulProperties.getSpaceId(), contentfulProperties.getEnvironmentId(),
contentfulAdvert.getId());

if (responses == null || responses.isEmpty()) {
log.error("createRichTextQuestionsInContentful failed on PATCH to {}, with message: No rich text responses found", contentfulUrl);
}

final Instant now = Instant.now();
webClientBuilder.build()
.patch()
Expand All @@ -434,13 +438,13 @@ private void createRichTextQuestionsInContentful(final GrantAdvert advert, final
})
.bodyValue(requestBody)
.retrieve()
.bodyToMono(void.class)
.bodyToMono(Void.class)
.doOnError(exception -> {
log.error("createRichTextQuestionsInContentful failed on PATCH to {}, with message: {}", contentfulUrl, exception.getMessage());
log.debug("Took {} seconds to try and update rich text questions in Contentful", Duration.between(now, Instant.now()).getSeconds());
log.info("Took {} seconds to try and update rich text questions in Contentful", Duration.between(now, Instant.now()).getSeconds());
})
.block();
log.debug("Took {} seconds to update rich text questions in Contentful", Duration.between(now, Instant.now()).getSeconds());
log.info("Took {} seconds to update rich text questions in Contentful", Duration.between(now, Instant.now()).getSeconds());
}

private List<GrantAdvertQuestionResponse> getRichTextResponses(final GrantAdvert advert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ void publishAdvert_successfullyPublishedAdvert() {
when(requestBodyUriSpec.headers(any())).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.bodyValue(any())).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
when(responseSpec.bodyToMono(void.class)).thenReturn(Mono.empty());
when(responseSpec.bodyToMono(Void.class)).thenReturn(Mono.empty());

final ArgumentCaptor<CMAEntry> entryCaptor = ArgumentCaptor.forClass(CMAEntry.class);

Expand Down Expand Up @@ -867,7 +867,7 @@ void publishAdvert_successfullyPublishedAdvert() {
verify(requestBodyUriSpec).headers(any());
verify(requestBodyUriSpec).bodyValue(any());
verify(requestHeadersSpec).retrieve();
verify(responseSpec).bodyToMono(void.class);
verify(responseSpec).bodyToMono(Void.class);

// verify that we've refreshed the data after adding RTF data
verify(contentfulEntries).fetchOne(contentfulAdvertId);
Expand Down Expand Up @@ -912,7 +912,7 @@ void publishAdvert_updatesExistingAdvert_IfFirstPublishedDateHasBeenSet() {
when(requestBodyUriSpec.headers(any())).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.bodyValue(any())).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
when(responseSpec.bodyToMono(void.class)).thenReturn(Mono.empty());
when(responseSpec.bodyToMono(Void.class)).thenReturn(Mono.empty());

final ArgumentCaptor<GrantAdvert> grantAdvertArgumentCaptor = ArgumentCaptor.forClass(GrantAdvert.class);

Expand All @@ -931,7 +931,7 @@ void publishAdvert_updatesExistingAdvert_IfFirstPublishedDateHasBeenSet() {
verify(requestBodyUriSpec).headers(any());
verify(requestBodyUriSpec).bodyValue(any());
verify(requestHeadersSpec).retrieve();
verify(responseSpec).bodyToMono(void.class);
verify(responseSpec).bodyToMono(Void.class);

verify(contentfulEntries).update(publishedContentfulAdvert);

Expand Down Expand Up @@ -962,7 +962,7 @@ void publishAdvertThroughLambda_successfullyPublishedAdvert() {
when(requestBodyUriSpec.headers(any())).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.bodyValue(any())).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
when(responseSpec.bodyToMono(void.class)).thenReturn(Mono.empty());
when(responseSpec.bodyToMono(Void.class)).thenReturn(Mono.empty());
doReturn(mockGrantAdvert).when(grantAdvertService).save(any());

when(advertDefinition.getSections()).thenReturn(definition.getSections());
Expand Down Expand Up @@ -1015,7 +1015,7 @@ void publishAdvertThroughLambda_successfullyPublishedAdvert() {
verify(requestBodyUriSpec).headers(any());
verify(requestBodyUriSpec).bodyValue(any());
verify(requestHeadersSpec).retrieve();
verify(responseSpec).bodyToMono(void.class);
verify(responseSpec).bodyToMono(Void.class);

// verify that we've refreshed the data after adding RTF data
verify(contentfulEntries).fetchOne(contentfulAdvertId);
Expand Down
Loading