Skip to content

Commit

Permalink
Remove @Override.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Nov 14, 2023
1 parent de9cee8 commit bc7d2f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ public FormValidation doCheckName(@AncestorInPath final BuildableItem project,
return FormValidation.ok();
}

return doCheckName(name);
}

@VisibleForTesting
FormValidation doCheckName(final String name) {
if (StringUtils.isBlank(name)) {
return FormValidation.error(Messages.GroovyParser_Error_Name_isEmpty());
}
Expand All @@ -303,6 +308,11 @@ public FormValidation doCheckRegexp(@AncestorInPath final BuildableItem project,
return FormValidation.ok();
}

return doCheckRegexp(regexp);
}

@VisibleForTesting
FormValidation doCheckRegexp(final String regexp) {
try {
if (StringUtils.isBlank(regexp)) {
return FormValidation.error(Messages.GroovyParser_Error_Regexp_isEmpty());
Expand Down Expand Up @@ -337,6 +347,11 @@ public FormValidation doCheckScript(@AncestorInPath final BuildableItem project,
if (!jenkinsFacade.hasPermission(Jenkins.ADMINISTER)) {
return NO_RUN_SCRIPT_PERMISSION_WARNING;
}
return doCheckScript(script);
}

@VisibleForTesting
FormValidation doCheckScript(final String script) {
try {
if (StringUtils.isBlank(script)) {
return FormValidation.error(Messages.GroovyParser_Error_Script_isEmpty());
Expand Down Expand Up @@ -378,6 +393,11 @@ public FormValidation doCheckExample(@AncestorInPath final BuildableItem project
if (!jenkinsFacade.hasPermission(Jenkins.ADMINISTER)) {
return NO_RUN_SCRIPT_PERMISSION_WARNING;
}
return doCheckExample(example, regexp, script);
}

@VisibleForTesting
FormValidation doCheckExample(final String example, final String regexp, final String script) {
if (StringUtils.isNotBlank(example) && StringUtils.isNotBlank(regexp) && StringUtils.isNotBlank(script)) {
FormValidation response = parseExample(script, example, regexp, containsNewline(regexp));
if (example.length() <= MAX_EXAMPLE_SIZE) {
Expand Down Expand Up @@ -420,7 +440,7 @@ private FormValidation parseExample(final String script, final String example, f
if (matcher.find()) {
GroovyExpressionMatcher checker = new GroovyExpressionMatcher(script);
Object result = checker.run(matcher, new IssueBuilder(), 0, "UI Example");
Optional<?> optional = (Optional) result;
Optional<?> optional = (Optional<?>) result;
if (optional.isPresent()) {
Object wrappedIssue = optional.get();
if (wrappedIssue instanceof Issue) {
Expand All @@ -433,7 +453,7 @@ private FormValidation parseExample(final String script, final String example, f
return FormValidation.error(Messages.GroovyParser_Error_Example_regexpDoesNotMatch());
}
}
catch (Exception exception) { // catch all exceptions of the Groovy script
catch (Exception exception) { // catch all exceptions thrown by the Groovy script
return FormValidation.error(
Messages.GroovyParser_Error_Example_exception(exception.getMessage()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ void shouldPopulateListOfParsers() {

Descriptor descriptor = new Descriptor(jenkins);
assertThat(descriptor.getId()).isEqualTo(Descriptor.ANALYSIS_MODEL_ID);
assertThat(descriptor.doFillAnalysisModelIdItems(job)).extracting(o -> o.value).first().isEqualTo("acu-cobol");
assertThat(descriptor.doFillAnalysisModelIdItems()).extracting(o -> o.value).first().isEqualTo("acu-cobol");

when(jenkins.hasPermission(Item.CONFIGURE, job)).thenReturn(false);
assertThat(descriptor.doFillAnalysisModelIdItems(job)).isEmpty();
assertThat(descriptor.doFillAnalysisModelIdItems()).isEmpty();
}
}
}

0 comments on commit bc7d2f5

Please sign in to comment.