use of com.redhat.cloud.notifications.ingress.Action in project notifications-backend by RedHatInsights.
the class TestAdvisorTemplate method testInstantEmailTitleForNewRecommendations.
@Test
public void testInstantEmailTitleForNewRecommendations() {
Action action = TestHelpers.createAdvisorAction("123456", "new-recommendation");
String result = Advisor.Templates.newRecommendationInstantEmailTitle().data("action", action).render();
assertEquals("Red Hat Enterprise Linux - Advisor Instant Notification - 03 Oct 2020 15:22 UTC - 4 new recommendations\n", result, "Title contains the number of reports created");
// Action with only 1 event
action.setEvents(List.of(action.getEvents().get(0)));
result = Advisor.Templates.newRecommendationInstantEmailTitle().data("action", action).render();
assertEquals("Red Hat Enterprise Linux - Advisor Instant Notification - 03 Oct 2020 15:22 UTC - 1 new recommendation\n", result, "Title contains the number of reports created");
}
use of com.redhat.cloud.notifications.ingress.Action in project notifications-backend by RedHatInsights.
the class TestDriftTemplate method testInstantEmailTitle.
public void testInstantEmailTitle() {
Action action = DriftTestHelpers.createDriftAction("tenant", "rhel", "drift", "host-01", "Machine 1");
String result = Drift.Templates.newBaselineDriftInstantEmailTitle().data("action", action).render();
assertTrue(result.contains("2 drifts from baseline detected on Machine 1"));
}
use of com.redhat.cloud.notifications.ingress.Action in project notifications-backend by RedHatInsights.
the class TestOpenshiftAdvisorTemplate method testInstantEmailTitle.
@Test
public void testInstantEmailTitle() {
Action action = TestHelpers.createAdvisorOpenshiftAction("123456", "new-recommendation");
String result = AdvisorOpenshift.Templates.newRecommendationInstantEmailTitle().data("action", action).render();
assertTrue(result.contains("OpenShift - Advisor Instant Notification - "));
assertTrue(result.contains("2021"));
}
use of com.redhat.cloud.notifications.ingress.Action in project notifications-backend by RedHatInsights.
the class TestOpenshiftAdvisorTemplate method testInstantEmailBody.
@Test
public void testInstantEmailBody() {
Action action = TestHelpers.createAdvisorOpenshiftAction("123456", "new-recommendation");
final String result = AdvisorOpenshift.Templates.newRecommendationInstantEmailBody().data("action", action).render();
action.getEvents().forEach(event -> {
assertTrue(result.contains(event.getPayload().getAdditionalProperties().get("rule_description").toString()), "Body should contain rule description" + event.getPayload().getAdditionalProperties().get("rule_description"));
assertTrue(result.contains(event.getPayload().getAdditionalProperties().get("total_risk").toString()), "Body should contain total_risk" + event.getPayload().getAdditionalProperties().get("total_risk"));
assertTrue(result.contains(event.getPayload().getAdditionalProperties().get("rule_url").toString()), "Body should contain rule_url" + event.getPayload().getAdditionalProperties().get("rule_url"));
});
assertTrue(result.contains("alt=\"Low severity\""), "Body should contain low severity rule image");
assertTrue(result.contains("alt=\"Moderate severity\""), "Body should contain moderate severity rule image");
assertTrue(result.contains("alt=\"Important severity\""), "Body should contain important severity rule image");
assertTrue(result.contains("alt=\"Critical severity\""), "Body should contain critical severity rule image");
// Display name
assertTrue(result.contains("some-cluster-name"), "Body should contain the display_name");
action.setEvents(action.getEvents().stream().filter(event -> event.getPayload().getAdditionalProperties().get("total_risk").equals("1")).collect(Collectors.toList()));
String result2 = AdvisorOpenshift.Templates.newRecommendationInstantEmailBody().data("action", action).render();
assertTrue(result2.contains("alt=\"Low severity\""), "Body 2 should contain low severity rule image");
assertFalse(result2.contains("alt=\"Moderate severity\""), "Body 2 should not contain moderate severity rule image");
assertFalse(result2.contains("alt=\"Important severity\""), "Body 2 should not contain important severity rule image");
assertFalse(result2.contains("alt=\"Critical severity\""), "Body 2 should not contain critical severity rule image");
}
use of com.redhat.cloud.notifications.ingress.Action in project notifications-backend by RedHatInsights.
the class TestPoliciesTemplate method testInstantEmailTitle.
@Test
public void testInstantEmailTitle() {
Action action = TestHelpers.createPoliciesAction("", "", "", "FooMachine");
String result = Policies.Templates.instantEmailTitle().data("action", action).render();
assertTrue(result.contains("2"), "Title contains the number of policies triggered");
assertTrue(result.contains("FooMachine"), "Body should contain the display_name");
}
Aggregations