Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ private static Predicate<String> detectorAttributeFilter(
if (included == null && excluded == null) {
return ResourceFactory::matchAll;
}
// when "included" is omitted in configuration, we get an empty list
// in this context it should be interpreted as "include everything"
if (included != null && included.isEmpty()) {
included = null;
}
return IncludeExcludePredicate.createPatternMatching(included, excluded);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,16 @@ private static Stream<Arguments> createWithDetectorsArgs() {
Arguments.of(
Collections.singletonList("*o*"),
Collections.singletonList("order"),
Resource.getDefault().toBuilder().put("color", "red").build()));
Resource.getDefault().toBuilder().put("color", "red").build()),
// empty or missing include should be treated as include all
Arguments.of(
Collections.emptyList(),
Collections.singletonList("order"),
Resource.getDefault().toBuilder().put("color", "red").put("shape", "square").build()),
Arguments.of(
null,
Collections.singletonList("order"),
Resource.getDefault().toBuilder().put("color", "red").put("shape", "square").build()));
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Collections;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -25,6 +26,8 @@ class IncludeExcludePredicateTest {
IncludeExcludePredicate.createExactMatching(singletonList("foo"), singletonList("bar"));
private static final Predicate<String> EXACT_MULTI =
IncludeExcludePredicate.createExactMatching(asList("foo", "fooo"), asList("bar", "barr"));
public static final Predicate<String> EXACT_INCLUDE_NONE =
IncludeExcludePredicate.createExactMatching(Collections.emptyList(), null);

private static final Predicate<String> PATTERN_INCLUDE =
IncludeExcludePredicate.createPatternMatching(singletonList("f?o"), null);
Expand All @@ -34,6 +37,8 @@ class IncludeExcludePredicateTest {
IncludeExcludePredicate.createPatternMatching(singletonList("f?o"), singletonList("b?r"));
private static final Predicate<String> PATTERN_MULTI =
IncludeExcludePredicate.createPatternMatching(asList("f?o", "f?oo"), asList("b?r", "b?rr"));
public static final Predicate<String> PATTERN_INCLUDE_NONE =
IncludeExcludePredicate.createPatternMatching(Collections.emptyList(), null);

@ParameterizedTest
@MethodSource("testArgs")
Expand Down Expand Up @@ -70,6 +75,8 @@ private static Stream<Arguments> testArgs() {
Arguments.of(EXACT_MULTI, "bar", false),
Arguments.of(EXACT_MULTI, "barr", false),
Arguments.of(EXACT_MULTI, "baz", false),
// include none
Arguments.of(EXACT_INCLUDE_NONE, "foo", false),
// pattern matching
// include only
Arguments.of(PATTERN_INCLUDE, "foo", true),
Expand Down Expand Up @@ -99,7 +106,9 @@ private static Stream<Arguments> testArgs() {
Arguments.of(PATTERN_MULTI, "bAr", false),
Arguments.of(PATTERN_MULTI, "barr", false),
Arguments.of(PATTERN_MULTI, "bArr", false),
Arguments.of(PATTERN_MULTI, "baz", false));
Arguments.of(PATTERN_MULTI, "baz", false),
// include none
Arguments.of(PATTERN_INCLUDE_NONE, "foo", false));
}

@ParameterizedTest
Expand Down
Loading