Skip to content

Add sample finder test for multi choice field#2903

Merged
DariaBod merged 13 commits intodevelopfrom
fb_multiChoiceSampleFinder
Mar 16, 2026
Merged

Add sample finder test for multi choice field#2903
DariaBod merged 13 commits 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(", "));
}

@DariaBod DariaBod requested a review from labkey-tchad March 13, 2026 18:46
Comment on lines +505 to +508
for (int i = 0; i < size; i++)
{
textChoices.add(randomString(randomInt(1, 25)));
}
Copy link
Member

Choose a reason for hiding this comment

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

This should trim the generated values and ensure that there aren't any duplicate or blank values.

Comment on lines +80 to +88
// waitForElement(elementCache().findCheckbox(values[0]));
// waitFor(() -> elementCache().findCheckbox(values[0]).isDisplayed(), 10000);
for (String value : values)
{
elementCache().findCheckbox(value).check();
try{
elementCache().findCheckbox(value).check();}
catch (Exception e){
elementCache().findCheckbox(value).check();
}
Copy link
Member

Choose a reason for hiding this comment

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

Consider making ElementCache.findCheckbox wait for the checkbox instead of attempting to find it twice here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method should be the same as it was. Used this for debugging and forgot to delete it, my bad

Copy link
Member

@labkey-tchad labkey-tchad left a comment

Choose a reason for hiding this comment

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

A couple more requests

Comment on lines +52 to +56
.sorted(Comparator
.comparing((String s) -> s.substring(0, 1).toLowerCase())
.thenComparing(s -> s.substring(0, 1))
.thenComparing(s -> s))
.collect(Collectors.toList()),
Copy link
Member

Choose a reason for hiding this comment

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

Add some documentation explaining this special sorting.

DariaBod and others added 2 commits March 16, 2026 11:43
comment fix

Co-authored-by: Trey Chadick <tchad@labkey.com>
{
textChoices.add(randomString(randomInt(1, 25)));
}
return textChoices;
Copy link
Member

Choose a reason for hiding this comment

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

This is likely to be used to generate Lists that shouldn't be changed. Use Collections.unmodifiableList to prevent modification.

Suggested change
return textChoices;
return Collections.unmodifiableList(textChoices);

@DariaBod DariaBod merged commit 3c447fe into develop Mar 16, 2026
5 checks passed
@DariaBod DariaBod deleted the fb_multiChoiceSampleFinder branch March 16, 2026 19:18
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