CloudhopperUserDataAssertions.java

1
package fr.sii.ogham.testing.assertion.internal;
2
3
import static org.apache.commons.lang3.reflect.FieldUtils.readField;
4
import static org.hamcrest.MatcherAssert.assertThat;
5
6
import org.hamcrest.Matcher;
7
8
import fr.sii.ogham.sms.sender.impl.CloudhopperSMPPSender;
9
import fr.sii.ogham.sms.sender.impl.cloudhopper.preparator.MessagePreparator;
10
import fr.sii.ogham.sms.sender.impl.cloudhopper.preparator.ShortMessagePreparator;
11
import fr.sii.ogham.sms.sender.impl.cloudhopper.preparator.TlvMessagePayloadMessagePreparator;
12
import fr.sii.ogham.testing.util.HasParent;
13
14
/**
15
 * Make assertions on "User Data" to ensure that it is transported using the
16
 * right field.
17
 * 
18
 * @author Aurélien Baudet
19
 *
20
 */
21
public class CloudhopperUserDataAssertions extends HasParent<CloudhopperAssertions> {
22
23
	private final CloudhopperSMPPSender cloudhopperSender;
24
25
	public CloudhopperUserDataAssertions(CloudhopperAssertions parent, CloudhopperSMPPSender cloudhopperSender) {
26
		super(parent);
27
		this.cloudhopperSender = cloudhopperSender;
28
	}
29
30
	/**
31
	 * Ensure that short message field is used to transport "User Data".
32
	 * 
33
	 * @param matcher
34
	 *            the matcher to ensure that short message field is used or not.
35
	 * @return this instance for fluent chaining
36
	 */
37
	public CloudhopperUserDataAssertions useShortMessage(Matcher<Boolean> matcher) {
38
		MessagePreparator preparator = getPreparator(cloudhopperSender);
39 2 1. useShortMessage : removed call to org/hamcrest/MatcherAssert::assertThat → SURVIVED
2. useShortMessage : removed call to org/hamcrest/MatcherAssert::assertThat → NO_COVERAGE
		assertThat(preparator instanceof ShortMessagePreparator, matcher);
40 2 1. useShortMessage : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useShortMessage → NO_COVERAGE
2. useShortMessage : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useShortMessage → KILLED
		return this;
41
	}
42
43
	/**
44
	 * Ensure that "message_payload" optional TLV parameter is used to transport
45
	 * "User Data".
46
	 * 
47
	 * @param matcher
48
	 *            the matcher to ensure that "message_payload" parameter is used
49
	 *            or not.
50
	 * @return this instance for fluent chaining
51
	 */
52
	public CloudhopperUserDataAssertions useMessagePayloadTlvParameter(Matcher<Boolean> matcher) {
53
		MessagePreparator preparator = getPreparator(cloudhopperSender);
54 2 1. useMessagePayloadTlvParameter : removed call to org/hamcrest/MatcherAssert::assertThat → NO_COVERAGE
2. useMessagePayloadTlvParameter : removed call to org/hamcrest/MatcherAssert::assertThat → SURVIVED
		assertThat(preparator instanceof TlvMessagePayloadMessagePreparator, matcher);
55 2 1. useMessagePayloadTlvParameter : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useMessagePayloadTlvParameter → NO_COVERAGE
2. useMessagePayloadTlvParameter : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useMessagePayloadTlvParameter → KILLED
		return this;
56
	}
57
58
	private MessagePreparator getPreparator(CloudhopperSMPPSender cloudhopperSender) {
59
		try {
60 2 1. getPreparator : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::getPreparator → NO_COVERAGE
2. getPreparator : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::getPreparator → KILLED
			return (MessagePreparator) readField(cloudhopperSender, "messagePreparator", true);
61
		} catch (IllegalAccessException e) {
62
			throw new IllegalStateException("Failed to get 'messagePreparator' of CloudhopperSMPPSender", e);
63
		}
64
	}
65
}

Mutations

39

1.1
Location : useShortMessage
Killed by : none
removed call to org/hamcrest/MatcherAssert::assertThat → SURVIVED

2.2
Location : useShortMessage
Killed by : none
removed call to org/hamcrest/MatcherAssert::assertThat → NO_COVERAGE

40

1.1
Location : useShortMessage
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useShortMessage → KILLED

2.2
Location : useShortMessage
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useShortMessage → NO_COVERAGE

54

1.1
Location : useMessagePayloadTlvParameter
Killed by : none
removed call to org/hamcrest/MatcherAssert::assertThat → NO_COVERAGE

2.2
Location : useMessagePayloadTlvParameter
Killed by : none
removed call to org/hamcrest/MatcherAssert::assertThat → SURVIVED

55

1.1
Location : useMessagePayloadTlvParameter
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useMessagePayloadTlvParameter → NO_COVERAGE

2.2
Location : useMessagePayloadTlvParameter
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::useMessagePayloadTlvParameter → KILLED

60

1.1
Location : getPreparator
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::getPreparator → KILLED

2.2
Location : getPreparator
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperUserDataAssertions::getPreparator → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM