Skip to content

Commit

Permalink
Merge pull request #91 from jenkinsci/warn-unmatched
Browse files Browse the repository at this point in the history
Warn on parameters without values
  • Loading branch information
res0nance authored Dec 28, 2020
2 parents 72bc311 + 86c9c9b commit 7417eb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public String checkSanity(String cronTabSpec, ParametersDefinitionProperty param
if (!parsedKeySet.isEmpty()) {
return Messages.ParameterizedTimerTrigger_UndefinedParameter(parsedKeySet, parameterDefinitionNames);
}
List<String> emptyParameters = parsedParameters.keySet().stream().filter(k -> parsedParameters.get(k).isEmpty()).collect(Collectors.toList());
if (!emptyParameters.isEmpty()) {
return Messages.ParameterizedTimerTrigger_EmptyParameter(emptyParameters);
}
} catch (IllegalArgumentException e) {
return e.getMessage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ ParameterizedTimerTrigger.MissingWhitespace=You appear to be missing whitespace
ParameterizedTimerTrigger.MoreThanOnePercent=You can only use one percent sign to separate the cron from the parameters.
ParameterizedTimerTrigger.TrailingSemicolon=I need you to remove that semicolon from the end of the line.
ParameterizedTimerTrigger.UndefinedParameter=You have tried to schedule with parameters ({0}), which are not among saved project parameters: {1}
ParameterizedTimerTrigger.EmptyParameter=You have tried to schedule with empty values for parameters ({0}), is this intentional?
ParameterizedTimerTrigger.TimerTriggerCause.ShortDescription=Started by timer with parameters: {0}
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public void checkSanity_UnmatchedEquals() throws Exception {
ParameterParser testObject = new ParameterParser();
Mockito.when(mockParametersDefinitionProperty.getParameterDefinitionNames()).thenReturn(
Arrays.asList("name", "name2"));
// TODO: Warn on missing value
assertNull(testObject.checkSanity("* * * * *%name=value;name2=", mockParametersDefinitionProperty));
assertEquals(Messages.ParameterizedTimerTrigger_EmptyParameter(Collections.singletonList("name2")),
testObject.checkSanity("* * * * *%name=value;name2=", mockParametersDefinitionProperty));
}

@Test
Expand Down

0 comments on commit 7417eb4

Please sign in to comment.