|
1
|
|
package com.reallifedeveloper.common.application.notification; |
|
2
|
|
|
|
3
|
|
import java.time.ZonedDateTime; |
|
4
|
|
|
|
5
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
6
|
|
|
|
7
|
|
import com.reallifedeveloper.common.domain.ErrorHandling; |
|
8
|
|
import com.reallifedeveloper.common.domain.event.DomainEvent; |
|
9
|
|
|
|
10
|
|
/** |
|
11
|
|
* A notification is information about a domain event that has occurred, and that has been stored in an |
|
12
|
|
* {@link com.reallifedeveloper.common.application.eventstore.EventStore}. The notification can be sent to external systems that need to be |
|
13
|
|
* informed about the event. |
|
14
|
|
* |
|
15
|
|
* @param eventType the type of the event |
|
16
|
|
* @param storedEventId the stored event ID, must not be {@code null} |
|
17
|
|
* @param occurredOn the timestamp the event occurred |
|
18
|
|
* @param event the domain event that occurred, must not be {@code null} |
|
19
|
|
* |
|
20
|
|
* @author RealLifeDeveloper |
|
21
|
|
*/ |
|
22
|
|
public record Notification(@Nullable String eventType, Long storedEventId, @Nullable ZonedDateTime occurredOn, DomainEvent event) { |
|
23
|
|
|
|
24
|
|
/** |
|
25
|
|
* Creates a new {@code Notification}. |
|
26
|
|
*/ |
|
27
|
|
public Notification { |
|
28
|
1
1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → SURVIVED
|
ErrorHandling.checkNull("Arguments must not be null: event=%s, storedEventId=%s", event, storedEventId); |
|
29
|
|
} |
|
30
|
|
|
|
31
|
|
/** |
|
32
|
|
* A factory method that sets the {@code eventType} to the name of the event class and {@code occurredOn} to the date and time when the |
|
33
|
|
* event occurred. |
|
34
|
|
* |
|
35
|
|
* @param event the event to store and use to set {@code eventType} and {@code occurredOn} |
|
36
|
|
* @param storedEventId the stored event ID to store |
|
37
|
|
* |
|
38
|
|
* @return a new {@code Notification} |
|
39
|
|
* |
|
40
|
|
* @throws IllegalArgumentException if {@code event} or {@code storedEventId} is {@code null} |
|
41
|
|
*/ |
|
42
|
|
public static Notification create(DomainEvent event, Long storedEventId) { |
|
43
|
1
1. create : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED
|
ErrorHandling.checkNull("Arguments must not be null: event=%s, storedEventId=%s", event, storedEventId); |
|
44
|
1
1. create : replaced return value with null for com/reallifedeveloper/common/application/notification/Notification::create → KILLED
|
return new Notification(event.getClass().getName(), storedEventId, event.eventOccurredOn(), event); |
|
45
|
|
} |
|
46
|
|
|
|
47
|
|
} |
| | Mutations |
| 28 |
|
1.1 Location : <init> Killed by : none removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → SURVIVED
Covering tests
Covered by tests:
- com.reallifedeveloper.common.application.notification.NotificationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationTest]/[method:createEventWithNullOccurredOn()]
- com.reallifedeveloper.common.application.notification.NotificationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationTest]/[method:create()]
- com.reallifedeveloper.common.application.notification.NotificationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationTest]/[method:testToString()]
- com.reallifedeveloper.common.application.notification.NotificationLogTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationLogTest]/[method:constructorDefensiveCopyOfNotifications()]
- com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:constructorEventWithNullOccurredOn()]
- com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:constructorNullSerializer()]
- com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:constructor()]
- com.reallifedeveloper.common.infrastructure.GsonObjectSerializerTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.GsonObjectSerializerTest]/[method:serializeAndDeserializeNotification()]
- com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest]/[method:publishNotificationsShouldThrowIOExceptionIfConnectionTimesOut()]
- com.reallifedeveloper.common.infrastructure.messaging.KafkaNotificationPublisherTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.messaging.KafkaNotificationPublisherTest]/[method:verifyLogging()]
- com.reallifedeveloper.common.infrastructure.messaging.KafkaNotificationPublisherTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.messaging.KafkaNotificationPublisherTest]/[method:publishingNotificationShouldCallKafkaTemplateSend()]
- com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest]/[method:publishNotificationsShouldCallChannelBasicPublish()]
- com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest]/[method:verifyLogging()]
- com.reallifedeveloper.common.application.notification.NotificationFactoryTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationFactoryTest]/[method:fromStoredEventWithSingleEventReturnsNotification()]
- com.reallifedeveloper.common.application.notification.NotificationFactoryTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationFactoryTest]/[method:fromStoredEventWithMultipleEventsReturnsAList()]
- com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:publishSameNotificationsTwice()]
- com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:publishNotifications()]
- com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:publishNotificationsTwiceWithSomeNewEvents()]
- com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:currentNotificationLogFullBatch()]
- com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:currentNotificationLog()]
- com.reallifedeveloper.common.infrastructure.GsonNotificationReaderTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.GsonNotificationReaderTest]/[method:realNotification()]
- com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:notificationLog()]
- com.reallifedeveloper.common.resource.notification.NotificationResourceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationResourceTest]/[method:getCurrentNotificationLogFullBatchPlusOne()]
- com.reallifedeveloper.common.resource.notification.NotificationResourceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationResourceTest]/[method:getCurrentNotificationLogFullBatch()]
- com.reallifedeveloper.common.resource.notification.NotificationResourceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationResourceTest]/[method:getNotificationLog()]
- com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.messaging.RabbitMQNotificationPublisherTest]/[method:publishNotificationsShouldThrowOriginalExceptionIfBasicPublishFails()]
|
| 43 |
|
1.1 Location : create Killed by : com.reallifedeveloper.common.application.notification.NotificationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationTest]/[method:createNullEvent()] removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED
|
| 44 |
|
1.1 Location : create Killed by : com.reallifedeveloper.common.application.notification.NotificationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationTest]/[method:createEventWithNullOccurredOn()] replaced return value with null for com/reallifedeveloper/common/application/notification/Notification::create → KILLED
|