Skip to content

Add sample finder test for multi choice field#2903

Open
DariaBod wants to merge 1 commit intodevelopfrom
fb_multiChoiceSampleFinder
Open

Add sample finder test for multi choice field#2903
DariaBod wants to merge 1 commit intodevelopfrom
fb_multiChoiceSampleFinder

Conversation

@DariaBod
Copy link
Contributor

@DariaBod DariaBod commented Mar 3, 2026

Rationale

Add sample finder test for multi choice field

Related Pull Requests

Changes

  • create TestArrayDataUtils to move duplicated methods for multi choice

create TestArrayDataUtils to move duplicated methods for multi choice
simplify verifyFilter method in SMSourceTypeMultiChoiceTest
Comment on lines +10 to +11
public class TestArrayDataUtils
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
));
}
Copy link
Member

@labkey-tchad labkey-tchad Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(", "));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants