NotificationFactory.java

1
package com.reallifedeveloper.common.application.notification;
2
3
import java.util.List;
4
5
import com.reallifedeveloper.common.application.eventstore.EventStore;
6
import com.reallifedeveloper.common.application.eventstore.StoredEvent;
7
import com.reallifedeveloper.common.domain.ErrorHandling;
8
import com.reallifedeveloper.common.domain.event.DomainEvent;
9
10
/**
11
 * A factory for {@link Notification Notifications}.
12
 *
13
 * @author RealLifeDeveloper
14
 */
15
public final class NotificationFactory {
16
17
    private final EventStore eventStore;
18
19
    private NotificationFactory(EventStore eventStore) {
20 1 1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED
        ErrorHandling.checkNull("eventStore must not be null", eventStore);
21
        this.eventStore = eventStore;
22
    }
23
24
    /**
25
     * Gives an instance of the factory that uses the given {@link EventStore} to create {@link Notification Notifications}.
26
     *
27
     * @param eventStore the {@code EventStore} to use
28
     *
29
     * @return a {@code NotificationFactory} instance
30
     */
31
    public static NotificationFactory instance(EventStore eventStore) {
32 1 1. instance : replaced return value with null for com/reallifedeveloper/common/application/notification/NotificationFactory::instance → KILLED
        return new NotificationFactory(eventStore);
33
    }
34
35
    /**
36
     * Creates a new {@link Notification} for the given {@link StoredEvent}.
37
     *
38
     * @param storedEvent the stored event for which to create a {@code Notification}
39
     *
40
     * @return a new {@code Notification} for the stored event
41
     */
42
    public Notification fromStoredEvent(StoredEvent storedEvent) {
43
        DomainEvent domainEvent = eventStore.toDomainEvent(storedEvent);
44 1 1. fromStoredEvent : replaced return value with null for com/reallifedeveloper/common/application/notification/NotificationFactory::fromStoredEvent → KILLED
        return Notification.create(domainEvent, storedEvent.id());
45
    }
46
47
    /**
48
     * Creates new {@link Notification Notifications} for the given {@link StoredEvent StoredEvents}.
49
     *
50
     * @param storedEvents a list with the stored events for which to create {@code Notifications}
51
     *
52
     * @return a list of {@code Notifications} for the stored events
53
     */
54
    public List<Notification> fromStoredEvents(List<StoredEvent> storedEvents) {
55 1 1. fromStoredEvents : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED
        ErrorHandling.checkNull("storedEvents must not be null", storedEvents);
56 1 1. fromStoredEvents : replaced return value with Collections.emptyList for com/reallifedeveloper/common/application/notification/NotificationFactory::fromStoredEvents → KILLED
        return storedEvents.stream().map(this::fromStoredEvent).toList();
57
    }
58
}

Mutations

20

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

32

1.1
Location : instance
Killed by : com.reallifedeveloper.common.application.notification.NotificationFactoryTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationFactoryTest]/[method:fromStoreventWithNullEventShouldThrowException()]
replaced return value with null for com/reallifedeveloper/common/application/notification/NotificationFactory::instance → KILLED

44

1.1
Location : fromStoredEvent
Killed by : com.reallifedeveloper.common.application.notification.NotificationFactoryTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationFactoryTest]/[method:fromStoredEventWithSingleEventReturnsNotification()]
replaced return value with null for com/reallifedeveloper/common/application/notification/NotificationFactory::fromStoredEvent → KILLED

55

1.1
Location : fromStoredEvents
Killed by : com.reallifedeveloper.common.application.notification.NotificationFactoryTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationFactoryTest]/[method:fromStoredEventsWillNullListShouldThrowException()]
removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED

56

1.1
Location : fromStoredEvents
Killed by : com.reallifedeveloper.common.application.notification.NotificationFactoryTest.[engine:junit-jupiter]/[class:com.reallifedeveloper.common.application.notification.NotificationFactoryTest]/[method:fromStoredEventWithMultipleEventsReturnsAList()]
replaced return value with Collections.emptyList for com/reallifedeveloper/common/application/notification/NotificationFactory::fromStoredEvents → KILLED

Active mutators

Tests examined


Report generated by PIT 1.20.0