Search in sources :

Example 11 with Payload

use of com.redhat.cloud.notifications.ingress.Payload in project notifications-backend by RedHatInsights.

the class ComplianceTestHelpers method createEmailAggregation.

public static EmailAggregation createEmailAggregation(String tenant, String bundle, String application, String eventType, String policyId, String inventoryId) {
    EmailAggregation aggregation = new EmailAggregation();
    aggregation.setBundleName(bundle);
    aggregation.setApplicationName(application);
    aggregation.setAccountId(tenant);
    aggregation.setCreated(LocalDateTime.now(UTC).minusHours(5L));
    Action emailActionMessage = new Action();
    emailActionMessage.setBundle(bundle);
    emailActionMessage.setApplication(application);
    emailActionMessage.setTimestamp(LocalDateTime.now());
    emailActionMessage.setEventType(eventType);
    emailActionMessage.setContext(new Context.ContextBuilder().withAdditionalProperty("inventory_id", inventoryId).withAdditionalProperty("system_check_in", "2020-08-03T15:22:42.199046").withAdditionalProperty("display_name", "My test machine").withAdditionalProperty("tags", List.of()).build());
    emailActionMessage.setEvents(List.of(new Event.EventBuilder().withMetadata(new Metadata.MetadataBuilder().build()).withPayload(new Payload.PayloadBuilder().withAdditionalProperty("policy_id", policyId).withAdditionalProperty("policy_name", "not-tested-name").withAdditionalProperty("policy_description", "not-used-desc").withAdditionalProperty("policy_condition", "not-used-condition").build()).build()));
    emailActionMessage.setAccountId(tenant);
    JsonObject payload = baseTransformer.transform(emailActionMessage);
    aggregation.setPayload(payload);
    return aggregation;
}
Also used : Action(com.redhat.cloud.notifications.ingress.Action) Event(com.redhat.cloud.notifications.ingress.Event) JsonObject(io.vertx.core.json.JsonObject) Payload(com.redhat.cloud.notifications.ingress.Payload) EmailAggregation(com.redhat.cloud.notifications.models.EmailAggregation)

Example 12 with Payload

use of com.redhat.cloud.notifications.ingress.Payload in project notifications-backend by RedHatInsights.

the class DriftTestHelpers method createEmailAggregation.

public static EmailAggregation createEmailAggregation(String tenant, String bundle, String application, String baselineId, String baselineName, String inventory_id, String inventory_name) {
    EmailAggregation aggregation = new EmailAggregation();
    aggregation.setBundleName(bundle);
    aggregation.setApplicationName(application);
    aggregation.setAccountId(tenant);
    Action emailActionMessage = new Action();
    emailActionMessage.setBundle(bundle);
    emailActionMessage.setApplication(application);
    emailActionMessage.setTimestamp(LocalDateTime.now());
    emailActionMessage.setEventType("testEmailSubscriptionInstant");
    emailActionMessage.setContext(new Context.ContextBuilder().withAdditionalProperty("inventory_id", inventory_id).withAdditionalProperty("system_check_in", "2021-07-13T15:22:42.199046").withAdditionalProperty("display_name", inventory_name).withAdditionalProperty("tags", List.of()).build());
    emailActionMessage.setEvents(List.of(new Event.EventBuilder().withMetadata(new Metadata.MetadataBuilder().build()).withPayload(new Payload.PayloadBuilder().withAdditionalProperty("baseline_id", baselineId).withAdditionalProperty("baseline_name", baselineName).build()).build()));
    emailActionMessage.setAccountId(tenant);
    JsonObject payload = baseTransformer.transform(emailActionMessage);
    aggregation.setPayload(payload);
    return aggregation;
}
Also used : Action(com.redhat.cloud.notifications.ingress.Action) Event(com.redhat.cloud.notifications.ingress.Event) JsonObject(io.vertx.core.json.JsonObject) Payload(com.redhat.cloud.notifications.ingress.Payload) EmailAggregation(com.redhat.cloud.notifications.models.EmailAggregation)

Aggregations

Payload (com.redhat.cloud.notifications.ingress.Payload)12 Action (com.redhat.cloud.notifications.ingress.Action)11 JsonObject (io.vertx.core.json.JsonObject)10 Event (com.redhat.cloud.notifications.ingress.Event)8 EmailAggregation (com.redhat.cloud.notifications.models.EmailAggregation)8 Context (com.redhat.cloud.notifications.ingress.Context)6 Event (com.redhat.cloud.notifications.models.Event)3 MockServerLifecycleManager (com.redhat.cloud.notifications.MockServerLifecycleManager)2 Metadata (com.redhat.cloud.notifications.ingress.Metadata)2 Endpoint (com.redhat.cloud.notifications.models.Endpoint)2 EndpointType (com.redhat.cloud.notifications.models.EndpointType)2 NotificationHistory (com.redhat.cloud.notifications.models.NotificationHistory)2 QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 JsonArray (io.vertx.core.json.JsonArray)2 LocalDateTime (java.time.LocalDateTime)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Inject (javax.inject.Inject)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)2 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)2