Add sample finder test for multi choice field#2903
Open
Conversation
create TestArrayDataUtils to move duplicated methods for multi choice simplify verifyFilter method in SMSourceTypeMultiChoiceTest
labkey-tchad
reviewed
Mar 4, 2026
Comment on lines
+10
to
+11
| public class TestArrayDataUtils | ||
| { |
Member
There was a problem hiding this comment.
Consider moving TestDataUtils.parseMultiValueText and ResponsiveGrid.ARRAY_OPERATORS into this class.
| case ARRAY_CONTAINS_NOT_EXACT -> !(actualValues.size() == searchValues.size() && actualValues.containsAll(searchValues)); | ||
| case ARRAY_ISEMPTY -> actualValues.isEmpty(); | ||
| case ARRAY_ISNOTEMPTY -> !actualValues.isEmpty(); | ||
| default -> true; |
Member
There was a problem hiding this comment.
Should this default to true for non-array operators? What does the server do?
Unless this matches the actual product behavior, we should just throw an IllegalArgumentException for non-array operators.
Comment on lines
+17
to
+27
| public static Map<String, String> filterMap(Map<String, List<String>> sourceMap, List<String> searchValues, Filter.Operator filterType) | ||
| { | ||
| return sourceMap.entrySet().stream() | ||
| .filter(entry -> isMatch(entry.getValue(), searchValues, filterType)) | ||
| .collect(Collectors.toMap( | ||
| Map.Entry::getKey, | ||
| e -> e.getValue().stream().sorted().collect(Collectors.joining(", ")), | ||
| (e1, e2) -> e1, | ||
| LinkedHashMap::new | ||
| )); | ||
| } |
Member
There was a problem hiding this comment.
Avoid losing information. filterMap should return the filtered map in the same format that it was passed in, Map<String, List<String>>.
Maybe create a separate method to sort and join the values in a standard format. Something like:
public static String formatValues(List<String> values)
{
return TextUtils.normalizeSpace(values.stream().sorted().collect(Collectors.joining(", "));
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
Add sample finder test for multi choice field
Related Pull Requests
Changes