You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2025/02/28 10:15:18 UTC
(sling-org-apache-sling-fsresource) 01/01: SLING-12685 improve error reporting for flaky unit test
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12685-flaky-tests
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit da93afc5f7cccfec75c7e77a150d0a3210584f25
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Feb 28 11:15:04 2025 +0100
SLING-12685 improve error reporting for flaky unit test
---
.../org/apache/sling/fsprovider/internal/TestUtils.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java b/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
index e3701ac..0f8e1a6 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -107,14 +108,14 @@ class TestUtils {
}
public static void assertChange(List<ResourceChange> changes, String path, ChangeType changeType) {
- boolean found = false;
- for (ResourceChange change : changes) {
- if (StringUtils.equals(change.getPath(), path) && change.getType() == changeType) {
- found = true;
- break;
- }
- }
- assertTrue("Change with path=" + path + ", changeType=" + changeType + " expected", found);
+ List<ChangeType> changeTypesForPath = changes.stream()
+ .filter(change -> StringUtils.equals(change.getPath(), path))
+ .map(ResourceChange::getType)
+ .collect(Collectors.toList());
+ assertTrue(
+ "Change with path=" + path + ", changeType=" + changeType + " expected, but found: ["
+ + changeTypesForPath + "]",
+ changeTypesForPath.contains(changeType));
}
public static class ResourceListener implements ResourceChangeListener {