NotificationRepresentation.java

1
package com.reallifedeveloper.common.resource.notification;
2
3
import java.time.ZonedDateTime;
4
5
import org.checkerframework.checker.nullness.qual.Nullable;
6
7
import com.fasterxml.jackson.annotation.JsonRawValue;
8
import jakarta.xml.bind.annotation.XmlAccessType;
9
import jakarta.xml.bind.annotation.XmlAccessorType;
10
import jakarta.xml.bind.annotation.XmlElement;
11
import jakarta.xml.bind.annotation.XmlRootElement;
12
13
import com.reallifedeveloper.common.application.notification.Notification;
14
import com.reallifedeveloper.common.domain.ErrorHandling;
15
import com.reallifedeveloper.common.domain.ObjectSerializer;
16
17
/**
18
 * A REST-ful representation of a {@link Notification}.
19
 *
20
 * @author RealLifeDeveloper
21
 */
22
@XmlRootElement(name = "Notification")
23
@XmlAccessorType(XmlAccessType.FIELD)
24
public final class NotificationRepresentation {
25
26
    @XmlElement(name = "eventType")
27
    private @Nullable String eventType;
28
29
    @XmlElement(name = "storedEventId")
30
    private long storedEventId;
31
32
    @XmlElement(name = "occurredOn")
33
    private @Nullable ZonedDateTime occurredOn;
34
35
    @XmlElement(name = "event")
36
    @JsonRawValue
37
    private @Nullable String event;
38
39
    /**
40
     * Creates a new {@code NotificationRepresentation} representing the given {@link Notification}, and using the given
41
     * {@link ObjectSerializer} to serialize the domain event.
42
     *
43
     * @param notification     the notification to represent
44
     * @param objectSerializer the object serializer to use to serialize the domain event
45
     */
46
    public NotificationRepresentation(Notification notification, ObjectSerializer<String> objectSerializer) {
47 1 1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED
        ErrorHandling.checkNull("Arguments must not be null: notification=%s, objectSerializer=%s", notification, objectSerializer);
48
        this.eventType = notification.eventType();
49
        this.storedEventId = notification.storedEventId();
50
        this.occurredOn = notification.occurredOn();
51
        this.event = objectSerializer.serialize(notification.event());
52
    }
53
54
    /**
55
     * Required by JAXB.
56
     */
57
    /* package-private */ NotificationRepresentation() {
58
        super();
59
    }
60
61
    /**
62
     * Gives the name of the domain event class.
63
     *
64
     * @return the name of the domain event class
65
     */
66
    public @Nullable String getEventType() {
67 1 1. getEventType : replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getEventType → KILLED
        return eventType;
68
    }
69
70
    /**
71
     * Gives the ID of the stored event represented by the notification.
72
     *
73
     * @return the ID of the stored event represented by the notification
74
     */
75
    public long getStoredEventId() {
76 1 1. getStoredEventId : replaced long return with 0 for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getStoredEventId → KILLED
        return storedEventId;
77
    }
78
79
    /**
80
     * Gives the date and time the domain event occurred.
81
     *
82
     * @return the date and time the domain event occurred
83
     */
84
    public @Nullable ZonedDateTime getOccurredOn() {
85 1 1. getOccurredOn : replaced return value with null for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getOccurredOn → KILLED
        return occurredOn;
86
    }
87
88
    /**
89
     * Gives the serialized form of the domain event.
90
     * <p>
91
     * Note that this form depends only on which {@link ObjectSerializer} is being used, and not on how this
92
     * {@code NotificationRepresentation} is serialized. For example, if a JSON object serializer is used, the event will be serialized as a
93
     * JSON string, even if the representation is serialized as XML.
94
     *
95
     * @return the serialized form of the domain event
96
     */
97
    public @Nullable String getEvent() {
98 1 1. getEvent : replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getEvent → KILLED
        return event;
99
    }
100
101
}

Mutations

47

1.1
Location : <init>
Killed by : com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:constructorNullNotification()]
removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED

67

1.1
Location : getEventType
Killed by : com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:packagePrivateConstructorLeavesAllFieldsWithDefaultValues()]
replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getEventType → KILLED

76

1.1
Location : getStoredEventId
Killed by : com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:constructor()]
replaced long return with 0 for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getStoredEventId → KILLED

85

1.1
Location : getOccurredOn
Killed by : com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:constructor()]
replaced return value with null for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getOccurredOn → KILLED

98

1.1
Location : getEvent
Killed by : com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.resource.notification.NotificationRepresentationTest]/[method:packagePrivateConstructorLeavesAllFieldsWithDefaultValues()]
replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationRepresentation::getEvent → KILLED

Active mutators

Tests examined


Report generated by PIT 1.20.0