| 1 | package fr.sii.ogham.testing.sms.simulator.cloudhopper; | |
| 2 | ||
| 3 | import java.util.HashSet; | |
| 4 | import java.util.Set; | |
| 5 | ||
| 6 | import com.cloudhopper.smpp.SmppConstants; | |
| 7 | import com.cloudhopper.smpp.SmppServerHandler; | |
| 8 | import com.cloudhopper.smpp.SmppServerSession; | |
| 9 | import com.cloudhopper.smpp.SmppSessionConfiguration; | |
| 10 | import com.cloudhopper.smpp.impl.PollableSmppSessionHandler; | |
| 11 | import com.cloudhopper.smpp.pdu.BaseBind; | |
| 12 | import com.cloudhopper.smpp.pdu.BaseBindResp; | |
| 13 | import com.cloudhopper.smpp.type.SmppProcessingException; | |
| 14 | ||
| 15 | public class TestSmppServerHandler implements SmppServerHandler { | |
| 16 | private Set<SmppServerSession> sessions = new HashSet<>(); | |
| 17 | private PollableSmppSessionHandler sessionHandler = new PollableSmppSessionHandler(); | |
| 18 | ||
| 19 | private String systemId; | |
| 20 | private String password; | |
| 21 | ||
| 22 | public TestSmppServerHandler(String systemId, String password) { | |
| 23 | super(); | |
| 24 | this.systemId = systemId; | |
| 25 | this.password = password; | |
| 26 | } | |
| 27 | ||
| 28 | @Override | |
| 29 | @SuppressWarnings("rawtypes") | |
| 30 | public void sessionBindRequested(Long sessionId, SmppSessionConfiguration sessionConfiguration, final BaseBind bindRequest) throws SmppProcessingException { | |
| 31 | // test name change of sessions | |
| 32 |
1
1. sessionBindRequested : removed call to com/cloudhopper/smpp/SmppSessionConfiguration::setName → NO_COVERAGE |
sessionConfiguration.setName("Test1"); |
| 33 | ||
| 34 |
1
1. sessionBindRequested : negated conditional → NO_COVERAGE |
if (!systemId.equals(bindRequest.getSystemId())) { |
| 35 | throw new SmppProcessingException(SmppConstants.STATUS_INVSYSID); | |
| 36 | } | |
| 37 | ||
| 38 |
1
1. sessionBindRequested : negated conditional → NO_COVERAGE |
if (!password.equals(bindRequest.getPassword())) { |
| 39 | throw new SmppProcessingException(SmppConstants.STATUS_INVPASWD); | |
| 40 | } | |
| 41 | } | |
| 42 | ||
| 43 | @Override | |
| 44 | public void sessionCreated(Long sessionId, SmppServerSession session, BaseBindResp preparedBindResponse) { | |
| 45 | sessions.add(session); | |
| 46 | // need to do something it now (flag we're ready) | |
| 47 |
1
1. sessionCreated : removed call to com/cloudhopper/smpp/SmppServerSession::serverReady → NO_COVERAGE |
session.serverReady(sessionHandler); |
| 48 | } | |
| 49 | ||
| 50 | @Override | |
| 51 | public void sessionDestroyed(Long sessionId, SmppServerSession session) { | |
| 52 | sessions.remove(session); | |
| 53 | } | |
| 54 | ||
| 55 | public Set<SmppServerSession> getSessions() { | |
| 56 |
1
1. getSessions : replaced return value with Collections.emptyList for fr/sii/ogham/testing/sms/simulator/cloudhopper/TestSmppServerHandler::getSessions → NO_COVERAGE |
return sessions; |
| 57 | } | |
| 58 | ||
| 59 | public PollableSmppSessionHandler getSessionHandler() { | |
| 60 |
1
1. getSessionHandler : replaced return value with null for fr/sii/ogham/testing/sms/simulator/cloudhopper/TestSmppServerHandler::getSessionHandler → NO_COVERAGE |
return sessionHandler; |
| 61 | } | |
| 62 | ||
| 63 | public String getSystemId() { | |
| 64 |
1
1. getSystemId : replaced return value with "" for fr/sii/ogham/testing/sms/simulator/cloudhopper/TestSmppServerHandler::getSystemId → NO_COVERAGE |
return systemId; |
| 65 | } | |
| 66 | ||
| 67 | public String getPassword() { | |
| 68 |
1
1. getPassword : replaced return value with "" for fr/sii/ogham/testing/sms/simulator/cloudhopper/TestSmppServerHandler::getPassword → NO_COVERAGE |
return password; |
| 69 | } | |
| 70 | } | |
Mutations | ||
| 32 |
1.1 |
|
| 34 |
1.1 |
|
| 38 |
1.1 |
|
| 47 |
1.1 |
|
| 56 |
1.1 |
|
| 60 |
1.1 |
|
| 64 |
1.1 |
|
| 68 |
1.1 |