AbstractJUnitSmppServerExt.java

1
package fr.sii.ogham.testing.extension.junit.sms;
2
3
import static java.util.stream.Collectors.toList;
4
5
import java.util.Collections;
6
import java.util.List;
7
8
import org.junit.jupiter.api.extension.Extension;
9
10
import fr.sii.ogham.testing.extension.junit.sms.config.ServerConfig;
11
import fr.sii.ogham.testing.sms.simulator.SmppServerSimulator;
12
import fr.sii.ogham.testing.sms.simulator.bean.SubmitSm;
13
import fr.sii.ogham.testing.sms.simulator.config.SimulatorConfiguration;
14
15
/**
16
 * Base class for JUnit Rule and JUnit {@link Extension}.
17
 * 
18
 * @author Aurélien Baudet
19
 *
20
 * @param <M>
21
 *            The type of the received messages
22
 */
23
public abstract class AbstractJUnitSmppServerExt<M> {
24
25
	/**
26
	 * The configuration to control how server should behave
27
	 */
28
	protected final ServerConfig builder;
29
	/**
30
	 * The server simulator
31
	 */
32
	protected SmppServerSimulator<M> server;
33
34
	/**
35
	 * Initializes with the default configuration to use for the SMPP server
36
	 * 
37
	 */
38
	public AbstractJUnitSmppServerExt() {
39
		this(new ServerConfig());
40
	}
41
42
	/**
43
	 * Initializes with the configuration to use for the SMPP server
44
	 * 
45
	 * @param builder
46
	 *            the configuration for the server
47
	 */
48
	public AbstractJUnitSmppServerExt(ServerConfig builder) {
49
		super();
50
		this.builder = builder;
51
	}
52
53
	/**
54
	 * Get the port used by the server.
55
	 * 
56
	 * @return the port used by the server
57
	 */
58
	public int getPort() {
59 1 1. getPort : replaced int return with 0 for fr/sii/ogham/testing/extension/junit/sms/AbstractJUnitSmppServerExt::getPort → RUN_ERROR
		return server.getPort();
60
	}
61
62
	/**
63
	 * Provide the list of received messages during the execution of the test.
64
	 * 
65
	 * @return the list of received messages
66
	 */
67
	public List<M> getRawMessages() {
68 1 1. getRawMessages : negated conditional → NO_COVERAGE
		if (server == null) {
69
			return Collections.emptyList();
70
		}
71 1 1. getRawMessages : replaced return value with Collections.emptyList for fr/sii/ogham/testing/extension/junit/sms/AbstractJUnitSmppServerExt::getRawMessages → NO_COVERAGE
		return server.getReceivedMessages();
72
	}
73
74
	/**
75
	 * Provide the list of received messages during the execution of the test.
76
	 * 
77
	 * The raw messages are converted to the common interface
78
	 * ({@link SubmitSm}).
79
	 * 
80
	 * @return the list of received messages
81
	 */
82
	public List<SubmitSm> getReceivedMessages() {
83 1 1. getReceivedMessages : replaced return value with Collections.emptyList for fr/sii/ogham/testing/extension/junit/sms/AbstractJUnitSmppServerExt::getReceivedMessages → NO_COVERAGE
		return getRawMessages().stream().map(this::convert).collect(toList());
84
	}
85
86
	/**
87
	 * Initialize the server with the ready to use configuration.
88
	 * 
89
	 * @param simulatorConfiguration
90
	 *            the configuration to apply to the server
91
	 * @return the server instance
92
	 */
93
	protected abstract SmppServerSimulator<M> initServer(SimulatorConfiguration simulatorConfiguration);
94
95
	protected abstract SubmitSm convert(M raw);
96
97
}

Mutations

59

1.1
Location : getPort
Killed by :
replaced int return with 0 for fr/sii/ogham/testing/extension/junit/sms/AbstractJUnitSmppServerExt::getPort → RUN_ERROR

68

1.1
Location : getRawMessages
Killed by :
negated conditional → NO_COVERAGE

71

1.1
Location : getRawMessages
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/testing/extension/junit/sms/AbstractJUnitSmppServerExt::getRawMessages → NO_COVERAGE

83

1.1
Location : getReceivedMessages
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/testing/extension/junit/sms/AbstractJUnitSmppServerExt::getReceivedMessages → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1