diff --git a/src/main/java/jenkins/plugins/office365connector/CardBuilder.java b/src/main/java/jenkins/plugins/office365connector/CardBuilder.java index f487bde..6316215 100644 --- a/src/main/java/jenkins/plugins/office365connector/CardBuilder.java +++ b/src/main/java/jenkins/plugins/office365connector/CardBuilder.java @@ -48,7 +48,7 @@ public Card createStartedCard(List factDefinitions) { factsBuilder.addDevelopers(); factsBuilder.addUserFacts(factDefinitions); - Section section = buildSection(); + Section section = buildSection(statusName); String summary = getDisplayName() + ": Build " + getRunName(); Card card = new Card(summary, section); @@ -84,7 +84,7 @@ public Card createCompletedCard(List factDefinitions) { factsBuilder.addDevelopers(); factsBuilder.addUserFacts(factDefinitions); - Section section = buildSection(); + Section section = buildSection(status); Card card = new Card(summary, section); card.setThemeColor(getCardThemeColor(lastResult)); @@ -104,8 +104,8 @@ private static String getCardThemeColor(Result result) { } } - private Section buildSection() { - String activityTitle = "Notification from " + getEscapedDisplayName(); + private Section buildSection(String status) { + String activityTitle = "Notification from " + getEscapedDisplayName() + ": " + status; String activitySubtitle = "Latest status of build " + getRunName(); return new Section(activityTitle, activitySubtitle, factsBuilder.collect()); } diff --git a/src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java b/src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java index c1e31b0..4ec3183 100644 --- a/src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java +++ b/src/test/java/jenkins/plugins/office365connector/CardBuilderTest.java @@ -62,7 +62,7 @@ public void createStartedCard_ReturnsCard() { assertThat(card.getSections()).hasSize(1); assertThat(card.getThemeColor()).isEqualTo("3479BF"); Section section = card.getSections().get(0); - assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME); + assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Started"); } @Test @@ -81,7 +81,7 @@ public void createCompletedCard_OnAborted_ReturnsCard() { assertThat(card.getSections()).hasSize(1); assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor()); Section section = card.getSections().get(0); - assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME); + assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Build Aborted"); } @Test @@ -98,7 +98,7 @@ public void createCompletedCard_OnFirstFailure_ReturnsCard() { assertThat(card.getSections()).hasSize(1); assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor()); Section section = card.getSections().get(0); - assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME); + assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Build Failed"); } @Test @@ -125,7 +125,7 @@ public void createCompletedCard_OnSecondFailure_AddsFailingSinceFact() { assertThat(card.getSections()).hasSize(1); assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor()); Section section = card.getSections().get(0); - assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME); + assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Repeated Failure"); FactAssertion.assertThatLast(section.getFacts(), 2) .hasName(FactsBuilder.NAME_FAILING_SINCE_BUILD) .hasValue("build #" + previousNotFailedBuildNumber); @@ -155,7 +155,7 @@ public void createCompletedCard_OnFirstFailure_SkipsFailingSinceFact() { assertThat(card.getSections()).hasSize(1); assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor()); Section section = card.getSections().get(0); - assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME); + assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Build Failed"); FactAssertion.assertThatLast(section.getFacts(), 1); FactAssertion.assertThat(section.getFacts()) .hasName(FactsBuilder.NAME_STATUS) diff --git a/src/test/resources/requests/back_to_normal-without_actions.json b/src/test/resources/requests/back_to_normal-without_actions.json index 1c81d44..f64c4dd 100644 --- a/src/test/resources/requests/back_to_normal-without_actions.json +++ b/src/test/resources/requests/back_to_normal-without_actions.json @@ -22,7 +22,7 @@ "value": "damian" } ], - "activityTitle": "Notification from hook » PR\\-1", + "activityTitle": "Notification from hook » PR\\-1: Back to Normal", "activitySubtitle": "Latest status of build #3" } ] diff --git a/src/test/resources/requests/completed-failed.json b/src/test/resources/requests/completed-failed.json index 360b7f4..048e080 100644 --- a/src/test/resources/requests/completed-failed.json +++ b/src/test/resources/requests/completed-failed.json @@ -18,7 +18,7 @@ "value": "Mike" } ], - "activityTitle": "Notification from myFirst\\_Job\\_", + "activityTitle": "Notification from myFirst\\_Job\\_: Build Failed", "activitySubtitle": "Latest status of build #167" } ], diff --git a/src/test/resources/requests/completed-repeated_failure.json b/src/test/resources/requests/completed-repeated_failure.json index 8ae810a..4b9747f 100644 --- a/src/test/resources/requests/completed-repeated_failure.json +++ b/src/test/resources/requests/completed-repeated_failure.json @@ -22,7 +22,7 @@ "value": "Mike" } ], - "activityTitle": "Notification from myFirst\\_Job\\_", + "activityTitle": "Notification from myFirst\\_Job\\_: Repeated Failure", "activitySubtitle": "Latest status of build #167" } ], diff --git a/src/test/resources/requests/completed-success.json b/src/test/resources/requests/completed-success.json index f377f7c..26ff29f 100644 --- a/src/test/resources/requests/completed-success.json +++ b/src/test/resources/requests/completed-success.json @@ -18,7 +18,7 @@ "value": "Mike" } ], - "activityTitle": "Notification from myFirst\\_Job\\_", + "activityTitle": "Notification from myFirst\\_Job\\_: Build Success", "activitySubtitle": "Latest status of build #167" } ] diff --git a/src/test/resources/requests/repeated_failure-pull_request.json b/src/test/resources/requests/repeated_failure-pull_request.json index 017b524..60d7b69 100644 --- a/src/test/resources/requests/repeated_failure-pull_request.json +++ b/src/test/resources/requests/repeated_failure-pull_request.json @@ -34,7 +34,7 @@ "value": "damianszczepanik (Damian Szczepanik)" } ], - "activityTitle": "Notification from hook » PR\\-1", + "activityTitle": "Notification from hook » PR\\-1: Repeated Failure", "activitySubtitle": "Latest status of build #3" } ], diff --git a/src/test/resources/requests/started-developers.json b/src/test/resources/requests/started-developers.json index bc57984..481b656 100644 --- a/src/test/resources/requests/started-developers.json +++ b/src/test/resources/requests/started-developers.json @@ -14,7 +14,7 @@ "value": "Ann, the Queen, George Great, Peter" } ], - "activityTitle": "Notification from simple job", + "activityTitle": "Notification from simple job: Started", "activitySubtitle": "Latest status of build #1" } ], diff --git a/src/test/resources/requests/started.json b/src/test/resources/requests/started.json index 394d847..2be4003 100644 --- a/src/test/resources/requests/started.json +++ b/src/test/resources/requests/started.json @@ -18,7 +18,7 @@ "value": "Mike" } ], - "activityTitle": "Notification from myFirst\\_Job\\_", + "activityTitle": "Notification from myFirst\\_Job\\_: Started", "activitySubtitle": "Latest status of build #167" } ],