Skip to content

Commit 943f3b7

Browse files
author
m.zharinova
committed
refactoring
1 parent 7cb0604 commit 943f3b7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

spring-boot-2-demo-app/src/test/java/io/github/mfvanek/spring/boot2/test/controllers/TimeControllerTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void mdcValuesShouldBeReportedInLogs(@Nonnull final CapturedOutput output) {
170170

171171
@SneakyThrows
172172
@Test
173-
void spanShouldBeReportedInRetryLogs(@Nonnull final CapturedOutput output) {
173+
void spanAndMdcShouldBeReportedWhenRetry(@Nonnull final CapturedOutput output) {
174174
final String zoneNames = TimeZone.getDefault().getID();
175175
final RuntimeException exception = new RuntimeException("Retries exhausted");
176176
stubFor(get(urlPathMatching("/" + zoneNames))
@@ -217,6 +217,11 @@ void spanShouldBeReportedInRetryLogs(@Nonnull final CapturedOutput output) {
217217
.pollInterval(Duration.ofMillis(500L))
218218
.until(() -> countRecordsInTable() >= 1L);
219219
assertThat(output.getAll())
220-
.contains("Received record: " + received.value() + " with traceId " + traceId);
220+
.contains(
221+
"Received record: " + received.value() + " with traceId " + traceId,
222+
"Retrying request to ",
223+
"Retries exhausted",
224+
"\"instance_timezone\":\"" + zoneNames + "\""
225+
);
221226
}
222227
}

spring-boot-3-demo-app/src/test/java/io/github/mfvanek/spring/boot3/test/controllers/TimeControllerTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void mdcValuesShouldBeReportedInLogs(@Nonnull final CapturedOutput output) {
169169

170170
@SneakyThrows
171171
@Test
172-
void mdcValuesShouldBeReportedInRetryLogs(@Nonnull final CapturedOutput output) {
172+
void mdcValuesShouldBeReportedWhenRetry(@Nonnull final CapturedOutput output) {
173173
final String zoneNames = TimeZone.getDefault().getID();
174174
final RuntimeException exception = new RuntimeException("Retries exhausted");
175175
stubFor(get(urlPathMatching("/" + zoneNames))
@@ -216,11 +216,11 @@ void mdcValuesShouldBeReportedInRetryLogs(@Nonnull final CapturedOutput output)
216216
.pollInterval(Duration.ofMillis(500L))
217217
.until(() -> countRecordsInTable() >= 1L);
218218
assertThat(output.getAll())
219-
.contains("Received record: " + received.value() + " with traceId " + traceId);
220-
assertThat(output.getAll()).contains("Retrying request to ", "Retries exhausted", "\"instance_timezone\":\"" + zoneNames + "\"");
221-
final String messageFromDb = namedParameterJdbcTemplate.queryForObject("select message from otel_demo.storage where trace_id = :traceId",
222-
Map.of("traceId", traceId), String.class);
223-
assertThat(messageFromDb)
224-
.isEqualTo(received.value());
219+
.contains(
220+
"Received record: " + received.value() + " with traceId " + traceId,
221+
"Retrying request to ",
222+
"Retries exhausted",
223+
"\"instance_timezone\":\"" + zoneNames + "\""
224+
);
225225
}
226226
}

0 commit comments

Comments
 (0)