target);
+
+ String getName();
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/Card.java b/src/main/java/jenkins/plugins/office365connector/model/Card.java
index 8cfd9ab1..d49456cf 100644
--- a/src/main/java/jenkins/plugins/office365connector/model/Card.java
+++ b/src/main/java/jenkins/plugins/office365connector/model/Card.java
@@ -1,61 +1,18 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
package jenkins.plugins.office365connector.model;
-import java.util.Arrays;
import java.util.List;
-/**
- * @author srhebbar
- */
-public class Card {
-
- private String summary;
- private String themeColor = "3479BF";
-
- // even plugin needs only single 'section' connector API expects arrays
- private List sections;
-
- private List potentialAction;
-
- public Card(String summary, Section section) {
- this.summary = summary;
- this.sections = Arrays.asList(section);
- }
+public interface Card {
- public String getSummary() {
- return summary;
- }
+ public Object toPaylod();
- public List getSections() {
- return this.sections;
- }
+ void setAction(List actions);
- public void setThemeColor(String themeColor) {
- this.themeColor = themeColor;
- }
+ void setThemeColor(String cardThemeColor);
- public String getThemeColor() {
- return themeColor;
- }
+ String getSummary();
- public void setPotentialAction(List potentialActions) {
- this.potentialAction = potentialActions;
- }
+ List getSections();
- public List getPotentialAction() {
- return this.potentialAction;
- }
+ String getThemeColor();
}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCard.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCard.java
new file mode 100644
index 00000000..77967356
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCard.java
@@ -0,0 +1,105 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import hudson.model.Result;
+import jenkins.plugins.office365connector.model.Action;
+import jenkins.plugins.office365connector.model.Card;
+import jenkins.plugins.office365connector.model.Section;
+
+public class AdaptiveCard implements Card {
+
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private String type = "AdaptiveCard";
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ @SerializedName("$schema")
+ private final String schema = "http://adaptivecards.io/schemas/adaptive-card.json";
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private final String version = "1.4";
+ @SerializedName("msTeams")
+ private final MsTeams msteams = new MsTeams();
+ private final List body;
+ private List actions;
+
+ public AdaptiveCard(final String summary, final Section section, Result result) {
+ this.body = new ArrayList<>();
+ this.body.add(new TextBlock(summary, "large", "bolder", color(result)));
+ if (section != null) {
+ this.body.add(new ColumnSet(List.of(new Column(List.of(
+ new TextBlock(section.getActivityTitle(), "default", "bolder"),
+ new TextBlock(section.getActivitySubtitle())
+ )))));
+ if (!section.getFacts().isEmpty()) {
+ this.body.add(new FactSet(section.getFacts()));
+ }
+ }
+ }
+
+ private String color(final Result result) {
+ if (result.equals(Result.SUCCESS)) {
+ return "good";
+ } else if (result.equals(Result.UNSTABLE)) {
+ return "warning";
+ } else if (result.equals(Result.FAILURE)) {
+ return "attention";
+ }
+ return "default";
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public MsTeams getMsteams() {
+ return msteams;
+ }
+
+ public List getBody() {
+ return body;
+ }
+
+ public List getActions() {
+ return actions;
+ }
+
+ @Override
+ public Object toPaylod() {
+ return new Payload(this);
+ }
+
+ @Override
+ public void setAction(final List actions) {
+ this.actions = actions;
+ }
+
+ @Override
+ public void setThemeColor(final String cardThemeColor) {
+
+ }
+
+ @Override
+ public String getSummary() {
+ return null;
+ }
+
+ @Override
+ public List getSections() {
+ return List.of();
+ }
+
+ @Override
+ public String getThemeColor() {
+ return null;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardAction.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardAction.java
new file mode 100644
index 00000000..32fd4a12
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardAction.java
@@ -0,0 +1,56 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import java.util.List;
+
+public class AdaptiveCardAction implements jenkins.plugins.office365connector.model.Action {
+
+ private String type = "Action.OpenUrl";
+
+ private String title;
+
+ private String url;
+
+ public AdaptiveCardAction(String title, String url) {
+ this.title = title;
+ this.url = url;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(final String url) {
+ this.url = url;
+ }
+
+ @Override
+ public void setName(final String name) {
+ setTitle(name);
+ }
+
+ @Override
+ public void setTarget(final List target) {
+ target.stream().findFirst().ifPresent(this::setUrl);
+ }
+
+ @Override
+ public String getName() {
+ return getTitle();
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardElement.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardElement.java
new file mode 100644
index 00000000..b95c0d92
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardElement.java
@@ -0,0 +1,5 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+public interface AdaptiveCardElement {
+ String getType();
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardFact.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardFact.java
new file mode 100644
index 00000000..27456fb5
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/AdaptiveCardFact.java
@@ -0,0 +1,19 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+public class AdaptiveCardFact {
+ private final String title;
+ private final String value;
+
+ public AdaptiveCardFact(final String title, final String value) {
+ this.title = title;
+ this.value = value;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Attachment.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Attachment.java
new file mode 100644
index 00000000..f44d655e
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Attachment.java
@@ -0,0 +1,23 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+public class Attachment {
+
+ private String contentType = "application/vnd.microsoft.card.adaptive";
+ private final AdaptiveCard content;
+
+ public Attachment(final AdaptiveCard content) {
+ this.content = content;
+ }
+
+ public void setContentType(final String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public AdaptiveCard getContent() {
+ return content;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Column.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Column.java
new file mode 100644
index 00000000..73dfa0b0
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Column.java
@@ -0,0 +1,25 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import java.util.List;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class Column implements AdaptiveCardElement {
+
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private final String type = "Column";
+ private final List items;
+
+ public Column(final List items) {
+ this.items = items;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ public List getItems() {
+ return items;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/ColumnSet.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/ColumnSet.java
new file mode 100644
index 00000000..bf511160
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/ColumnSet.java
@@ -0,0 +1,31 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import java.util.List;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class ColumnSet implements AdaptiveCardElement {
+
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private final String type = "ColumnSet";
+ private final List columns;
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private final String witdth = "stretch";
+
+ public ColumnSet(final List items) {
+ this.columns = items;
+ }
+
+ public String getWitdth() {
+ return witdth;
+ }
+
+ public List getColumns() {
+ return columns;
+ }
+
+ @Override
+ public String getType() {
+ return "";
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/FactSet.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/FactSet.java
new file mode 100644
index 00000000..f01a45c8
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/FactSet.java
@@ -0,0 +1,27 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import jenkins.plugins.office365connector.model.Fact;
+
+public class FactSet implements AdaptiveCardElement {
+
+ private final List facts;
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private final String type = "FactSet";
+
+ public FactSet(List facts) {
+ this.facts = facts.stream().map(f -> new AdaptiveCardFact(f.getName(),f.getValue())).collect(Collectors.toList());
+ }
+
+ public List getFacts() {
+ return facts;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/MsTeams.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/MsTeams.java
new file mode 100644
index 00000000..ad23a908
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/MsTeams.java
@@ -0,0 +1,13 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class MsTeams {
+
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private String width = "Full";
+
+ public String getWidth() {
+ return width;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Payload.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Payload.java
new file mode 100644
index 00000000..22955770
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/Payload.java
@@ -0,0 +1,25 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class Payload {
+
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private String type = "message";
+ private final List attachments = new ArrayList<>();
+
+ public Payload(AdaptiveCard adaptiveCard) {
+ attachments.add(new Attachment(adaptiveCard));
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public List getAttachments() {
+ return attachments;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/TextBlock.java b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/TextBlock.java
new file mode 100644
index 00000000..85205fcb
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/adaptivecard/TextBlock.java
@@ -0,0 +1,54 @@
+package jenkins.plugins.office365connector.model.adaptivecard;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class TextBlock implements AdaptiveCardElement {
+
+ private String text;
+ private String weight;
+ private String size;
+ private String color;
+ @SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
+ private String type = "TextBlock";
+ private boolean wrap;
+
+ public TextBlock(final String text) {
+ this(text,"default", "default");
+ }
+
+ public TextBlock(final String text, final String size, final String weight) {
+ this(text, size,weight,"default");
+ }
+
+ public TextBlock(final String text, final String size, final String weight, final String color) {
+ this.text = text;
+ this.wrap = true;
+ this.size = size;
+ this.weight = weight;
+ this.color = color;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public boolean isWrap() {
+ return wrap;
+ }
+
+ public String getWeight() {
+ return weight;
+ }
+
+ public String getSize() {
+ return size;
+ }
+
+ public String getColor() {
+ return color;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/messagecard/MessageCard.java b/src/main/java/jenkins/plugins/office365connector/model/messagecard/MessageCard.java
new file mode 100644
index 00000000..baa7d2d8
--- /dev/null
+++ b/src/main/java/jenkins/plugins/office365connector/model/messagecard/MessageCard.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jenkins.plugins.office365connector.model.messagecard;
+
+import java.util.Arrays;
+import java.util.List;
+
+import jenkins.plugins.office365connector.model.Action;
+import jenkins.plugins.office365connector.model.Card;
+import jenkins.plugins.office365connector.model.Section;
+
+/**
+ * @author srhebbar
+ */
+public class MessageCard implements Card {
+
+ private String summary;
+ private String themeColor = "3479BF";
+
+ // even plugin needs only single 'section' connector API expects arrays
+ private List sections;
+
+ private List potentialAction;
+
+ public MessageCard(String summary, Section section) {
+ this.summary = summary;
+ this.sections = Arrays.asList(section);
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public List getSections() {
+ return this.sections;
+ }
+
+ public void setThemeColor(String themeColor) {
+ this.themeColor = themeColor;
+ }
+
+ public String getThemeColor() {
+ return themeColor;
+ }
+
+ public void setAction(List potentialActions) {
+ this.potentialAction = potentialActions;
+ }
+
+ public List getAction() {
+ return this.potentialAction;
+ }
+
+ @Override
+ public Object toPaylod() {
+ return this;
+ }
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/model/PotentialAction.java b/src/main/java/jenkins/plugins/office365connector/model/messagecard/PotentialAction.java
similarity index 89%
rename from src/main/java/jenkins/plugins/office365connector/model/PotentialAction.java
rename to src/main/java/jenkins/plugins/office365connector/model/messagecard/PotentialAction.java
index e6435efc..4f6ee59b 100644
--- a/src/main/java/jenkins/plugins/office365connector/model/PotentialAction.java
+++ b/src/main/java/jenkins/plugins/office365connector/model/messagecard/PotentialAction.java
@@ -10,18 +10,19 @@
* limitations under the License.
*/
-package jenkins.plugins.office365connector.model;
+package jenkins.plugins.office365connector.model.messagecard;
import java.util.Collections;
import java.util.List;
import com.google.gson.annotations.SerializedName;
import hudson.Util;
+import jenkins.plugins.office365connector.model.Action;
/**
* @author srhebbar
*/
-public class PotentialAction {
+public class PotentialAction implements Action {
@SerializedName("@context")
private String context = "http://schema.org";
@@ -42,10 +43,12 @@ public PotentialAction(String name, List url) {
this.target = Util.fixNull(url);
}
+ @Override
public String getName() {
return name;
}
+ @Override
public void setName(String name) {
this.name = name;
}
@@ -54,6 +57,7 @@ public List getTarget() {
return target;
}
+ @Override
public void setTarget(List target) {
this.target = target;
}
diff --git a/src/main/java/jenkins/plugins/office365connector/workflow/Execution.java b/src/main/java/jenkins/plugins/office365connector/workflow/Execution.java
index f533ffc3..b80cce4e 100644
--- a/src/main/java/jenkins/plugins/office365connector/workflow/Execution.java
+++ b/src/main/java/jenkins/plugins/office365connector/workflow/Execution.java
@@ -21,7 +21,7 @@ public class Execution extends SynchronousNonBlockingStepExecution {
public Execution(Office365ConnectorSendStep step, StepContext context) {
super(context);
stepParameters = new StepParameters(
- step.getMessage(), step.getWebhookUrl(), step.getStatus(), step.getFactDefinitions(), step.getColor());
+ step.getMessage(), step.getWebhookUrl(), step.getStatus(), step.getFactDefinitions(), step.getColor(), step.isAdaptiveCards());
}
@Override
@@ -33,4 +33,4 @@ protected Void run() throws IOException, InterruptedException {
notifier.sendBuildStepNotification(stepParameters);
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep.java b/src/main/java/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep.java
index 85f79dcd..8f31cb7c 100644
--- a/src/main/java/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep.java
+++ b/src/main/java/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep.java
@@ -31,6 +31,7 @@ public class Office365ConnectorSendStep extends Step {
private String status;
private List factDefinitions;
private String color;
+ private boolean adaptiveCards;
@DataBoundConstructor
public Office365ConnectorSendStep(String webhookUrl) {
@@ -83,6 +84,15 @@ public StepExecution start(StepContext context) {
return new Execution(this, context);
}
+ public boolean isAdaptiveCards() {
+ return adaptiveCards;
+ }
+
+ @DataBoundSetter
+ public void setAdaptiveCards(boolean adaptiveCards) {
+ this.adaptiveCards = adaptiveCards;
+ }
+
@Extension
@Symbol("office365ConnectorSend")
public static class DescriptorImpl extends StepDescriptor {
diff --git a/src/main/java/jenkins/plugins/office365connector/workflow/StepParameters.java b/src/main/java/jenkins/plugins/office365connector/workflow/StepParameters.java
index a6b68c45..bba8e190 100644
--- a/src/main/java/jenkins/plugins/office365connector/workflow/StepParameters.java
+++ b/src/main/java/jenkins/plugins/office365connector/workflow/StepParameters.java
@@ -28,14 +28,16 @@ public class StepParameters {
private final String webhookUrl;
private final String status;
private final String color;
- private List factDefinitions;
+ private final boolean adaptiveCards;
+ private final List factDefinitions;
- public StepParameters(String message, String webhookUrl, String status, List factDefinitions, String color) {
+ public StepParameters(String message, String webhookUrl, String status, List factDefinitions, String color, boolean adaptiveCards) {
this.message = message;
this.webhookUrl = webhookUrl;
this.status = status;
this.factDefinitions = factDefinitions;
this.color = color;
+ this.adaptiveCards = adaptiveCards;
}
public String getMessage() {
@@ -58,4 +60,7 @@ public String getColor() {
return color;
}
+ public boolean isAdaptiveCards() {
+ return adaptiveCards;
+ }
}
diff --git a/src/main/resources/jenkins/plugins/office365connector/Webhook/config.jelly b/src/main/resources/jenkins/plugins/office365connector/Webhook/config.jelly
index 6917e9a3..e6e8ae1f 100644
--- a/src/main/resources/jenkins/plugins/office365connector/Webhook/config.jelly
+++ b/src/main/resources/jenkins/plugins/office365connector/Webhook/config.jelly
@@ -7,6 +7,9 @@
+
+
+
diff --git a/src/main/resources/jenkins/plugins/office365connector/Webhook/help-adaptiveCards.html b/src/main/resources/jenkins/plugins/office365connector/Webhook/help-adaptiveCards.html
new file mode 100644
index 00000000..4b6e90fe
--- /dev/null
+++ b/src/main/resources/jenkins/plugins/office365connector/Webhook/help-adaptiveCards.html
@@ -0,0 +1 @@
+Use AdaptiveCards format.
diff --git a/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/config.jelly b/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/config.jelly
index 00c6b7c8..0e8fc6b0 100644
--- a/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/config.jelly
+++ b/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/config.jelly
@@ -13,4 +13,7 @@
+
+
+
diff --git a/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/help-adaptiveCards.html b/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/help-adaptiveCards.html
new file mode 100644
index 00000000..4b6e90fe
--- /dev/null
+++ b/src/main/resources/jenkins/plugins/office365connector/workflow/Office365ConnectorSendStep/help-adaptiveCards.html
@@ -0,0 +1 @@
+Use AdaptiveCards format.
diff --git a/src/test/java/jenkins/plugins/office365connector/ActionableBuilderTest.java b/src/test/java/jenkins/plugins/office365connector/ActionablePotentialActionBuilderTest.java
similarity index 93%
rename from src/test/java/jenkins/plugins/office365connector/ActionableBuilderTest.java
rename to src/test/java/jenkins/plugins/office365connector/ActionablePotentialActionBuilderTest.java
index af3f495b..eb8cd931 100644
--- a/src/test/java/jenkins/plugins/office365connector/ActionableBuilderTest.java
+++ b/src/test/java/jenkins/plugins/office365connector/ActionablePotentialActionBuilderTest.java
@@ -11,7 +11,7 @@
import hudson.model.AbstractProject;
import hudson.model.TaskListener;
import jenkins.plugins.office365connector.helpers.SCMHeadBuilder;
-import jenkins.plugins.office365connector.model.PotentialAction;
+import jenkins.plugins.office365connector.model.Action;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.metadata.ContributorMetadataAction;
import jenkins.scm.api.metadata.ObjectMetadataAction;
@@ -24,7 +24,7 @@
import org.junit.Test;
import org.mockito.MockedStatic;
-public class ActionableBuilderTest {
+public class ActionablePotentialActionBuilderTest {
private static final String JOB_URL = "http://localhost/job/myFirstJob/167/display/redirect";
@@ -43,7 +43,7 @@ public void setUp() {
taskListener = mock(TaskListener.class);
factsBuilder = new FactsBuilder(run, taskListener);
- actionableBuilder = new ActionableBuilder(run, factsBuilder);
+ actionableBuilder = new ActionableBuilder(run, factsBuilder, false);
DisplayURLProvider displayURLProvider = mock(DisplayURLProvider.class);
when(displayURLProvider.getRunURL(run)).thenReturn(JOB_URL);
@@ -64,11 +64,11 @@ public void buildActionable_OnEmptyAction_ReturnsEmptyList() {
// from @Before
// when
- List potentialActions = actionableBuilder.buildActionable();
+ List potentialActions = actionableBuilder.buildActionable();
// then
assertThat(potentialActions).hasSize(1);
- PotentialAction potentialAction = potentialActions.get(0);
+ Action potentialAction = potentialActions.get(0);
assertThat(potentialAction.getName()).isEqualTo("View Build");
}
@@ -133,7 +133,7 @@ public void pullRequestActionable_OnContributorMetadataAction_AddsFact() throws
// then
assertThat(factsBuilder.collect()).hasSize(1);
- List potentialActions = FieldReflection.getFieldValue(actionableBuilder.getClass().getDeclaredField("potentialActions"), actionableBuilder);
+ List potentialActions = FieldReflection.getFieldValue(actionableBuilder.getClass().getDeclaredField("potentialActions"), actionableBuilder);
assertThat(potentialActions).hasSize(1);
}
@@ -164,7 +164,7 @@ public void pullRequestActionable_OnObjectMetadataAction_DoesNotAddFact() throws
// then
assertThat(factsBuilder.collect()).hasSize(1);
- List potentialActions = FieldReflection.getFieldValue(actionableBuilder.getClass().getDeclaredField("potentialActions"), actionableBuilder);
+ List potentialActions = FieldReflection.getFieldValue(actionableBuilder.getClass().getDeclaredField("potentialActions"), actionableBuilder);
assertThat(potentialActions).isEmpty();
}
diff --git a/src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java b/src/test/java/jenkins/plugins/office365connector/CardBuilderMessageCardTest.java
similarity index 98%
rename from src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java
rename to src/test/java/jenkins/plugins/office365connector/CardBuilderMessageCardTest.java
index 4ec31837..add00734 100644
--- a/src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java
+++ b/src/test/java/jenkins/plugins/office365connector/CardBuilderMessageCardTest.java
@@ -21,7 +21,7 @@
import org.junit.Before;
import org.junit.Test;
-public class CardBuilderTest extends AbstractTest {
+public class CardBuilderMessageCardTest extends AbstractTest {
private static final String JOB_DISPLAY_NAME = "myJobDisplayName";
private static final int BUILD_NUMBER = 7;
@@ -44,7 +44,7 @@ public void setUp() throws Exception {
mockDisplayURLProvider(JOB_DISPLAY_NAME, BUILD_NUMBER);
TaskListener taskListener = mock(TaskListener.class);
- cardBuilder = new CardBuilder(run, taskListener);
+ cardBuilder = new CardBuilder(run, taskListener, false);
}
@@ -421,7 +421,7 @@ public void createBuildMessageCard_ReturnsCard() {
String status = Result.SUCCESS.toString();
String color = "blue";
- StepParameters stepParameters = new StepParameters(message, webhookUrl, status, Collections.emptyList(), color);
+ StepParameters stepParameters = new StepParameters(message, webhookUrl, status, Collections.emptyList(), color, false);
// then
Card card = cardBuilder.createBuildMessageCard(stepParameters);
@@ -443,7 +443,7 @@ public void createBuildMessageCard_OnMissingStatus_ReturnsCard() {
String status = null;
String color = "blue";
- StepParameters stepParameters = new StepParameters(message, webhookUrl, status, Collections.emptyList(), color);
+ StepParameters stepParameters = new StepParameters(message, webhookUrl, status, Collections.emptyList(), color, false);
// then
Card card = cardBuilder.createBuildMessageCard(stepParameters);
@@ -464,7 +464,7 @@ public void createBuildMessageCard_OnMissingColor_ReturnsCard() {
String status = Result.ABORTED.toString();
String color = null;
- StepParameters stepParameters = new StepParameters(message, webhookUrl, status, Collections.emptyList(), color);
+ StepParameters stepParameters = new StepParameters(message, webhookUrl, status, Collections.emptyList(), color, false);
// then
Card card = cardBuilder.createBuildMessageCard(stepParameters);
@@ -494,7 +494,7 @@ public void getEscapedDisplayName_OnNameWithSpecialCharacters_EscapesSpecialChar
when(run.getParent()).thenReturn(job);
TaskListener taskListener = mock(TaskListener.class);
- cardBuilder = new CardBuilder(run, taskListener);
+ cardBuilder = new CardBuilder(run, taskListener, false);
// when
String displayName = MethodReflection.invokeWithCheckedThrows(cardBuilder.getClass(), cardBuilder, "getEscapedDisplayName", new Class[]{});
diff --git a/src/test/java/jenkins/plugins/office365connector/model/CardTest.java b/src/test/java/jenkins/plugins/office365connector/model/messagecard/MessageCardTest.java
similarity index 52%
rename from src/test/java/jenkins/plugins/office365connector/model/CardTest.java
rename to src/test/java/jenkins/plugins/office365connector/model/messagecard/MessageCardTest.java
index a11440b2..d7467cc8 100644
--- a/src/test/java/jenkins/plugins/office365connector/model/CardTest.java
+++ b/src/test/java/jenkins/plugins/office365connector/model/messagecard/MessageCardTest.java
@@ -1,15 +1,16 @@
-package jenkins.plugins.office365connector.model;
+package jenkins.plugins.office365connector.model.messagecard;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
+import jenkins.plugins.office365connector.model.Section;
import org.junit.Test;
/**
* @author Damian Szczepanik (damianszczepanik@github)
*/
-public class CardTest {
+public class MessageCardTest {
@Test
public void getSummary_ReturnsSummary() {
@@ -18,10 +19,10 @@ public void getSummary_ReturnsSummary() {
String summary = "mySummary";
// when
- Card card = new Card(summary, null);
+ MessageCard messageCard = new MessageCard(summary, null);
// then
- assertThat(card.getSummary()).isEqualTo(summary);
+ assertThat(messageCard.getSummary()).isEqualTo(summary);
}
@Test
@@ -31,10 +32,10 @@ public void getSections_ReturnsSection() {
Section section = new Section("myTitle", null, null);
// when
- Card card = new Card(null, section);
+ MessageCard messageCard = new MessageCard(null, section);
// then
- assertThat(card.getSections()).hasSize(1).containsOnly(section);
+ assertThat(messageCard.getSections()).hasSize(1).containsOnly(section);
}
@Test
@@ -42,13 +43,13 @@ public void getThemeColor_ReturnsThemeColor() {
// given
String themeColor = "red";
- Card card = new Card("mySummary", null);
+ MessageCard messageCard = new MessageCard("mySummary", null);
// when
- card.setThemeColor(themeColor);
+ messageCard.setThemeColor(themeColor);
// then
- assertThat(card.getThemeColor()).isEqualTo(themeColor);
+ assertThat(messageCard.getThemeColor()).isEqualTo(themeColor);
}
@Test
@@ -56,12 +57,12 @@ public void getPotentialAction_ReturnsPotentialActions() {
// given
PotentialAction action = new PotentialAction("myName", Collections.singletonList("someUrl"));
- Card card = new Card("mySummary", null);
+ MessageCard messageCard = new MessageCard("mySummary", null);
// when
- card.setPotentialAction(Collections.singletonList(action));
+ messageCard.setAction(Collections.singletonList(action));
// then
- assertThat(card.getPotentialAction()).hasSize(1).containsOnly(action);
+ assertThat(messageCard.getAction()).hasSize(1).containsOnly(action);
}
}
diff --git a/src/test/java/jenkins/plugins/office365connector/model/PotentialActionTest.java b/src/test/java/jenkins/plugins/office365connector/model/messagecard/PotentialActionTest.java
similarity index 96%
rename from src/test/java/jenkins/plugins/office365connector/model/PotentialActionTest.java
rename to src/test/java/jenkins/plugins/office365connector/model/messagecard/PotentialActionTest.java
index 2b7427bb..f13cb660 100644
--- a/src/test/java/jenkins/plugins/office365connector/model/PotentialActionTest.java
+++ b/src/test/java/jenkins/plugins/office365connector/model/messagecard/PotentialActionTest.java
@@ -1,4 +1,4 @@
-package jenkins.plugins.office365connector.model;
+package jenkins.plugins.office365connector.model.messagecard;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/src/test/java/jenkins/plugins/office365connector/workflow/SampleIT.java b/src/test/java/jenkins/plugins/office365connector/workflow/SampleIT.java
index 5cb097d8..b999e9c8 100644
--- a/src/test/java/jenkins/plugins/office365connector/workflow/SampleIT.java
+++ b/src/test/java/jenkins/plugins/office365connector/workflow/SampleIT.java
@@ -149,7 +149,7 @@ public void sendBuildStepNotification_SendsProperData() {
// given
StepParameters stepParameters = new StepParameters(
"helloMessage", ClassicDisplayURLProviderBuilder.LOCALHOST_URL_TEMPLATE,
- "funnyStatus", Collections.emptyList(), "#FF00FF");
+ "funnyStatus", Collections.emptyList(), "#FF00FF", false);
when(run.getResult()).thenReturn(Result.FAILURE);
Office365ConnectorWebhookNotifier notifier = new Office365ConnectorWebhookNotifier(run, mockListener());
diff --git a/src/test/java/jenkins/plugins/office365connector/workflow/StepParametersTest.java b/src/test/java/jenkins/plugins/office365connector/workflow/StepParametersTest.java
index c2217dbd..2d030cac 100644
--- a/src/test/java/jenkins/plugins/office365connector/workflow/StepParametersTest.java
+++ b/src/test/java/jenkins/plugins/office365connector/workflow/StepParametersTest.java
@@ -25,7 +25,7 @@ public class StepParametersTest {
@Before
public void setUp() {
stepParameters = new StepParameters(
- MESSAGE, WEBHOOK_URL, STATUS, Collections.singletonList(FACT_DEFINITION), COLOR);
+ MESSAGE, WEBHOOK_URL, STATUS, Collections.singletonList(FACT_DEFINITION), COLOR, false);
}
@Test