jbertram commented on code in PR #6387:
URL: https://github.com/apache/artemis/pull/6387#discussion_r3156316722


##########
artemis-core-client/src/test/java/org/apache/activemq/artemis/core/client/impl/AsynchronousProducerCreditsImplTest.java:
##########
@@ -32,4 +38,51 @@ public void testZeroCredits() throws Exception {
       Mockito.verify(session).sendProducerCreditsMessage(0, null);
    }
 
+   @Test
+   @Timeout(10)
+   public void testCreditsRequestedWhenMessageSizeExactlyEqualsBalance() 
throws Exception {
+      ClientSessionInternal mockClientSession = 
Mockito.mock(ClientSessionInternal.class);
+
+      AtomicInteger creditsRequested = new AtomicInteger(0);
+      AtomicBoolean blocked = new AtomicBoolean(false);
+
+      int producerWindowSize = 1000;
+
+      Mockito.doAnswer(inv -> {
+         creditsRequested.addAndGet(inv.getArgument(0));
+         return null;
+      }).when(mockClientSession).sendProducerCreditsMessage(Mockito.anyInt(), 
Mockito.any());
+
+      AsynchronousProducerCreditsImpl producerCredits = new 
AsynchronousProducerCreditsImpl(mockClientSession, null, producerWindowSize, 
bridgeFlowCallback(blocked));

Review Comment:
   Instead of having the `private` `static` method I think this is a bit more 
clear:
   ```java
         AsynchronousProducerCreditsImpl producerCredits = new 
AsynchronousProducerCreditsImpl(mockClientSession, null, producerWindowSize, 
new ClientProducerFlowCallback() {
            @Override
            public void onCreditsFlow(boolean isBlocked, ClientProducerCredits 
credits) {
               blocked.set(isBlocked);
            }
   
            @Override
            public void onCreditsFail(ClientProducerCredits credits) {
            }
         });
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to