Skip to content

Commit

Permalink
Fix pipeline syntax snippet generation (#198) (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
strangelookingnerd authored Oct 7, 2024
1 parent fff99f4 commit 99986b7
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public void setColor(String color) {
}
}

/**
* @deprecated replaced by {@link #getStyle()}.
*/
@Deprecated(since = "2.0", forRemoval = true)
public String getColor() {
// translate new field to color
return StringUtils.substringBetween(getStyle(), "color: ", ";");
}

@Override
public StepExecution start(StepContext context) {
return new Execution(getId(), getIcon(), getText(), getCssClass(), getStyle(), getLink(), context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public String getFunctionName() {
public String getDisplayName() {
return "Add a HTML Badge";
}

@Override
public boolean isAdvanced() {
return true;
}
}

@Deprecated(since = "2.0", forRemoval = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public String getFunctionName() {
public String getDisplayName() {
return "Add Short Text";
}

@Override
public boolean isAdvanced() {
return true;
}
}

@Deprecated(since = "2.0", forRemoval = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public String getFunctionName() {
public String getDisplayName() {
return "Create Summary";
}

@Override
public boolean isAdvanced() {
return true;
}
}

@Deprecated(since = "2.0", forRemoval = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public String getFunctionName() {
public String getDisplayName() {
return "Remove HTML Badges";
}

@Override
public boolean isAdvanced() {
return true;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<p>
This step has been deprecated and should be replaced by <code>addBadge</code>.
</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<p>
This step has been deprecated and should be replaced by <code>addBadge</code>.
</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<p>
This step has been deprecated and should be replaced by <code>addSummary</code>.
</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<p>
This step has been deprecated and should be replaced by <code>addBadge</code> and <code>removeBadges</code>.
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ void defaultConstructor(JenkinsRule r) {
assertNull(step.getLink());
}

@Test
@Deprecated(since = "2.0", forRemoval = true)
void color(@SuppressWarnings("unused") JenkinsRule r) {
AddBadgeStep step = (AddBadgeStep) createStep("id", "icon", "text", "cssClass", null, "link");
assertNull(step.getColor());

Check warning on line 58 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: getColor() in com.jenkinsci.plugins.badge.dsl.AddBadgeStep has been deprecated and marked for removal

step.setColor("");

Check warning on line 60 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: setColor(java.lang.String) in com.jenkinsci.plugins.badge.dsl.AddBadgeStep has been deprecated and marked for removal
assertEquals("", step.getColor());

Check warning on line 61 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: getColor() in com.jenkinsci.plugins.badge.dsl.AddBadgeStep has been deprecated and marked for removal

step.setColor("style");

Check warning on line 63 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: setColor(java.lang.String) in com.jenkinsci.plugins.badge.dsl.AddBadgeStep has been deprecated and marked for removal
assertEquals("style", step.getColor());

Check warning on line 64 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: getColor() in com.jenkinsci.plugins.badge.dsl.AddBadgeStep has been deprecated and marked for removal
}

@Test
void addInScriptedPipeline(JenkinsRule r) throws Exception {
AbstractAddBadgeStep step = createStep(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.jenkinsci.plugins.badge.action.HtmlBadgeAction;
import hudson.markup.RawHtmlMarkupFormatter;
Expand Down Expand Up @@ -62,6 +63,12 @@ void html() {
assertEquals(html, step.getHtml());
}

@Test
void deprecated(@SuppressWarnings("unused") JenkinsRule r) {
AddHtmlBadgeStep step = new AddHtmlBadgeStep(null);

Check warning on line 68 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.AddHtmlBadgeStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal

Check warning on line 68 in src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.AddHtmlBadgeStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal
assertTrue(step.getDescriptor().isAdvanced());
}

@Test
void addHtmlBadge(JenkinsRule r) throws Exception {
String html = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ void text(@SuppressWarnings("unused") JenkinsRule r) {
assertEquals(text, step.getText());
}

@Test
void deprecated(@SuppressWarnings("unused") JenkinsRule r) {
CreateSummaryStep step = new CreateSummaryStep(null);

Check warning on line 78 in src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.CreateSummaryStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal

Check warning on line 78 in src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.CreateSummaryStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal
assertTrue(step.getDescriptor().isAdvanced());
}

@Test
void createSummary_plain(JenkinsRule r) throws Exception {
String text = randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.jenkinsci.plugins.badge.dsl;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import hudson.model.BuildBadgeAction;
import java.util.List;
Expand Down Expand Up @@ -63,6 +64,12 @@ void removeInvalidId(JenkinsRule r) throws Exception {
runRemoveJob(r, addStep, removeStep, 1);
}

@Test
void deprecated(@SuppressWarnings("unused") JenkinsRule r) {
RemoveHtmlBadgesStep removeStep = createRemoveStep(null);

Check warning on line 69 in src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveHtmlBadgesStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.RemoveHtmlBadgesStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal
assertTrue(removeStep.getDescriptor().isAdvanced());
}

private static void runRemoveJob(
JenkinsRule r, AddHtmlBadgeStep addStep, RemoveHtmlBadgesStep removeStep, int expected) throws Exception {
WorkflowJob project = r.jenkins.createProject(WorkflowJob.class, "project");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.jenkinsci.plugins.badge.action.BadgeAction;
import hudson.model.BuildBadgeAction;
Expand Down Expand Up @@ -97,6 +98,12 @@ void link(@SuppressWarnings("unused") JenkinsRule r) {
assertEquals("https://jenkins.io", step.getLink());
}

@Test
void deprecated(@SuppressWarnings("unused") JenkinsRule r) {
AddShortTextStep step = new AddShortTextStep(null);

Check warning on line 103 in src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.AddShortTextStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal

Check warning on line 103 in src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java

View check run for this annotation

ci.jenkins.io / Java Compiler

compiler:testCompile

NORMAL: com.jenkinsci.plugins.badge.dsl.AddShortTextStep in com.jenkinsci.plugins.badge.dsl has been deprecated and marked for removal
assertTrue(step.getDescriptor().isAdvanced());
}

@Test
void addShortText(JenkinsRule r) throws Exception {
String text = UUID.randomUUID().toString();
Expand Down

0 comments on commit 99986b7

Please sign in to comment.