You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2022/12/26 10:15:41 UTC

[syncope] branch 3_0_X updated: Fixing flaky SearchITCase#searchConnObjectsBrowsePagedResult

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

ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/3_0_X by this push:
     new 3171c01fab Fixing flaky SearchITCase#searchConnObjectsBrowsePagedResult
3171c01fab is described below

commit 3171c01faba7fdfabe0bd50573b5bb6f2ec0531a
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Mon Dec 26 11:15:18 2022 +0100

    Fixing flaky SearchITCase#searchConnObjectsBrowsePagedResult
---
 .../org/apache/syncope/fit/core/SearchITCase.java  | 40 +++++++++-------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
index ca2c365407..c63988102f 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
@@ -26,7 +26,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -35,7 +34,6 @@ import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.client.lib.batch.BatchRequest;
-import org.apache.syncope.client.ui.commons.ConnIdSpecialName;
 import org.apache.syncope.common.lib.Attr;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.SyncopeConstants;
@@ -509,35 +507,29 @@ public class SearchITCase extends AbstractITCase {
     @Test
     public void searchConnObjectsBrowsePagedResult() {
         List<String> groupKeys = new ArrayList<>();
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 11; i++) {
             GroupCR groupCR = GroupITCase.getSample("group");
             groupCR.getResources().add(RESOURCE_NAME_LDAP);
             GroupTO group = createGroup(groupCR).getEntity();
             groupKeys.add(group.getKey());
         }
 
-        int totalRead = 0;
-        Set<String> read = new HashSet<>();
-        try {
-            ConnObjectTOQuery.Builder builder = new ConnObjectTOQuery.Builder().size(10);
-            PagedConnObjectResult matches;
-            do {
-                matches = RESOURCE_SERVICE.searchConnObjects(
-                        RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), builder.build());
-                assertNotNull(matches);
-
-                totalRead += matches.getResult().size();
-                read.addAll(matches.getResult().stream().
-                        map(input -> input.getAttr(ConnIdSpecialName.NAME).get().getValues().get(0)).
-                        collect(Collectors.toList()));
-
-                if (matches.getPagedResultsCookie() != null) {
-                    builder.pagedResultsCookie(matches.getPagedResultsCookie());
-                }
-            } while (matches.getPagedResultsCookie() != null);
+        ConnObjectTOQuery.Builder builder = new ConnObjectTOQuery.Builder().size(10);
 
-            assertEquals(totalRead, read.size());
-            assertTrue(totalRead >= groupKeys.size());
+        try {
+            PagedConnObjectResult matches = RESOURCE_SERVICE.searchConnObjects(
+                    RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), builder.build());
+            assertNotNull(matches);
+            assertNotNull(matches.getPagedResultsCookie());
+            int firstRound = matches.getResult().size();
+
+            builder.pagedResultsCookie(matches.getPagedResultsCookie());
+            matches = RESOURCE_SERVICE.searchConnObjects(
+                    RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), builder.build());
+            assertNotNull(matches);
+            int secondRound = matches.getResult().size();
+
+            assertTrue(firstRound + secondRound >= groupKeys.size());
         } finally {
             BatchRequest batchRequest = ADMIN_CLIENT.batch();
             GroupService batchGroupService = batchRequest.getService(GroupService.class);