diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml
index 0a7c4b0860..fa0f666c7f 100644
--- a/testing-modules/testing-assertions/pom.xml
+++ b/testing-modules/testing-assertions/pom.xml
@@ -18,11 +18,45 @@
logback-classic
1.2.3
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.6.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.6.2
+ test
+
org.assertj
assertj-core
- 3.15.0
+ 3.16.1
+ test
+
+
+ org.hamcrest
+ hamcrest-all
+ 1.3
+ test
+
+
+ org.apache.commons
+ commons-collections4
+ 4.4
test
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.1
+
+
+
diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/listassert/OrderAgnosticListComparisonUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/listassert/OrderAgnosticListComparisonUnitTest.java
new file mode 100644
index 0000000000..bf278cea90
--- /dev/null
+++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/listassert/OrderAgnosticListComparisonUnitTest.java
@@ -0,0 +1,54 @@
+package com.baeldung.listassert;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class OrderAgnosticListComparisonUnitTest {
+
+ private final List first = Arrays.asList(1, 3, 4, 6, 8);
+ private final List second = Arrays.asList(8, 1, 6, 3, 4);
+ private final List third = Arrays.asList(1, 3, 3, 6, 6);
+
+ @Test
+ public void whenTestingForOrderAgnosticEquality_ShouldBeTrue() {
+ assertTrue(first.size() == second.size() && first.containsAll(second) && second.containsAll(first));
+ }
+
+ @Test
+ public void whenTestingForOrderAgnosticEquality_ShouldBeFalse() {
+ assertFalse(first.size() == third.size() && first.containsAll(third) && third.containsAll(first));
+ }
+
+ @Test
+ public void whenTestingForOrderAgnosticEquality_ShouldBeEqual() {
+ MatcherAssert.assertThat(first, Matchers.containsInAnyOrder(second.toArray()));
+ }
+
+ @Test
+ public void whenTestingForOrderAgnosticEquality_ShouldBeTrueIfEqualOtherwiseFalse() {
+ assertTrue(CollectionUtils.isEqualCollection(first, second));
+ assertFalse(CollectionUtils.isEqualCollection(first, third));
+ }
+
+ @Test
+ void whenTestingForOrderAgnosticEqualityBothList_ShouldBeEqual() {
+ assertThat(first).hasSameElementsAs(second);
+ }
+
+ @Test
+ void whenTestingForOrderAgnosticEqualityBothList_ShouldNotBeEqual() {
+ List a = Arrays.asList("a", "a", "b", "c");
+ List b = Arrays.asList("a", "b", "c");
+
+ assertThat(a).hasSameElementsAs(b);
+ }
+}