| 1 | package fr.sii.ogham.testing.sms.simulator.cloudhopper; | |
| 2 | ||
| 3 | import java.util.ArrayList; | |
| 4 | import java.util.List; | |
| 5 | ||
| 6 | import com.cloudhopper.smpp.SmppServerConfiguration; | |
| 7 | import com.cloudhopper.smpp.SmppServerHandler; | |
| 8 | import com.cloudhopper.smpp.impl.DefaultSmppServer; | |
| 9 | import com.cloudhopper.smpp.pdu.PduRequest; | |
| 10 | import com.cloudhopper.smpp.type.SmppChannelException; | |
| 11 | ||
| 12 | import fr.sii.ogham.testing.sms.simulator.SmppServerException; | |
| 13 | import fr.sii.ogham.testing.sms.simulator.SmppServerSimulator; | |
| 14 | ||
| 15 | @SuppressWarnings({"rawtypes", "java:S3740"}) | |
| 16 | public class CloudhopperSMPPServer implements SmppServerSimulator<PduRequest> { | |
| 17 | private DefaultSmppServer server; | |
| 18 | private TestSmppServerHandler serverHandler; | |
| 19 | | |
| 20 | protected CloudhopperSMPPServer(int port, TestSmppServerHandler serverHandler) { | |
| 21 | super(); | |
| 22 | this.server = createSmppServer(port, serverHandler); | |
| 23 | this.serverHandler = serverHandler; | |
| 24 | } | |
| 25 | | |
| 26 | public CloudhopperSMPPServer(int port, String systemId, String password) { | |
| 27 | this(port, new TestSmppServerHandler(systemId, password)); | |
| 28 | } | |
| 29 | ||
| 30 | public CloudhopperSMPPServer(int port) { | |
| 31 | this(port, "systemId", "password"); | |
| 32 | } | |
| 33 | ||
| 34 | @Override | |
| 35 | public void start() throws SmppServerException { | |
| 36 | try { | |
| 37 |
1
1. start : removed call to com/cloudhopper/smpp/impl/DefaultSmppServer::start → NO_COVERAGE |
server.start(); |
| 38 | } catch (SmppChannelException e) { | |
| 39 | throw new SmppServerException("failed to start SMPP server", e); | |
| 40 | } | |
| 41 | } | |
| 42 | ||
| 43 | @Override | |
| 44 | public void stop() { | |
| 45 |
1
1. stop : removed call to com/cloudhopper/smpp/impl/DefaultSmppServer::destroy → NO_COVERAGE |
server.destroy(); |
| 46 | } | |
| 47 | ||
| 48 | @Override | |
| 49 | public int getPort() { | |
| 50 |
1
1. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/cloudhopper/CloudhopperSMPPServer::getPort → NO_COVERAGE |
return server.getConfiguration().getPort(); |
| 51 | } | |
| 52 | ||
| 53 | @Override | |
| 54 | public List<PduRequest> getReceivedMessages() { | |
| 55 |
1
1. getReceivedMessages : replaced return value with Collections.emptyList for fr/sii/ogham/testing/sms/simulator/cloudhopper/CloudhopperSMPPServer::getReceivedMessages → NO_COVERAGE |
return new ArrayList<>(serverHandler.getSessionHandler().getReceivedPduRequests()); |
| 56 | } | |
| 57 | | |
| 58 | private static SmppServerConfiguration createSmppServerConfiguration(int port) { | |
| 59 | SmppServerConfiguration configuration = new SmppServerConfiguration(); | |
| 60 |
1
1. createSmppServerConfiguration : removed call to com/cloudhopper/smpp/SmppServerConfiguration::setPort → NO_COVERAGE |
configuration.setPort(port); |
| 61 |
1
1. createSmppServerConfiguration : removed call to com/cloudhopper/smpp/SmppServerConfiguration::setSystemId → NO_COVERAGE |
configuration.setSystemId("cloudhopper"); |
| 62 |
1
1. createSmppServerConfiguration : replaced return value with null for fr/sii/ogham/testing/sms/simulator/cloudhopper/CloudhopperSMPPServer::createSmppServerConfiguration → NO_COVERAGE |
return configuration; |
| 63 | } | |
| 64 | ||
| 65 | private static DefaultSmppServer createSmppServer(int port, SmppServerHandler serverHandler) { | |
| 66 | SmppServerConfiguration configuration = createSmppServerConfiguration(port); | |
| 67 |
1
1. createSmppServer : replaced return value with null for fr/sii/ogham/testing/sms/simulator/cloudhopper/CloudhopperSMPPServer::createSmppServer → NO_COVERAGE |
return new DefaultSmppServer(configuration, serverHandler); |
| 68 | } | |
| 69 | ||
| 70 | } | |
Mutations | ||
| 37 |
1.1 |
|
| 45 |
1.1 |
|
| 50 |
1.1 |
|
| 55 |
1.1 |
|
| 60 |
1.1 |
|
| 61 |
1.1 |
|
| 62 |
1.1 |
|
| 67 |
1.1 |