WIP:test: HandoverIT-POC - Refactored `TestWriter` to use a `Flux`
authorKai Moritz <kai@juplo.de>
Fri, 1 Mar 2024 18:55:16 +0000 (19:55 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 1 Mar 2024 18:55:16 +0000 (19:55 +0100)
src/test/java/de/juplo/kafka/chat/backend/TestWriter.java

index 08634b8..267519e 100644 (file)
@@ -44,6 +44,11 @@ public class TestWriter implements Runnable
         .flatMap(message -> sendMessage(chatRoom, message)
             .delayElement(Duration.ofMillis(ThreadLocalRandom.current().nextLong(500, 1500)))
             .retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1))))
+        .doOnNext(message -> log.info(
+            "{} sent a message to {}: {}",
+            user,
+            chatRoom,
+            message))
         .doOnError(throwable ->
         {
           WebClientResponseException e = (WebClientResponseException)throwable.getCause();
@@ -52,11 +57,6 @@ public class TestWriter implements Runnable
               user,
               e.getResponseBodyAsString(Charset.defaultCharset()));
         })
-        .doOnNext(message -> log.info(
-            "{} sent a message to {}: {}",
-            user,
-            chatRoom,
-            message))
         .then()
         .block();
   }