davsclaus commented on code in PR #25842:
URL: https://github.com/apache/camel/pull/25842#discussion_r3883042944


##########
components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cluster/integration/ZooKeeperClusterViewLeadershipLostIT.java:
##########
@@ -66,9 +70,12 @@ public void configure() throws Exception {
                 }
             });
 
-            context.start();
-
             CamelClusterView view = clusterService.getView(NAMESPACE);
+            view.addEventListener((CamelClusterEventListener.Leadership) (
+                    view1, leader) -> 
numberOfLeadershipChangedPushed.incrementAndGet()
+            );

Review Comment:
   `mvn formatter:format` reformats this closing paren onto the previous line 
(and also renames nothing, just re-wraps):
   ```suggestion
               view.addEventListener((CamelClusterEventListener.Leadership) (
                       view1, leader) -> 
numberOfLeadershipChangedPushed.incrementAndGet());
   ```
   Separately (non-blocking): naming the lambda parameter `view1` to dodge 
shadowing the outer `view` local is a bit awkward — consider renaming the outer 
variable instead (e.g. `clusterView`) for readability.



##########
components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cluster/integration/ZooKeeperClusterViewLeadershipLostIT.java:
##########
@@ -105,6 +112,23 @@ public void configure() throws Exception {
                                 
context.getRouteController().getRouteStatus(ROUTE_ID).isStarted(),
                                 "the clustered route must be restarted once 
the leadership is taken back");
                     });
+            view.stop();
+
+            /*
+            Give some time so the event can be consumed
+            (the correct behavior is that an event shouldn't be pushed)
+            this is just a safeguard so that if an event is pushed it has some 
time to be consumed
+            */
+            await()
+                .pollDelay(1, TimeUnit.SECONDS)
+                .atLeast(1, TimeUnit.SECONDS)
+                .atMost(2, TimeUnit.SECONDS)
+                .until(() -> true);

Review Comment:
   Formatter re-indents this chain to 8-space continuation:
   ```suggestion
               await()
                       .pollDelay(1, TimeUnit.SECONDS)
                       .atLeast(1, TimeUnit.SECONDS)
                       .atMost(2, TimeUnit.SECONDS)
                       .until(() -> true);
   ```



##########
components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cluster/integration/ZooKeeperClusterViewLeadershipLostIT.java:
##########
@@ -105,6 +112,23 @@ public void configure() throws Exception {
                                 
context.getRouteController().getRouteStatus(ROUTE_ID).isStarted(),
                                 "the clustered route must be restarted once 
the leadership is taken back");
                     });
+            view.stop();
+
+            /*
+            Give some time so the event can be consumed
+            (the correct behavior is that an event shouldn't be pushed)
+            this is just a safeguard so that if an event is pushed it has some 
time to be consumed
+            */
+            await()
+                .pollDelay(1, TimeUnit.SECONDS)
+                .atLeast(1, TimeUnit.SECONDS)
+                .atMost(2, TimeUnit.SECONDS)
+                .until(() -> true);
+
+            assertEquals(EXPECTED_PUSHED_EVENTS_NUM,
+                    numberOfLeadershipChangedPushed.get(),
+                    "the pushed Leadership Changed event must be %d otherwise 
a push happened on stop view".formatted(EXPECTED_PUSHED_EVENTS_NUM)
+            );

Review Comment:
   Formatter wraps the long `.formatted(...)` call and removes the trailing 
standalone `)`:
   ```suggestion
               assertEquals(EXPECTED_PUSHED_EVENTS_NUM,
                       numberOfLeadershipChangedPushed.get(),
                       "the pushed Leadership Changed event must be %d 
otherwise a push happened on stop view"
                               .formatted(EXPECTED_PUSHED_EVENTS_NUM));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to