diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95f2a83..a520b72 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.9.0] - unreleased
+## [0.8.2] - 2024-11-13
+
+* [#18](https://github.com/itsallcode/hamcrest-auto-matcher/issues/18): Ignore order for Sets
+
## [0.8.1] - 2024-09-12
* [#17](https://github.com/itsallcode/hamcrest-auto-matcher/pull/17): Allow using `null` as expected value
diff --git a/README.md b/README.md
index 8e9d690..88d10f4 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ repositories {
}
dependencies {
- testImplementation 'org.itsallcode:hamcrest-auto-matcher:0.8.1'
+ testImplementation 'org.itsallcode:hamcrest-auto-matcher:0.8.2'
}
```
@@ -43,7 +43,7 @@ dependencies {
org.itsallcode
hamcrest-auto-matcher
- 0.8.1
+ 0.8.2
test
```
diff --git a/build.gradle b/build.gradle
index d2d97df..520169e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ plugins {
}
group 'org.itsallcode'
-version = '0.8.1'
+version = '0.8.2'
dependencies {
api 'org.hamcrest:hamcrest:3.0'
diff --git a/src/main/java/org/itsallcode/matcher/auto/AutoConfigBuilder.java b/src/main/java/org/itsallcode/matcher/auto/AutoConfigBuilder.java
index 2ccb8f2..7d2a35e 100644
--- a/src/main/java/org/itsallcode/matcher/auto/AutoConfigBuilder.java
+++ b/src/main/java/org/itsallcode/matcher/auto/AutoConfigBuilder.java
@@ -159,6 +159,11 @@ private static Matcher createIterableContainsMatcher(final T expected) {
final Object[] elements = StreamSupport.stream(expectedIterable //
.spliterator(), false) //
.toArray();
+ if (expected instanceof Set) {
+ @SuppressWarnings("unchecked")
+ final Matcher matcher = (Matcher) AutoMatcher.containsInAnyOrder(elements);
+ return matcher;
+ }
@SuppressWarnings("unchecked")
final Matcher matcher = (Matcher) AutoMatcher.contains(elements);
return matcher;
diff --git a/src/test/java/org/itsallcode/matcher/auto/AutoMatcherListTest.java b/src/test/java/org/itsallcode/matcher/auto/AutoMatcherListTest.java
index 8209ca7..3a2b384 100644
--- a/src/test/java/org/itsallcode/matcher/auto/AutoMatcherListTest.java
+++ b/src/test/java/org/itsallcode/matcher/auto/AutoMatcherListTest.java
@@ -44,7 +44,7 @@ void testEmptyListAndNewLinkedList() {
}
@Test
- void testEmptyListAndAsListAreEqaul() {
+ void testEmptyListAndAsListAreEqual() {
assertValuesMatch(emptyList(), asList());
}
diff --git a/src/test/java/org/itsallcode/matcher/auto/AutoMatcherSetTest.java b/src/test/java/org/itsallcode/matcher/auto/AutoMatcherSetTest.java
new file mode 100644
index 0000000..9b6750f
--- /dev/null
+++ b/src/test/java/org/itsallcode/matcher/auto/AutoMatcherSetTest.java
@@ -0,0 +1,53 @@
+package org.itsallcode.matcher.auto;
+
+import static java.util.Collections.emptySet;
+import static org.itsallcode.matcher.auto.TestUtil.assertValuesDoNotMatch;
+import static org.itsallcode.matcher.auto.TestUtil.assertValuesMatch;
+
+import java.util.*;
+
+import org.itsallcode.matcher.model.DemoAttribute;
+import org.junit.jupiter.api.RepeatedTest;
+import org.junit.jupiter.api.Test;
+
+class AutoMatcherSetTest {
+
+ @Test
+ void testEmptySet() {
+ assertValuesDoNotMatch(emptySet(), Set.of("value2"));
+ }
+
+ @Test
+ void testIncompatibleMemberTypes() {
+ assertValuesDoNotMatch(Set.of("string"), Set.of(1));
+ }
+
+ @Test
+ void testIncompatibleMemberTypesComplexTypes() {
+ assertValuesDoNotMatch(Set.of(new DemoAttribute("attr")), Set.of(1));
+ }
+
+ @Test
+ void testEmptySetAndNewHashSetList() {
+ assertValuesMatch(emptySet(), new HashSet<>());
+ }
+
+ @Test
+ void testEmptySetAndNewTreeSet() {
+ assertValuesMatch(emptySet(), new TreeSet<>());
+ }
+
+ @Test
+ void testEmptySetAndAsSetOfAreEqual() {
+ assertValuesMatch(emptySet(), Set.of());
+ }
+
+ @RepeatedTest(name = "ignores set order repetition {currentRepetition} of {totalRepetitions}", value = 50)
+ void ignoresSetOrder() {
+
+ final Set set = new HashSet<>();
+ set.add("value1");
+ set.add("value2");
+ assertValuesMatch(Set.of("value1", "value2"), set);
+ }
+}