diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index ed7d18a6522..17c5798e1cf 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -80,6 +80,11 @@
2.27.2
test
+
+ org.awaitility
+ awaitility
+ test
+
diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/GroupsIT.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/GroupsIT.groovy
index 141cf9decba..4458d2a623b 100644
--- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/GroupsIT.groovy
+++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/GroupsIT.groovy
@@ -154,9 +154,8 @@ class GroupsIT extends ITSupport {
sleep(3000)
assertUserInGroup(user, group, groupApi, 10, getTestOperationDelay())
- // 3. Remove user from group and validate user removed
- groupApi.unassignUserFromGroup(group.getId(), user.getId())
+ groupApi.unassignUserFromGroup(group.getId(), user.getId());
- assertUserNotInGroup(user, group, groupApi,10, getTestOperationDelay())
+ assertUserNotInGroup(user, group, groupApi);
}
}
\ No newline at end of file
diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/Util.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/Util.groovy
index 40ef3de9ee5..d2eca8e5a8e 100644
--- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/Util.groovy
+++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/Util.groovy
@@ -29,6 +29,9 @@ import static org.hamcrest.MatcherAssert.assertThat
import static org.hamcrest.Matchers.equalTo
import static org.hamcrest.Matchers.hasSize
import static org.hamcrest.Matchers.notNullValue
+import static org.awaitility.Awaitility.await
+import static java.util.concurrent.TimeUnit.SECONDS
+import static org.hamcrest.Matchers.is
class Util {
@@ -117,26 +120,25 @@ class Util {
if (!present) Assert.fail("User found in group")
}
- static void assertUserNotInGroup(User user, Group group, GroupApi groupApi) {
- assertThat "User was found in group.", !StreamSupport.stream(groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false)
- .filter{ listUser -> listUser.id == user.id}
- .findFirst().isPresent()
- }
-
- static void assertUserNotInGroup(User user, Group group, GroupApi groupApi, int times, long delayInMilliseconds) {
- for (int ii = 0; ii < times; ii++) {
- sleep(delayInMilliseconds)
+// static void assertUserNotInGroup(User user, Group group, GroupApi groupApi) {
+// assertThat "User was found in group.", !StreamSupport.stream(groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false)
+// .filter{ listUser -> listUser.id == user.id}
+// .findFirst().isPresent()
+// }
- boolean userIsPresent = StreamSupport.stream(
- groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false
- ).anyMatch { listUser -> listUser.id == user.id }
- if (!userIsPresent) {
- return
- }
- }
-
- Assert.fail("User found in group after ${times} attempts")
+ static void assertUserNotInGroup(User user, Group group, GroupApi groupApi) {
+ await()
+ .atMost(60, SECONDS) // Wait for a maximum of 60 seconds.
+ .pollInterval(2, SECONDS) // Check every 2 seconds.
+ .untilAsserted(() -> {
+ boolean userIsPresent = StreamSupport.stream(
+ groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false
+ ).anyMatch(listUser -> listUser.id.equals(user.id));
+
+ // This assertion will be retried until it passes or the timeout is reached.
+ assertThat("User should not be present in the group.", userIsPresent, is(false));
+ });
}
diff --git a/pom.xml b/pom.xml
index ca7bae68a76..8ed05144212 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
1.78.1
0.12.6
5.3.1
- 23.0.1
+ 24.0.0
2.0.1
1.1.1
okta/okta-sdk-java
@@ -87,6 +87,13 @@
okta-commons-lang
${okta.commons.version}
+
+
+ org.apache.commons
+ commons-lang3
+ 3.18.0
+
+
com.okta.commons
okta-http-api
@@ -209,6 +216,11 @@
${slf4j.version}
test
+
+ org.awaitility
+ awaitility
+ 4.2.1
+