PublishedMessageTracker.java

1
package com.reallifedeveloper.common.application.notification;
2
3
import jakarta.persistence.Column;
4
import jakarta.persistence.Entity;
5
import jakarta.persistence.Table;
6
7
import com.reallifedeveloper.common.domain.ErrorHandling;
8
import com.reallifedeveloper.common.infrastructure.persistence.BaseJpaEntity;
9
10
/**
11
 * Keeps track of the most recently published message on a certain publication channel.
12
 * <p>
13
 * The publication channel can, for example, be an exchange in a messaging system.
14
 *
15
 * @author RealLifeDeveloper
16
 */
17
@Entity
18
@Table(name = "message_tracker")
19
public class PublishedMessageTracker extends BaseJpaEntity<Long> {
20
21
    @Column(name = "last_published_message_id", nullable = false, unique = false)
22
    private Long lastPublishedMessageId;
23
24
    @Column(name = "publication_channel", nullable = false, unique = true)
25
    private String publicationChannel;
26
27
    /**
28
     * Creates a new {@code PublishedMessageTracker} with the id of the most recently published message on the given publication channel.
29
     *
30
     * @param lastPublishedMessageId the id of the most recently published message on the publication channel
31
     * @param publicationChannel     the name of the publication channel, e.g., the name of an exchange in a messaging system
32
     */
33
    public PublishedMessageTracker(long lastPublishedMessageId, String publicationChannel) {
34 1 1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → SURVIVED
        ErrorHandling.checkNull("publicationChannel must not be null", publicationChannel);
35
        this.lastPublishedMessageId = lastPublishedMessageId;
36
        this.publicationChannel = publicationChannel;
37
    }
38
39
    /* package-private */
40
    /**
41
     * Required by JPA.
42
     */
43
    @SuppressWarnings("NullAway")
44
    PublishedMessageTracker() {
45
        super();
46
    }
47
48
    /**
49
     * Gives the id of the most recently published message on the publication channel associated with this {@code PublishedMessageTracker}.
50
     *
51
     * @return the id of the most recently published message
52
     */
53
    public Long lastPublishedMessageId() {
54 1 1. lastPublishedMessageId : replaced Long return value with 0L for com/reallifedeveloper/common/application/notification/PublishedMessageTracker::lastPublishedMessageId → KILLED
        return lastPublishedMessageId;
55
    }
56
57
    /**
58
     * Sets the id of the most recently published message on the publication channel associated with this {@code PublishedMessageTracker}.
59
     *
60
     * @param newLastPublishedMessageId the new id of the most recently published message
61
     */
62
    public void setLastPublishedMessageid(long newLastPublishedMessageId) {
63
        this.lastPublishedMessageId = newLastPublishedMessageId;
64
    }
65
66
    /**
67
     * Gives the name of the publication channel for this {@code PublishedMessageTracker}.
68
     *
69
     * @return the name of the publication channel
70
     */
71
    public String publicationChannel() {
72 1 1. publicationChannel : replaced return value with "" for com/reallifedeveloper/common/application/notification/PublishedMessageTracker::publicationChannel → KILLED
        return publicationChannel;
73
    }
74
75
}

Mutations

34

1.1
Location : <init>
Killed by : none
removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → SURVIVED
Covering tests

54

1.1
Location : lastPublishedMessageId
Killed by : com.reallifedeveloper.common.application.notification.NotificationServiceTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationServiceTest]/[method:publishSameNotificationsTwice()]
replaced Long return value with 0L for com/reallifedeveloper/common/application/notification/PublishedMessageTracker::lastPublishedMessageId → KILLED

72

1.1
Location : publicationChannel
Killed by : com.reallifedeveloper.common.infrastructure.persistence.JpaPublishedMessageTrackerRepositoryIT.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.infrastructure.persistence.JpaPublishedMessageTrackerRepositoryIT]/[method:save()]
replaced return value with "" for com/reallifedeveloper/common/application/notification/PublishedMessageTracker::publicationChannel → KILLED

Active mutators

Tests examined


Report generated by PIT 1.20.2