This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 4fdf85f  [CAMEL-16886]NewCommentsConsumerTest#singleIssueCommentsTest 
fails intermitently
     new 79a86c8  Merge branch 'main' of github.com:apache/camel into main
4fdf85f is described below

commit 4fdf85f34fe15fba41965808ce744e1cab55df1b
Author: Freeman Fang <freeman.f...@gmail.com>
AuthorDate: Tue Aug 24 12:54:01 2021 -0400

    [CAMEL-16886]NewCommentsConsumerTest#singleIssueCommentsTest fails 
intermitently
---
 .../jira/consumer/NewCommentsConsumerTest.java     | 28 ++++++++++++++--------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git 
a/components/camel-jira/src/test/java/org/apache/camel/component/jira/consumer/NewCommentsConsumerTest.java
 
b/components/camel-jira/src/test/java/org/apache/camel/component/jira/consumer/NewCommentsConsumerTest.java
index dc7e220..5c3035b 100644
--- 
a/components/camel-jira/src/test/java/org/apache/camel/component/jira/consumer/NewCommentsConsumerTest.java
+++ 
b/components/camel-jira/src/test/java/org/apache/camel/component/jira/consumer/NewCommentsConsumerTest.java
@@ -129,27 +129,35 @@ public class NewCommentsConsumerTest extends 
CamelTestSupport {
 
     @Test
     public void singleIssueCommentsTest() throws Exception {
-        // create issue with 3 comments
-        Issue issue = createIssueWithComments(11, 3);
+        Issue issueWithCommends = createIssueWithComments(11L, 3000);
+        Issue issueWithNoComments = createIssue(51L);
+
         reset(issueRestClient);
-        Promise<Issue> promiseIssue = Promises.promise(issue);
-        when(issueRestClient.getIssue(anyString())).thenReturn(promiseIssue);
+        AtomicInteger regulator = new AtomicInteger();
+        when(issueRestClient.getIssue(anyString())).then(inv -> {
+            int idx = regulator.getAndIncrement();
+            Issue issue = issueWithNoComments;
+            if (idx < 1) {
+                issue = issueWithCommends;
+            }
+            return Promises.promise(issue);
+        });
         List<Comment> comments = new ArrayList<>();
-        for (Comment c : issue.getComments()) {
+        for (Comment c : issueWithCommends.getComments()) {
             comments.add(c);
         }
         // reverse the order, from oldest comment to recent
         Collections.reverse(comments);
-        // expect 3 comments
+        // expect 6000 comments
         mockResult.expectedBodiesReceived(comments);
         mockResult.assertIsSatisfied();
     }
 
     @Test
     public void multipleIssuesTest() throws Exception {
-        Issue issue1 = createIssueWithComments(20L, 2);
-        Issue issue2 = createIssueWithComments(21L, 3);
-        Issue issue3 = createIssueWithComments(22L, 1);
+        Issue issue1 = createIssueWithComments(20L, 2000);
+        Issue issue2 = createIssueWithComments(21L, 3000);
+        Issue issue3 = createIssueWithComments(22L, 1000);
         List<Issue> newIssues = new ArrayList<>();
         newIssues.add(issue1);
         newIssues.add(issue2);
@@ -178,7 +186,7 @@ public class NewCommentsConsumerTest extends 
CamelTestSupport {
         }
         // reverse the order, from oldest comment to recent
         Collections.reverse(comments);
-        // expect 6 comments
+        // expect 6000 comments
         mockResult.expectedBodiesReceived(comments);
         mockResult.assertIsSatisfied();
     }

Reply via email to