From 159844a132a5a97ecccf43d6c153ba639f59587b Mon Sep 17 00:00:00 2001 From: Andrei Kliuchnikau <58571912+draker94@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:25:07 +0300 Subject: [PATCH] Remove unnecessary phrases data model (#288) Co-authored-by: Andrei Kliuchnikau --- .../template/data/MessageData.java | 6 +-- .../template/data/PhrasesData.java | 43 ------------------- .../src/main/resources/templates/html.ftl | 38 ++++++++-------- .../src/main/resources/templates/markdown.ftl | 38 ++++++++-------- .../src/main/resources/templates/rocket.ftl | 38 ++++++++-------- .../src/main/resources/templates/telegram.ftl | 38 ++++++++-------- 6 files changed, 79 insertions(+), 122 deletions(-) delete mode 100644 allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/PhrasesData.java diff --git a/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/MessageData.java b/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/MessageData.java index 21aa1f3..873a205 100644 --- a/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/MessageData.java +++ b/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/MessageData.java @@ -21,7 +21,7 @@ public class MessageData { private final BuildData buildData; private final SummaryData summaryData; private final String suitesSummaryJson; - private final PhrasesData phrasesData; + private final Phrases phrases; private Map data; public MessageData(Base base, Summary summary, String suitesSummaryJson, Phrases phrases) { @@ -29,7 +29,7 @@ public MessageData(Base base, Summary summary, String suitesSummaryJson, Phrases this.buildData = new BuildData(base); this.summaryData = new SummaryData(base, summary); this.suitesSummaryJson = suitesSummaryJson; - this.phrasesData = new PhrasesData(phrases); + this.phrases = phrases; } public Map getValues() { @@ -39,7 +39,7 @@ public Map getValues() { data.putAll(buildData.map()); data.putAll(summaryData.map()); data.put("suitesSummaryJson", suitesSummaryJson); - data.putAll(phrasesData.map()); + data.put("phrases", phrases); log.info("Template data: {}", data); } return data; diff --git a/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/PhrasesData.java b/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/PhrasesData.java deleted file mode 100644 index 91de1db..0000000 --- a/allure-notifications-api/src/main/java/guru/qa/allure/notifications/template/data/PhrasesData.java +++ /dev/null @@ -1,43 +0,0 @@ -package guru.qa.allure.notifications.template.data; - -import guru.qa.allure.notifications.model.phrases.Phrases; -import lombok.extern.slf4j.Slf4j; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author kadehar - * @since 4.0 - * Utility class for mapping phrases data for template. - */ -@Slf4j -public class PhrasesData implements TemplateData { - private final Phrases phrases; - - public PhrasesData(Phrases phrases) { - this.phrases = phrases; - } - - @Override - public Map map() { - log.info("Collecting phrases data for template"); - - Map info = new HashMap<>(); - info.put("results", phrases.getResults()); - info.put("environment", phrases.getEnvironment()); - info.put("comment", phrases.getComment()); - info.put("reportAvailableAtLink", phrases.getReportAvailableAtLink()); - info.put("numberOfSuites", phrases.getNumberOfSuites()); - info.put("suiteName", phrases.getSuiteName()); - info.put("duration", phrases.getScenario().getDuration()); - info.put("totalScenarios", phrases.getScenario().getTotalScenarios()); - info.put("totalPassed", phrases.getScenario().getTotalPassed()); - info.put("totalFailed", phrases.getScenario().getTotalFailed()); - info.put("totalBroken", phrases.getScenario().getTotalBroken()); - info.put("totalUnknown", phrases.getScenario().getTotalUnknown()); - info.put("totalSkipped", phrases.getScenario().getTotalSkipped()); - log.info("Phrases data: {}", info); - return info; - } -} diff --git a/allure-notifications-api/src/main/resources/templates/html.ftl b/allure-notifications-api/src/main/resources/templates/html.ftl index bce2da0..b2dd78c 100644 --- a/allure-notifications-api/src/main/resources/templates/html.ftl +++ b/allure-notifications-api/src/main/resources/templates/html.ftl @@ -1,20 +1,20 @@ <#compress> -

${results}:

- ${environment}: ${env}
- ${comment}: ${comm}
- ${duration}: ${time}
- ${totalScenarios}: ${total} +

${phrases.results}:

+ ${phrases.environment}: ${env}
+ ${phrases.comment}: ${comm}
+ ${phrases.scenario.duration}: ${time}
+ ${phrases.scenario.totalScenarios}: ${total}
    - <#if passed != 0 >
  • ${totalPassed}: ${passed} (${passedPercentage} %)
  • - <#if failed != 0 >
  • ${totalFailed}: ${failed} (${failedPercentage} %)
  • - <#if broken != 0 >
  • ${totalBroken}: ${broken}
  • - <#if unknown != 0 >
  • ${totalUnknown}: ${unknown}
  • - <#if skipped != 0 >
  • ${totalSkipped}: ${skipped}
  • + <#if passed != 0 >
  • ${phrases.scenario.totalPassed}: ${passed} (${passedPercentage} %)
  • + <#if failed != 0 >
  • ${phrases.scenario.totalFailed}: ${failed} (${failedPercentage} %)
  • + <#if broken != 0 >
  • ${phrases.scenario.totalBroken}: ${broken}
  • + <#if unknown != 0 >
  • ${phrases.scenario.totalUnknown}: ${unknown}
  • + <#if skipped != 0 >
  • ${phrases.scenario.totalSkipped}: ${skipped}
<#if suitesSummaryJson??> <#assign suitesData = suitesSummaryJson?eval_json> - ${numberOfSuites}: ${suitesData.total}
+ ${phrases.numberOfSuites}: ${suitesData.total}
<#list suitesData.items as suite> <#assign suitePassed = suite.statistic.passed> <#assign suiteFailed = suite.statistic.failed> @@ -25,17 +25,17 @@
- ${suiteName}: ${suite.name}
- ${totalScenarios}: ${suite.statistic.total}
- <#if suitePassed != 0 >
  • ${totalPassed}: ${suitePassed}
  • - <#if suiteFailed != 0 >
  • ${totalFailed}: ${suiteFailed}
  • - <#if suiteBroken != 0 >
  • ${totalBroken}: ${suiteBroken}
  • - <#if suiteUnknown != 0 >
  • ${totalUnknown}: ${suiteUnknown}
  • - <#if suiteSkipped != 0 >
  • ${totalSkipped}: ${suiteSkipped}
  • + ${phrases.suiteName}: ${suite.name}
    + ${phrases.scenario.totalScenarios}: ${suite.statistic.total}
    + <#if suitePassed != 0 >
  • ${phrases.scenario.totalPassed}: ${suitePassed}
  • + <#if suiteFailed != 0 >
  • ${phrases.scenario.totalFailed}: ${suiteFailed}
  • + <#if suiteBroken != 0 >
  • ${phrases.scenario.totalBroken}: ${suiteBroken}
  • + <#if suiteUnknown != 0 >
  • ${phrases.scenario.totalUnknown}: ${suiteUnknown}
  • + <#if suiteSkipped != 0 >
  • ${phrases.scenario.totalSkipped}: ${suiteSkipped}

  • - <#if reportLink??>${reportAvailableAtLink}: ${reportLink} + <#if reportLink??>${phrases.reportAvailableAtLink}: ${reportLink} \ No newline at end of file diff --git a/allure-notifications-api/src/main/resources/templates/markdown.ftl b/allure-notifications-api/src/main/resources/templates/markdown.ftl index 297237f..681791a 100644 --- a/allure-notifications-api/src/main/resources/templates/markdown.ftl +++ b/allure-notifications-api/src/main/resources/templates/markdown.ftl @@ -1,18 +1,18 @@ <#compress> -*${results}:* - *${environment}:* ${env} - *${comment}:* ${comm} - *${duration}:* ${time} - *${totalScenarios}:* ${total} - <#if passed != 0 > *${totalPassed}:* ${passed} (${passedPercentage} %) - <#if failed != 0 > *${totalFailed}:* ${failed} (${failedPercentage} %) - <#if broken != 0 > *${totalBroken}:* ${broken} - <#if unknown != 0 >*${totalUnknown}:* ${unknown} - <#if skipped != 0 >*${totalSkipped}:* ${skipped} +*${phrases.results}:* + *${phrases.environment}:* ${env} + *${phrases.comment}:* ${comm} + *${phrases.scenario.duration}:* ${time} + *${phrases.scenario.totalScenarios}:* ${total} + <#if passed != 0 > *${phrases.scenario.totalPassed}:* ${passed} (${passedPercentage} %) + <#if failed != 0 > *${phrases.scenario.totalFailed}:* ${failed} (${failedPercentage} %) + <#if broken != 0 > *${phrases.scenario.totalBroken}:* ${broken} + <#if unknown != 0 >*${phrases.scenario.totalUnknown}:* ${unknown} + <#if skipped != 0 >*${phrases.scenario.totalSkipped}:* ${skipped} <#if suitesSummaryJson??> <#assign suitesData = suitesSummaryJson?eval_json> - *${numberOfSuites}:* ${suitesData.total} + *${phrases.numberOfSuites}:* ${suitesData.total} <#list suitesData.items as suite> <#assign suitePassed = suite.statistic.passed> <#assign suiteFailed = suite.statistic.failed> @@ -20,14 +20,14 @@ <#assign suiteUnknown = suite.statistic.unknown> <#assign suiteSkipped = suite.statistic.skipped> - *${suiteName}:* ${suite.name} - > *${totalScenarios}:* ${suite.statistic.total} - <#if suitePassed != 0 >> *${totalPassed}:* ${suitePassed} - <#if suiteFailed != 0 >> *${totalFailed}:* ${suiteFailed} - <#if suiteBroken != 0 >> *${totalBroken}:* ${suiteBroken} - <#if suiteUnknown != 0 >> *${totalUnknown}:* ${suiteUnknown} - <#if suiteSkipped != 0 >> *${totalSkipped}:* ${suiteSkipped} + *${phrases.suiteName}:* ${suite.name} + > *${phrases.scenario.totalScenarios}:* ${suite.statistic.total} + <#if suitePassed != 0 >> *${phrases.scenario.totalPassed}:* ${suitePassed} + <#if suiteFailed != 0 >> *${phrases.scenario.totalFailed}:* ${suiteFailed} + <#if suiteBroken != 0 >> *${phrases.scenario.totalBroken}:* ${suiteBroken} + <#if suiteUnknown != 0 >> *${phrases.scenario.totalUnknown}:* ${suiteUnknown} + <#if suiteSkipped != 0 >> *${phrases.scenario.totalSkipped}:* ${suiteSkipped} - <#if reportLink??>*${reportAvailableAtLink}:* ${reportLink} + <#if reportLink??>*${phrases.reportAvailableAtLink}:* ${reportLink} \ No newline at end of file diff --git a/allure-notifications-api/src/main/resources/templates/rocket.ftl b/allure-notifications-api/src/main/resources/templates/rocket.ftl index 37eadda..ae200c1 100644 --- a/allure-notifications-api/src/main/resources/templates/rocket.ftl +++ b/allure-notifications-api/src/main/resources/templates/rocket.ftl @@ -1,18 +1,18 @@ <#compress> - **${results}:** - **-${environment}:** ${env} - **-${comment}:** ${comm} - **-${duration}:** **${time}** - **-${totalScenarios}:** ${total} - <#if passed != 0 > **-${totalPassed}:** ${passed} **(${passedPercentage} %)** - <#if failed != 0 > **-${totalFailed}:** ${failed} **(${failedPercentage} %)** - <#if broken != 0 > **-${totalBroken}:** ${broken} - <#if unknown != 0 > **-${totalUnknown}:** ${unknown} - <#if skipped != 0 > **-${totalSkipped}:** ${skipped} + **${phrases.results}:** + **-${phrases.environment}:** ${env} + **-${phrases.comment}:** ${comm} + **-${phrases.scenario.duration}:** **${time}** + **-${phrases.scenario.totalScenarios}:** ${total} + <#if passed != 0 > **-${phrases.scenario.totalPassed}:** ${passed} **(${passedPercentage} %)** + <#if failed != 0 > **-${phrases.scenario.totalFailed}:** ${failed} **(${failedPercentage} %)** + <#if broken != 0 > **-${phrases.scenario.totalBroken}:** ${broken} + <#if unknown != 0 > **-${phrases.scenario.totalUnknown}:** ${unknown} + <#if skipped != 0 > **-${phrases.scenario.totalSkipped}:** ${skipped} <#if suitesSummaryJson??> <#assign suitesData = suitesSummaryJson?eval_json> - **-${numberOfSuites}:** **${suitesData.total}** + **-${phrases.numberOfSuites}:** **${suitesData.total}** <#list suitesData.items as suite> <#assign suitePassed = suite.statistic.passed> <#assign suiteFailed = suite.statistic.failed> @@ -20,14 +20,14 @@ <#assign suiteUnknown = suite.statistic.unknown> <#assign suiteSkipped = suite.statistic.skipped> - **-${suiteName}:** **${suite.name}** - **-${totalScenarios}:** **${suite.statistic.total}** - <#if suitePassed != 0 > **-${totalPassed}:** ${suitePassed} - <#if suiteFailed != 0 > **-${totalFailed}:** ${suiteFailed} - <#if suiteBroken != 0 > **-${totalBroken}:** ${suiteBroken} - <#if suiteUnknown != 0 > **-${totalUnknown}:** ${suiteUnknown} - <#if suiteSkipped != 0 > **-${totalSkipped}:** ${suiteSkipped} + **-${phrases.suiteName}:** **${suite.name}** + **-${phrases.scenario.totalScenarios}:** **${suite.statistic.total}** + <#if suitePassed != 0 > **-${phrases.scenario.totalPassed}:** ${suitePassed} + <#if suiteFailed != 0 > **-${phrases.scenario.totalFailed}:** ${suiteFailed} + <#if suiteBroken != 0 > **-${phrases.scenario.totalBroken}:** ${suiteBroken} + <#if suiteUnknown != 0 > **-${phrases.scenario.totalUnknown}:** ${suiteUnknown} + <#if suiteSkipped != 0 > **-${phrases.scenario.totalSkipped}:** ${suiteSkipped} - <#if reportLink??>**${reportAvailableAtLink}:** ${reportLink} + <#if reportLink??>**${phrases.reportAvailableAtLink}:** ${reportLink} \ No newline at end of file diff --git a/allure-notifications-api/src/main/resources/templates/telegram.ftl b/allure-notifications-api/src/main/resources/templates/telegram.ftl index 85f14a0..e399855 100644 --- a/allure-notifications-api/src/main/resources/templates/telegram.ftl +++ b/allure-notifications-api/src/main/resources/templates/telegram.ftl @@ -1,18 +1,18 @@ <#compress> - ${results}: - ${environment}: ${env} - ${comment}: ${comm} - ${duration}: ${time} - ${totalScenarios}: ${total} - <#if passed != 0 >${totalPassed}: ${passed} (${passedPercentage} %) - <#if failed != 0 >${totalFailed}: ${failed} (${failedPercentage} %) - <#if broken != 0 >${totalBroken}: ${broken} - <#if unknown != 0 >${totalUnknown}: ${unknown} - <#if skipped != 0 >${totalSkipped}: ${skipped} + ${phrases.results}: + ${phrases.environment}: ${env} + ${phrases.comment}: ${comm} + ${phrases.scenario.duration}: ${time} + ${phrases.scenario.totalScenarios}: ${total} + <#if passed != 0 >${phrases.scenario.totalPassed}: ${passed} (${passedPercentage} %) + <#if failed != 0 >${phrases.scenario.totalFailed}: ${failed} (${failedPercentage} %) + <#if broken != 0 >${phrases.scenario.totalBroken}: ${broken} + <#if unknown != 0 >${phrases.scenario.totalUnknown}: ${unknown} + <#if skipped != 0 >${phrases.scenario.totalSkipped}: ${skipped} <#if suitesSummaryJson??> <#assign suitesData = suitesSummaryJson?eval_json> - ${numberOfSuites}: ${suitesData.total} + ${phrases.numberOfSuites}: ${suitesData.total} <#list suitesData.items as suite> <#assign suitePassed = suite.statistic.passed> <#assign suiteFailed = suite.statistic.failed> @@ -20,14 +20,14 @@ <#assign suiteUnknown = suite.statistic.unknown> <#assign suiteSkipped = suite.statistic.skipped> - ${suiteName}: ${suite.name} - ${totalScenarios}: ${suite.statistic.total} - <#if suitePassed != 0 >${totalPassed}: ${suitePassed} - <#if suiteFailed != 0 >${totalFailed}: ${suiteFailed} - <#if suiteBroken != 0 >${totalBroken}: ${suiteBroken} - <#if suiteUnknown != 0 >${totalUnknown}: ${suiteUnknown} - <#if suiteSkipped != 0 >${totalSkipped}: ${suiteSkipped} + ${phrases.suiteName}: ${suite.name} + ${phrases.scenario.totalScenarios}: ${suite.statistic.total} + <#if suitePassed != 0 >${phrases.scenario.totalPassed}: ${suitePassed} + <#if suiteFailed != 0 >${phrases.scenario.totalFailed}: ${suiteFailed} + <#if suiteBroken != 0 >${phrases.scenario.totalBroken}: ${suiteBroken} + <#if suiteUnknown != 0 >${phrases.scenario.totalUnknown}: ${suiteUnknown} + <#if suiteSkipped != 0 >${phrases.scenario.totalSkipped}: ${suiteSkipped} - <#if reportLink??>${reportAvailableAtLink}: ${reportLink} + <#if reportLink??>${phrases.reportAvailableAtLink}: ${reportLink} \ No newline at end of file