WaitBindTask.java

1
package fr.sii.ogham.testing.sms.simulator.jsmpp;
2
3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Objects;
6
import java.util.concurrent.TimeoutException;
7
8
import ogham.testing.org.jsmpp.PDUStringException;
9
import ogham.testing.org.jsmpp.SMPPConstant;
10
import ogham.testing.org.jsmpp.bean.InterfaceVersion;
11
import ogham.testing.org.jsmpp.session.BindRequest;
12
import ogham.testing.org.jsmpp.session.SMPPServerSession;
13
import org.slf4j.Logger;
14
import org.slf4j.LoggerFactory;
15
16
import fr.sii.ogham.testing.sms.simulator.config.Credentials;
17
18
class WaitBindTask implements Runnable {
19
	private static final int WAIT_DURATION = 1000;
20
21
	private static final Logger LOG = LoggerFactory.getLogger(WaitBindTask.class);
22
23
	private final SMPPServerSession serverSession;
24
	private final List<Credentials> serverCredentials;
25
26
	public WaitBindTask(SMPPServerSession serverSession, List<Credentials> serverCredentials) {
27
		this.serverSession = serverSession;
28
		this.serverCredentials = serverCredentials;
29
	}
30
31
	public void run() {
32
		try {
33
			BindRequest bindRequest = serverSession.waitForBind(WAIT_DURATION);
34
			LOG.info("Accepting bind for session {}, interface version {}", serverSession.getSessionId(), InterfaceVersion.IF_34);
35 1 1. run : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::bind → NO_COVERAGE
			bind(bindRequest);
36
		} catch (IllegalStateException e) {
37
			LOG.error("System error", e);
38
		} catch (TimeoutException e) {
39
			LOG.warn("Wait for bind has reach timeout", e);
40
		} catch (IOException e) {
41
			LOG.error("Failed accepting bind request for session {}", serverSession.getSessionId(), e);
42
		}
43
	}
44
45
	private void bind(BindRequest bindRequest) throws IOException {
46
		try {
47 1 1. bind : negated conditional → NO_COVERAGE
			if (checkPassword(bindRequest)) {
48 1 1. bind : removed call to ogham/testing/org/jsmpp/session/BindRequest::accept → NO_COVERAGE
				bindRequest.accept(bindRequest.getSystemId(), InterfaceVersion.IF_34);
49
			} else {
50 1 1. bind : removed call to ogham/testing/org/jsmpp/session/BindRequest::reject → NO_COVERAGE
				bindRequest.reject(SMPPConstant.STAT_ESME_RINVPASWD);
51
			}
52
		} catch (PDUStringException e) {
53
			LOG.error("Invalid system id", e);
54 1 1. bind : removed call to ogham/testing/org/jsmpp/session/BindRequest::reject → NO_COVERAGE
			bindRequest.reject(SMPPConstant.STAT_ESME_RSYSERR);
55
		}
56
	}
57
58
	private boolean checkPassword(BindRequest bindRequest) {
59
		// no credentials registered => allow requests
60 2 1. checkPassword : negated conditional → NO_COVERAGE
2. checkPassword : negated conditional → NO_COVERAGE
		if (serverCredentials == null || serverCredentials.isEmpty()) {
61 1 1. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE
			return true;
62
		}
63
		for (Credentials creds : serverCredentials) {
64 2 1. checkPassword : negated conditional → NO_COVERAGE
2. checkPassword : negated conditional → NO_COVERAGE
			if (Objects.equals(creds.getSystemId(), bindRequest.getSystemId()) && Objects.equals(creds.getPassword(), bindRequest.getPassword())) {
65 1 1. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE
				return true;
66
			}
67
		}
68 1 1. checkPassword : replaced boolean return with true for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE
		return false;
69
	}
70
}

Mutations

35

1.1
Location : run
Killed by :
removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::bind → NO_COVERAGE

47

1.1
Location : bind
Killed by :
negated conditional → NO_COVERAGE

48

1.1
Location : bind
Killed by :
removed call to ogham/testing/org/jsmpp/session/BindRequest::accept → NO_COVERAGE

50

1.1
Location : bind
Killed by :
removed call to ogham/testing/org/jsmpp/session/BindRequest::reject → NO_COVERAGE

54

1.1
Location : bind
Killed by :
removed call to ogham/testing/org/jsmpp/session/BindRequest::reject → NO_COVERAGE

60

1.1
Location : checkPassword
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : checkPassword
Killed by :
negated conditional → NO_COVERAGE

61

1.1
Location : checkPassword
Killed by :
replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE

64

1.1
Location : checkPassword
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : checkPassword
Killed by :
negated conditional → NO_COVERAGE

65

1.1
Location : checkPassword
Killed by :
replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE

68

1.1
Location : checkPassword
Killed by :
replaced boolean return with true for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1