From 1e1ac7e42e70c0172684d70c2c3e4306f8bc3bcb Mon Sep 17 00:00:00 2001 From: Kezhi Xiong Date: Sun, 28 Feb 2021 13:38:37 +0800 Subject: [PATCH] Support for annotations in publish checks step. (#87) * Support for annotations in publish checks step. * Test for annotations dropdown list view * Fix checkstyle warning --- .../checks/steps/PublishChecksStep.java | 191 ++++++++++++++++-- .../plugins/checks/steps/StepUtils.java | 31 +++ .../StepChecksAnnotation/config.jelly | 40 ++++ .../help-annotationLevel.html | 4 + .../StepChecksAnnotation/help-endColumn.html | 3 + .../StepChecksAnnotation/help-endLine.html | 3 + .../StepChecksAnnotation/help-message.html | 3 + .../StepChecksAnnotation/help-path.html | 3 + .../StepChecksAnnotation/help-rawDetails.html | 3 + .../help-startColumn.html | 3 + .../StepChecksAnnotation/help-startLine.html | 3 + .../StepChecksAnnotation/help-title.html | 3 + .../steps/PublishChecksStep/config.jelly | 12 ++ .../steps/PublishChecksStep/config.properties | 1 + .../checks/steps/PublishChecksStepITest.java | 27 ++- .../checks/steps/PublishChecksStepTest.java | 43 ++++ 16 files changed, 358 insertions(+), 15 deletions(-) create mode 100644 src/main/java/io/jenkins/plugins/checks/steps/StepUtils.java create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/config.jelly create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-annotationLevel.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endColumn.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endLine.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-message.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-path.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-rawDetails.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startColumn.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startLine.html create mode 100644 src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-title.html diff --git a/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java b/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java index ebea6acb..5e62ff75 100644 --- a/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java +++ b/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java @@ -8,7 +8,13 @@ import hudson.model.Run; import hudson.model.TaskListener; import hudson.util.ListBoxModel; -import io.jenkins.plugins.checks.api.*; +import io.jenkins.plugins.checks.api.ChecksAction; +import io.jenkins.plugins.checks.api.ChecksAnnotation; +import io.jenkins.plugins.checks.api.ChecksConclusion; +import io.jenkins.plugins.checks.api.ChecksDetails; +import io.jenkins.plugins.checks.api.ChecksOutput; +import io.jenkins.plugins.checks.api.ChecksPublisherFactory; +import io.jenkins.plugins.checks.api.ChecksStatus; import org.apache.commons.lang3.StringUtils; import org.jenkinsci.plugins.workflow.steps.*; import org.kohsuke.stapler.DataBoundConstructor; @@ -34,6 +40,7 @@ public class PublishChecksStep extends Step implements Serializable { private ChecksStatus status = ChecksStatus.COMPLETED; private ChecksConclusion conclusion = ChecksConclusion.SUCCESS; private List actions = Collections.emptyList(); + private List annotations = Collections.emptyList(); /** * Constructor used for pipeline by Stapler. @@ -94,6 +101,11 @@ public void setActions(final List actions) { this.actions = actions; } + @DataBoundSetter + public void setAnnotations(final List annotations) { + this.annotations = annotations; + } + public String getName() { return name; } @@ -126,6 +138,10 @@ public List getActions() { return actions; } + public List getAnnotations() { + return annotations; + } + @Override public StepExecution start(final StepContext stepContext) { return new PublishChecksStepExecution(stepContext, this); @@ -136,6 +152,8 @@ public StepExecution start(final StepContext stepContext) { */ @Extension public static class PublishChecksStepDescriptor extends StepDescriptor { + private final StepUtils utils = new StepUtils(); + @Override public String getFunctionName() { return "publishChecks"; @@ -158,7 +176,7 @@ public String getDisplayName() { * @return a model with all {@link ChecksStatus}es. */ public ListBoxModel doFillStatusItems() { - return asListBoxModel(ChecksStatus.values()); + return utils.asListBoxModel(ChecksStatus.values()); } /** @@ -167,18 +185,7 @@ public ListBoxModel doFillStatusItems() { * @return a model with all {@link ChecksConclusion}s. */ public ListBoxModel doFillConclusionItems() { - return asListBoxModel(ChecksConclusion.values()); - } - - private ListBoxModel asListBoxModel(final Enum... enums) { - return Arrays.stream(enums) - .map(Enum::name) - .map(name -> new ListBoxModel.Option(asDisplayName(name), name)) - .collect(Collectors.toCollection(ListBoxModel::new)); - } - - private String asDisplayName(final String name) { - return StringUtils.capitalize(name.toLowerCase(Locale.ENGLISH).replace("_", " ")); + return utils.asListBoxModel(ChecksConclusion.values()); } } @@ -220,6 +227,9 @@ ChecksDetails extractChecksDetails() throws IOException, InterruptedException { .withTitle(step.getTitle()) .withSummary(step.getSummary()) .withText(step.getText()) + .withAnnotations(step.getAnnotations().stream() + .map(StepChecksAnnotation::getAnnotation) + .collect(Collectors.toList())) .build()) .withActions(step.getActions().stream() .map(StepChecksAction::getAction) @@ -228,6 +238,159 @@ ChecksDetails extractChecksDetails() throws IOException, InterruptedException { } } + /** + * A simple wrapper for {@link ChecksAnnotation} to allow users add code annotations by {@link PublishChecksStep}. + */ + public static class StepChecksAnnotation extends AbstractDescribableImpl + implements Serializable { + private static final long serialVersionUID = 1L; + + private final String path; + private final int startLine; + private final int endLine; + private final String message; + + private Integer startColumn; + private Integer endColumn; + private String title; + private String rawDetails; + + private ChecksAnnotation.ChecksAnnotationLevel annotationLevel = ChecksAnnotation.ChecksAnnotationLevel.WARNING; + + /** + * Creates an annotation with required parameters. + * + * @param path + * path of the file to annotate + * @param startLine + * start line of the annotation + * @param endLine + * end line of the annotation + * @param message + * annotation message + */ + @DataBoundConstructor + public StepChecksAnnotation(final String path, final int startLine, final int endLine, final String message) { + super(); + + this.path = path; + this.startLine = startLine; + this.endLine = endLine; + this.message = message; + } + + @DataBoundSetter + public void setStartColumn(final Integer startColumn) { + this.startColumn = startColumn; + } + + @DataBoundSetter + public void setEndColumn(final Integer endColumn) { + this.endColumn = endColumn; + } + + @DataBoundSetter + public void setTitle(final String title) { + this.title = title; + } + + @DataBoundSetter + public void setRawDetails(final String rawDetails) { + this.rawDetails = rawDetails; + } + + @DataBoundSetter + public void setAnnotationLevel(final ChecksAnnotation.ChecksAnnotationLevel annotationLevel) { + this.annotationLevel = annotationLevel; + } + + public String getPath() { + return path; + } + + public int getStartLine() { + return startLine; + } + + public int getEndLine() { + return endLine; + } + + public String getMessage() { + return message; + } + + public Integer getStartColumn() { + return startColumn; + } + + public Integer getEndColumn() { + return endColumn; + } + + public String getTitle() { + return title; + } + + public String getRawDetails() { + return rawDetails; + } + + public ChecksAnnotation.ChecksAnnotationLevel getAnnotationLevel() { + return annotationLevel; + } + + /** + * Get {@link ChecksAnnotation} built with user-provided parameters in {@link PublishChecksStep}. + * + * @return the annotation built with provided parameters + */ + public ChecksAnnotation getAnnotation() { + ChecksAnnotation.ChecksAnnotationBuilder builder = new ChecksAnnotation.ChecksAnnotationBuilder() + .withPath(path) + .withStartLine(startLine) + .withEndLine(endLine) + .withMessage(message) + .withAnnotationLevel(annotationLevel); + + if (startColumn != null) { + builder.withStartColumn(startColumn); + } + if (endColumn != null) { + builder.withEndColumn(endColumn); + } + if (title != null) { + builder.withTitle(title); + } + if (rawDetails != null) { + builder.withRawDetails(rawDetails); + } + + return builder.build(); + } + + /** + * Descriptor for {@link StepChecksAnnotation}, required for Pipeline Snippet Generator. + */ + @Extension + public static class StepChecksAnnotationDescriptor extends Descriptor { + private final StepUtils utils = new StepUtils(); + + /** + * Fill the dropdown list model with all {@link io.jenkins.plugins.checks.api.ChecksAnnotation.ChecksAnnotationLevel} + * values. + * + * @return a model with all {@link io.jenkins.plugins.checks.api.ChecksAnnotation.ChecksAnnotationLevel} values. + */ + public ListBoxModel doFillAnnotationLevelItems() { + return utils.asListBoxModel( + Arrays.stream(ChecksAnnotation.ChecksAnnotationLevel.values()) + .filter(v -> v != ChecksAnnotation.ChecksAnnotationLevel.NONE) + .toArray(Enum[]::new)); + } + } + } + /** * A simple wrapper for {@link ChecksAction} to allow users add checks actions by {@link PublishChecksStep}. */ diff --git a/src/main/java/io/jenkins/plugins/checks/steps/StepUtils.java b/src/main/java/io/jenkins/plugins/checks/steps/StepUtils.java new file mode 100644 index 00000000..5da5307b --- /dev/null +++ b/src/main/java/io/jenkins/plugins/checks/steps/StepUtils.java @@ -0,0 +1,31 @@ +package io.jenkins.plugins.checks.steps; + +import hudson.util.ListBoxModel; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.Locale; +import java.util.stream.Collectors; + +/** + * Utilities for pipeline steps. + */ +public class StepUtils { + /** + * Converts an {@link Enum} into a {@link ListBoxModel} with all values of it. + * + * @param enums + * all candidate values of the enum + * @return the list box model with all enum values. + */ + public ListBoxModel asListBoxModel(final Enum... enums) { + return Arrays.stream(enums) + .map(Enum::name) + .map(name -> new ListBoxModel.Option(asDisplayName(name), name)) + .collect(Collectors.toCollection(ListBoxModel::new)); + } + + private String asDisplayName(final String name) { + return StringUtils.capitalize(name.toLowerCase(Locale.ENGLISH).replace("_", " ")); + } +} diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/config.jelly b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/config.jelly new file mode 100644 index 00000000..983693d6 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/config.jelly @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-annotationLevel.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-annotationLevel.html new file mode 100644 index 00000000..a84df89e --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-annotationLevel.html @@ -0,0 +1,4 @@ +
+ Severity level of the annotation, can be one of can be "NOTICE", "WARNING", or "FAILURE"; by default, "WARNING" will + be used. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endColumn.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endColumn.html new file mode 100644 index 00000000..980cc696 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endColumn.html @@ -0,0 +1,3 @@ +
+ End column of code to be annotated. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endLine.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endLine.html new file mode 100644 index 00000000..2ad422f3 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-endLine.html @@ -0,0 +1,3 @@ +
+ End line of code to be annotated. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-message.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-message.html new file mode 100644 index 00000000..7d154942 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-message.html @@ -0,0 +1,3 @@ +
+ A digest message of the annotation. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-path.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-path.html new file mode 100644 index 00000000..3606173c --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-path.html @@ -0,0 +1,3 @@ +
+ Path to the file to be annotated, started from the project root directory. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-rawDetails.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-rawDetails.html new file mode 100644 index 00000000..026f4038 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-rawDetails.html @@ -0,0 +1,3 @@ +
+ Raw details of the annotation. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startColumn.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startColumn.html new file mode 100644 index 00000000..04fcac79 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startColumn.html @@ -0,0 +1,3 @@ +
+ Start column of code to be annotated. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startLine.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startLine.html new file mode 100644 index 00000000..30fed5ec --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-startLine.html @@ -0,0 +1,3 @@ +
+ Start line of code to be annotated. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-title.html b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-title.html new file mode 100644 index 00000000..6d2d62c3 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/StepChecksAnnotation/help-title.html @@ -0,0 +1,3 @@ +
+ Title of the annotation. +
diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.jelly b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.jelly index bfaa7346..dd34e889 100644 --- a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.jelly +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.jelly @@ -41,4 +41,16 @@ + +
+ + +
+ +
+
+
+
+
+ diff --git a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.properties b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.properties index 741e2164..f3bf40c6 100644 --- a/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.properties +++ b/src/main/resources/io/jenkins/plugins/checks/steps/PublishChecksStep/config.properties @@ -6,3 +6,4 @@ title.detailsURL=Details URL title.status=Status title.conclusion=Conclusion title.actions=Actions +title.annotations=Annotations \ No newline at end of file diff --git a/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepITest.java b/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepITest.java index 75f2505d..7431de6d 100644 --- a/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepITest.java +++ b/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepITest.java @@ -1,6 +1,7 @@ package io.jenkins.plugins.checks.steps; import io.jenkins.plugins.checks.api.ChecksAction; +import io.jenkins.plugins.checks.api.ChecksAnnotation; import io.jenkins.plugins.checks.api.ChecksConclusion; import io.jenkins.plugins.checks.api.ChecksDetails; import io.jenkins.plugins.checks.api.ChecksOutput; @@ -38,7 +39,12 @@ public void shouldPublishChecksWhenUsingPipeline() throws IOException { job.setDefinition(asStage("publishChecks name: 'customized-check', " + "summary: 'customized check created in pipeline', title: 'Publish Checks Step', " + "text: 'Pipeline support for checks', status: 'IN_PROGRESS', conclusion: 'NONE', " - + "actions: [[label:'test-label', description:'test-desc', identifier:'test-id']]")); + + "actions: [[label:'test-label', description:'test-desc', identifier:'test-id']], " + + "annotations: [" + + " [path:'Jenkinsfile', startLine:1, endLine:1, message:'test with only required params'], " + + " [path:'Jenkinsfile', startLine:2, endLine:2, message:'test with all params', " + + " annotationLevel:'NOTICE', startColumn:0, endColumn:10, title:'integration test', " + + " rawDetails:'raw details']]")); assertThat(JenkinsRule.getLog(buildSuccessfully(job))) .contains("[Pipeline] publishChecks"); @@ -58,5 +64,24 @@ public void shouldPublishChecksWhenUsingPipeline() throws IOException { assertThat(output.getTitle()).isPresent().get().isEqualTo("Publish Checks Step"); assertThat(output.getSummary()).isPresent().get().isEqualTo("customized check created in pipeline"); assertThat(output.getText()).isPresent().get().isEqualTo("Pipeline support for checks"); + assertThat(output.getChecksAnnotations()).usingFieldByFieldElementComparator().containsExactlyInAnyOrder( + new ChecksAnnotation.ChecksAnnotationBuilder() + .withPath("Jenkinsfile") + .withStartLine(1) + .withEndLine(1) + .withAnnotationLevel(ChecksAnnotation.ChecksAnnotationLevel.WARNING) + .withMessage("test with only required params") + .build(), + new ChecksAnnotation.ChecksAnnotationBuilder() + .withPath("Jenkinsfile") + .withStartLine(2) + .withEndLine(2) + .withAnnotationLevel(ChecksAnnotation.ChecksAnnotationLevel.NOTICE) + .withMessage("test with all params") + .withStartColumn(0) + .withEndColumn(10) + .withTitle("integration test") + .withRawDetails("raw details") + .build()); } } diff --git a/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepTest.java b/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepTest.java index f9284282..5f3f4dea 100644 --- a/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepTest.java +++ b/src/test/java/io/jenkins/plugins/checks/steps/PublishChecksStepTest.java @@ -2,7 +2,9 @@ import hudson.model.Run; import hudson.model.TaskListener; +import hudson.util.ListBoxModel; import io.jenkins.plugins.checks.api.ChecksAction; +import io.jenkins.plugins.checks.api.ChecksAnnotation; import io.jenkins.plugins.checks.api.ChecksConclusion; import io.jenkins.plugins.checks.api.ChecksDetails; import io.jenkins.plugins.checks.api.ChecksOutput; @@ -16,6 +18,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; import static io.jenkins.plugins.checks.assertions.Assertions.assertThat; @@ -104,6 +107,16 @@ void shouldPublishCheckWithSetValues() throws IOException, InterruptedException assertThat(step.getActions().stream().map(PublishChecksStep.StepChecksAction::getIdentifier)) .containsExactlyInAnyOrder("identifier-1", "identifier-2"); + List annotations = Arrays.asList( + new PublishChecksStep.StepChecksAnnotation("Jenkinsfile", 1, 1, "required params"), + new PublishChecksStep.StepChecksAnnotation("Jenkinsfile", 2, 2, "full params")); + annotations.get(1).setStartColumn(0); + annotations.get(1).setEndColumn(10); + annotations.get(1).setTitle("unit test"); + annotations.get(1).setRawDetails("raw details"); + annotations.get(1).setAnnotationLevel(ChecksAnnotation.ChecksAnnotationLevel.FAILURE); + step.setAnnotations(annotations); + StepExecution execution = step.start(createStepContext()); assertThat(execution).isInstanceOf(PublishChecksStep.PublishChecksStepExecution.class); assertThat(((PublishChecksStep.PublishChecksStepExecution)execution).extractChecksDetails()) @@ -117,6 +130,25 @@ void shouldPublishCheckWithSetValues() throws IOException, InterruptedException .withTitle("Jenkins Build") .withSummary("a check made by Jenkins") .withText("a failed build") + .withAnnotations(Arrays.asList( + new ChecksAnnotation.ChecksAnnotationBuilder() + .withPath("Jenkinsfile") + .withStartLine(1) + .withEndLine(1) + .withAnnotationLevel(ChecksAnnotation.ChecksAnnotationLevel.WARNING) + .withMessage("required params") + .build(), + new ChecksAnnotation.ChecksAnnotationBuilder() + .withPath("Jenkinsfile") + .withStartLine(2) + .withEndLine(2) + .withAnnotationLevel(ChecksAnnotation.ChecksAnnotationLevel.FAILURE) + .withMessage("full params") + .withStartColumn(0) + .withEndColumn(10) + .withTitle("unit test") + .withRawDetails("raw details") + .build())) .build()) .withActions(Arrays.asList( new ChecksAction("label-1", "", "identifier-1"), @@ -132,6 +164,17 @@ void shouldDefinePublishChecksStepDescriptorCorrectly() { assertThat(descriptor.getRequiredContext().toArray()).containsExactlyInAnyOrder(Run.class, TaskListener.class); } + @Test + void shouldFillStepChecksAnnotationDropdownListCorrectly() { + PublishChecksStep.StepChecksAnnotation.StepChecksAnnotationDescriptor descriptor = + new PublishChecksStep.StepChecksAnnotation.StepChecksAnnotationDescriptor(); + + assertThat(descriptor.doFillAnnotationLevelItems().stream() + .map(option -> option.name) + .collect(Collectors.toList())) + .containsExactlyInAnyOrder("Notice", "Warning", "Failure"); + } + private StepContext createStepContext() throws IOException, InterruptedException { StepContext context = mock(StepContext.class); when(context.get(Run.class)).thenReturn(mock(Run.class));