CreateEventService.java

1
package com.seshira.events.domain.services;
2
3
import com.seshira.events.domain.exception.BadInputException;
4
import com.seshira.events.domain.models.*;
5
import com.seshira.events.domain.services.models.CreateEventPayload;
6
import org.springframework.stereotype.Service;
7
8
import java.util.UUID;
9
10
@Service
11
public class CreateEventService {
12
13
    private void updateEventFromPayload(Event event, CreateEventPayload createEventPayload) {
14 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setName → SURVIVED
        event.setName(createEventPayload.name());
15 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setDescription → SURVIVED
        event.setDescription(createEventPayload.description());
16 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setStartDate → SURVIVED
        event.setStartDate(createEventPayload.startDate());
17 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setEndDate → SURVIVED
        event.setEndDate(createEventPayload.endDate());
18 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setLocationName → SURVIVED
        event.setLocationName(createEventPayload.locationName());
19 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setLocationAddress → SURVIVED
        event.setLocationAddress(createEventPayload.locationAddress());
20 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setOrganizerName → SURVIVED
        event.setOrganizerName(createEventPayload.organizerName());
21 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setOrganizerUrl → SURVIVED
        event.setOrganizerUrl(createEventPayload.organizerUrl());
22 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setUrl → SURVIVED
        event.setUrl(createEventPayload.url()); // link to the event page
23 1 1. updateEventFromPayload : removed call to com/seshira/events/domain/models/Event::setImage → SURVIVED
        event.setImage(createEventPayload.image()); // URL of an image
24
    }
25
26
    public EventSeries createEventSeries(CreateEventPayload createEventPayload, Event parent) {
27
        EventSeries event = new EventSeries(
28
                UUID.randomUUID(),
29
                createEventPayload.name()
30
        );
31 1 1. createEventSeries : removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
        updateEventFromPayload(event, createEventPayload);
32 1 1. createEventSeries : removed call to com/seshira/events/domain/models/EventSeries::setParentEvent → SURVIVED
        event.setParentEvent(parent);
33 1 1. createEventSeries : replaced return value with null for com/seshira/events/domain/services/CreateEventService::createEventSeries → KILLED
        return event;
34
    }
35
36
    public InterventionEducationEvent createIntervention(CreateEventPayload createEventPayload, Event parent) {
37 4 1. createIntervention : removed conditional - replaced equality check with false → KILLED
2. createIntervention : removed conditional - replaced equality check with false → KILLED
3. createIntervention : removed conditional - replaced equality check with true → KILLED
4. createIntervention : removed conditional - replaced equality check with true → KILLED
        boolean parentIsNullOrNotSession = parent == null || parent.getAdditionalType() != EventAdditionalType.SESSION;
38 2 1. createIntervention : removed conditional - replaced equality check with false → KILLED
2. createIntervention : removed conditional - replaced equality check with true → KILLED
        if (parentIsNullOrNotSession)
39
            throw new BadInputException("An intervention can only be a sub-event of a Session");
40
        InterventionEducationEvent event = new InterventionEducationEvent(UUID.randomUUID(), createEventPayload.name());
41 1 1. createIntervention : removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
        updateEventFromPayload(event, createEventPayload);
42 1 1. createIntervention : removed call to com/seshira/events/domain/models/InterventionEducationEvent::setParentEvent → KILLED
        event.setParentEvent(parent);
43 1 1. createIntervention : replaced return value with null for com/seshira/events/domain/services/CreateEventService::createIntervention → KILLED
        return event;
44
    }
45
46
    public SessionEducationEvent createSession(CreateEventPayload createEventPayload, Event parent) {
47 4 1. createSession : removed conditional - replaced equality check with true → KILLED
2. createSession : removed conditional - replaced equality check with true → KILLED
3. createSession : removed conditional - replaced equality check with false → KILLED
4. createSession : removed conditional - replaced equality check with false → KILLED
        boolean parentIsNullOrCongress = parent == null || parent.getAdditionalType() != EventAdditionalType.CONGRESS;
48 2 1. createSession : removed conditional - replaced equality check with false → KILLED
2. createSession : removed conditional - replaced equality check with true → KILLED
        if (parentIsNullOrCongress)
49
            throw new BadInputException("A session can only be a sub-event of a Congress");
50
        SessionEducationEvent event = new SessionEducationEvent(
51
                UUID.randomUUID(),
52
                createEventPayload.name()
53
        );
54 1 1. createSession : removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
        updateEventFromPayload(event, createEventPayload);
55 1 1. createSession : removed call to com/seshira/events/domain/models/SessionEducationEvent::setParentEvent → KILLED
        event.setParentEvent(parent);
56 1 1. createSession : replaced return value with null for com/seshira/events/domain/services/CreateEventService::createSession → KILLED
        return event;
57
    }
58
59
    public CongressEducationEvent createCongress(CreateEventPayload createEventPayload, Event parent) {
60 4 1. createCongress : removed conditional - replaced equality check with false → KILLED
2. createCongress : removed conditional - replaced equality check with true → KILLED
3. createCongress : removed conditional - replaced equality check with false → KILLED
4. createCongress : removed conditional - replaced equality check with true → KILLED
        boolean parentIsNotNullAndNotEventSeries = parent != null && parent.getAdditionalType() != EventAdditionalType.EVENT_SERIES;
61 2 1. createCongress : removed conditional - replaced equality check with false → KILLED
2. createCongress : removed conditional - replaced equality check with true → KILLED
        if (parentIsNotNullAndNotEventSeries)
62
            throw new BadInputException("A congress can only be a sub-event of an EventSeries");
63
        CongressEducationEvent event = new CongressEducationEvent(
64
                UUID.randomUUID(),
65
                createEventPayload.name());
66 1 1. createCongress : removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
        updateEventFromPayload(event, createEventPayload);
67 1 1. createCongress : removed call to com/seshira/events/domain/models/CongressEducationEvent::setParentEvent → SURVIVED
        event.setParentEvent(parent);
68 1 1. createCongress : replaced return value with null for com/seshira/events/domain/services/CreateEventService::createCongress → KILLED
        return event;
69
    }
70
71
    public Event createEvent(CreateEventPayload createEventPayload, Event parent) {
72
        Event event = new Event(
73
                UUID.randomUUID(),
74
                createEventPayload.name()
75
        );
76 1 1. createEvent : removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
        updateEventFromPayload(event, createEventPayload);
77 1 1. createEvent : removed call to com/seshira/events/domain/models/Event::setParentEvent → KILLED
        event.setParentEvent(parent);
78 1 1. createEvent : replaced return value with null for com/seshira/events/domain/services/CreateEventService::createEvent → KILLED
        return event;
79
    }
80
}

Mutations

14

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setName → SURVIVED
Covering tests

15

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setDescription → SURVIVED
Covering tests

16

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setStartDate → SURVIVED
Covering tests

17

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setEndDate → SURVIVED
Covering tests

18

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setLocationName → SURVIVED
Covering tests

19

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setLocationAddress → SURVIVED
Covering tests

20

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setOrganizerName → SURVIVED
Covering tests

21

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setOrganizerUrl → SURVIVED
Covering tests

22

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setUrl → SURVIVED
Covering tests

23

1.1
Location : updateEventFromPayload
Killed by : none
removed call to com/seshira/events/domain/models/Event::setImage → SURVIVED
Covering tests

31

1.1
Location : createEventSeries
Killed by : none
removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
Covering tests

32

1.1
Location : createEventSeries
Killed by : none
removed call to com/seshira/events/domain/models/EventSeries::setParentEvent → SURVIVED
Covering tests

33

1.1
Location : createEventSeries
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongressWithParent()]
replaced return value with null for com/seshira/events/domain/services/CreateEventService::createEventSeries → KILLED

37

1.1
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateIntervention()]
removed conditional - replaced equality check with false → KILLED

2.2
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateInterventionShallFailIfNoOrIncorrectParentType()]
removed conditional - replaced equality check with false → KILLED

3.3
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateIntervention()]
removed conditional - replaced equality check with true → KILLED

4.4
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateInterventionShallFailIfNoOrIncorrectParentType()]
removed conditional - replaced equality check with true → KILLED

38

1.1
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateInterventionShallFailIfNoOrIncorrectParentType()]
removed conditional - replaced equality check with false → KILLED

2.2
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateIntervention()]
removed conditional - replaced equality check with true → KILLED

41

1.1
Location : createIntervention
Killed by : none
removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
Covering tests

42

1.1
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateIntervention()]
removed call to com/seshira/events/domain/models/InterventionEducationEvent::setParentEvent → KILLED

43

1.1
Location : createIntervention
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:InterventionCanBeCreated]/[method:testCreateIntervention()]
replaced return value with null for com/seshira/events/domain/services/CreateEventService::createIntervention → KILLED

47

1.1
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSession()]
removed conditional - replaced equality check with true → KILLED

2.2
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSessionShallFailIfNoOrIncorrectParentType()]
removed conditional - replaced equality check with true → KILLED

3.3
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSession()]
removed conditional - replaced equality check with false → KILLED

4.4
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSessionShallFailIfNoOrIncorrectParentType()]
removed conditional - replaced equality check with false → KILLED

48

1.1
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSessionShallFailIfNoOrIncorrectParentType()]
removed conditional - replaced equality check with false → KILLED

2.2
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSession()]
removed conditional - replaced equality check with true → KILLED

54

1.1
Location : createSession
Killed by : none
removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
Covering tests

55

1.1
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSession()]
removed call to com/seshira/events/domain/models/SessionEducationEvent::setParentEvent → KILLED

56

1.1
Location : createSession
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:SessionCanBeCreated]/[method:testCreateSession()]
replaced return value with null for com/seshira/events/domain/services/CreateEventService::createSession → KILLED

60

1.1
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongressWithParent()]
removed conditional - replaced equality check with false → KILLED

2.2
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongressWithParent()]
removed conditional - replaced equality check with true → KILLED

3.3
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongressWithParent()]
removed conditional - replaced equality check with false → KILLED

4.4
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongress()]
removed conditional - replaced equality check with true → KILLED

61

1.1
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongressWithParent()]
removed conditional - replaced equality check with false → KILLED

2.2
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongress()]
removed conditional - replaced equality check with true → KILLED

66

1.1
Location : createCongress
Killed by : none
removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
Covering tests

67

1.1
Location : createCongress
Killed by : none
removed call to com/seshira/events/domain/models/CongressEducationEvent::setParentEvent → SURVIVED
Covering tests

68

1.1
Location : createCongress
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:CongressCanBeCreated]/[method:testCreateCongress()]
replaced return value with null for com/seshira/events/domain/services/CreateEventService::createCongress → KILLED

76

1.1
Location : createEvent
Killed by : none
removed call to com/seshira/events/domain/services/CreateEventService::updateEventFromPayload → SURVIVED
Covering tests

77

1.1
Location : createEvent
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:EventCanBeCreated]/[method:testCreateEventWithParent()]
removed call to com/seshira/events/domain/models/Event::setParentEvent → KILLED

78

1.1
Location : createEvent
Killed by : com.seshira.events.application.services.CreateEventServiceTest.[engine:junit-jupiter]/[class:com.seshira.events.application.services.CreateEventServiceTest]/[nested-class:EventCanBeCreated]/[method:testCreateEvent()]
replaced return value with null for com/seshira/events/domain/services/CreateEventService::createEvent → KILLED

Active mutators

Tests examined


Report generated by PIT 1.21.0