Skip to content

Commit

Permalink
Make description optional
Browse files Browse the repository at this point in the history
  • Loading branch information
XiongKezhi committed Feb 20, 2021
1 parent 88f492a commit 166c08b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ChecksAction implements Serializable {
*/
@SuppressFBWarnings("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE")
public ChecksAction(@CheckForNull final String label, @CheckForNull final String description,
@CheckForNull final String identifier) {
@CheckForNull final String identifier) {
this.label = label;
this.description = description;
this.identifier = identifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,24 @@ ChecksDetails extractChecksDetails() throws IOException, InterruptedException {
*/
public static class StepChecksAction implements Serializable {
private static final long serialVersionUID = 1L;
private final ChecksAction action;
private ChecksAction action;

/**
* Creates an instance that wraps a newly constructed {@link ChecksAction} with according parameters.
*
* @param label
* label of the action to display in the checks report on SCMs
* @param description
* description for the action
* @param identifier
* identifier for the action, useful to identify which action is requested by users
*/
@DataBoundConstructor
public StepChecksAction(final String label, final String description, final String identifier) {
action = new ChecksAction(label, description, identifier);
public StepChecksAction(final String label, final String identifier) {
action = new ChecksAction(label, StringUtils.EMPTY, identifier);
}

@DataBoundSetter
public void setDescription(final String description) {
action = new ChecksAction(getLabel(), description, getIdentifier());
}

public String getLabel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static io.jenkins.plugins.checks.assertions.Assertions.assertThat;
Expand Down Expand Up @@ -86,13 +87,16 @@ void shouldPublishCheckWithSetValues() throws IOException, InterruptedException
PublishChecksStep step = createPublishChecksStep("a failed build", ChecksStatus.IN_PROGRESS,
ChecksConclusion.FAILURE);

step.setActions(Arrays.asList(
new PublishChecksStep.StepChecksAction("label-1", "description-1", "identifier-1"),
new PublishChecksStep.StepChecksAction("label-2", "description-2", "identifier-2")));
List<PublishChecksStep.StepChecksAction> actions = Arrays.asList(
new PublishChecksStep.StepChecksAction("label-1", "identifier-1"),
new PublishChecksStep.StepChecksAction("label-2", "identifier-2"));
actions.get(1).setDescription("description-2");

step.setActions(actions);
assertThat(step.getActions().stream().map(PublishChecksStep.StepChecksAction::getLabel))
.containsExactlyInAnyOrder("label-1", "label-2");
assertThat(step.getActions().stream().map(PublishChecksStep.StepChecksAction::getDescription))
.containsExactlyInAnyOrder("description-1", "description-2");
.containsExactlyInAnyOrder(StringUtils.EMPTY, "description-2");
assertThat(step.getActions().stream().map(PublishChecksStep.StepChecksAction::getIdentifier))
.containsExactlyInAnyOrder("identifier-1", "identifier-2");

Expand All @@ -111,7 +115,7 @@ void shouldPublishCheckWithSetValues() throws IOException, InterruptedException
.withText("a failed build")
.build())
.withActions(Arrays.asList(
new ChecksAction("label-1", "description-1", "identifier-1"),
new ChecksAction("label-1", "", "identifier-1"),
new ChecksAction("label-2", "description-2", "identifier-2")))
.build());
}
Expand Down

0 comments on commit 166c08b

Please sign in to comment.