Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanHealey committed Jan 12, 2023
1 parent 2d6198b commit 865c86c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public DslArg[] getParams()
private List<String> getValues(final String name)
{

if (name == null || stream(dslArgs).noneMatch(arg -> arg.getName().equals(name.toLowerCase())))
if (name == null || stream(dslArgs).noneMatch(arg -> arg.getName().equalsIgnoreCase(name)))
{
throw new IllegalArgumentException(String.format("Parameter %s does not exist in this repeating group", name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public void shouldMatchAllowedValuesCaseInsensitivelyAndReturnValuesUsingTheCase
{
final String[] args = {"a: value", "myGroup: joe", "myValue: a"};
final DslArg[] parameters = {
new RequiredArg("a"),
new RequiredArg("A"),
new RepeatingArgGroup(
new RequiredArg("myGroup").setAllowedValues("Joe", "Jenny"),
new RequiredArg("myValue").setAllowedValues("A", "B"))
Expand All @@ -640,8 +640,8 @@ public void shouldMatchAllowedValuesCaseInsensitivelyAndReturnValuesUsingTheCase
assertEquals("value", params.value("a"));
final RepeatingGroup[] groups = params.valuesAsGroup("myGroup");
assertEquals(1, groups.length);
assertEquals("Joe", groups[0].value("myGroup"));
assertEquals("A", groups[0].value("myValue"));
assertEquals("Joe", groups[0].values("myGroup")[0]);
assertEquals("A", groups[0].values("myValue")[0]);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,18 @@ void shouldThrowExceptionWhenAttemptToGetValueButContainsMultiple()

assertEquals("values() should be used when multiple values are allowed", exception.getMessage());
}

@Test
public void shouldRetrieveValueCaseWithACaseInsensitiveKey()
{
final RequiredArg requiredArg = new RequiredArg("foo");
final OptionalArg otherArg = new OptionalArg("bar");
final Map<String, List<String>> values = new HashMap<>();
values.put("foo", Collections.singletonList(""));
values.put("bar", Collections.singletonList("123"));
final RepeatingParamValues params = new RepeatingParamValues(asList(requiredArg, otherArg).toArray(new DslArg[0]), values);

assertTrue(params.hasValue("Bar"));
assertEquals("123", params.value("BAR"));
}
}

0 comments on commit 865c86c

Please sign in to comment.