Skip to content

Commit

Permalink
chore: Fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed Sep 29, 2024
1 parent ba58563 commit 77f8879
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/main/java/com/endava/cats/args/FilterArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,25 +423,24 @@ private List<String> constructFuzzersListFromCheckArguments() {
finalList = fuzzers.stream().map(Object::toString).toList();
}

this.removeIfNotSupplied(checkArguments.isIncludeControlChars(), ControlCharFuzzer.class, finalList);
this.removeIfNotSupplied(checkArguments.isIncludeEmojis(), EmojiFuzzer.class, finalList);
this.removeIfNotSupplied(checkArguments.isIncludeWhitespaces(), WhitespaceFuzzer.class, finalList);
this.removeIfNotSupplied(checkArguments.isIncludeContract(), LinterFuzzer.class, finalList);
finalList = this.filterByAnnotationAndIncludeArgument(checkArguments.isIncludeControlChars(), ControlCharFuzzer.class, finalList);
finalList = this.filterByAnnotationAndIncludeArgument(checkArguments.isIncludeEmojis(), EmojiFuzzer.class, finalList);
finalList = this.filterByAnnotationAndIncludeArgument(checkArguments.isIncludeWhitespaces(), WhitespaceFuzzer.class, finalList);
finalList = this.filterByAnnotationAndIncludeArgument(checkArguments.isIncludeContract(), LinterFuzzer.class, finalList);

return finalList;
}

private void removeIfNotSupplied(boolean includeArgument, Class<? extends Annotation> annotation, List<String> currentFuzzers) {
private List<String> filterByAnnotationAndIncludeArgument(boolean includeArgument, Class<? extends Annotation> annotation, List<String> currentFuzzers) {
if (includeArgument) {
// if special characters fuzzers are included, we exit and don't remove them
return;
return currentFuzzers;
}

for (Fuzzer fuzzer : fuzzers) {
if (AnnotationUtils.findAnnotation(fuzzer.getClass(), annotation) != null) {
currentFuzzers.remove(fuzzer.toString());
}
}
return currentFuzzers.stream()
.filter(fuzzerStr -> fuzzers.stream()
.noneMatch(fuzzer -> AnnotationUtils.findAnnotation(fuzzer.getClass(), annotation) != null
&& fuzzer.toString().equals(fuzzerStr)))
.toList();
}

private List<String> filterFuzzersByAnnotationWhenCheckArgumentSupplied(boolean checkArgument, Class<? extends Annotation> annotation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ private static boolean isNullSchema(Schema innerType) {

int getArrayLength(Schema<?> property) {
int min = null == property.getMinItems() ? 1 : property.getMinItems();
int max = null == property.getMaxItems() ? 2 : property.getMaxItems();
int max = null == property.getMaxItems() ? min + 1 : property.getMaxItems();

return Math.clamp(this.arraySize, min, max);
}
Expand Down

0 comments on commit 77f8879

Please sign in to comment.