CloudhopperSplitterAssertions.java

1
package fr.sii.ogham.testing.assertion.internal;
2
3
import static org.hamcrest.MatcherAssert.assertThat;
4
5
import org.apache.commons.lang3.reflect.FieldUtils;
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.splitter.MessageSplitter;
11
import fr.sii.ogham.sms.splitter.NoSplitMessageSplitter;
12
import fr.sii.ogham.testing.util.HasParent;
13
14
/**
15
 * Make assertions on splitter instance to ensure that it is correctly
16
 * configured.
17
 * 
18
 * For example:
19
 * 
20
 * <pre>
21
 * {@code
22
 *   enabled(is(true))
23
 * }
24
 * </pre>
25
 * 
26
 * @author Aurélien Baudet
27
 *
28
 */
29
public class CloudhopperSplitterAssertions extends HasParent<CloudhopperAssertions> {
30
31
	private final CloudhopperSMPPSender cloudhopperSender;
32
33
	public CloudhopperSplitterAssertions(CloudhopperAssertions parent, CloudhopperSMPPSender cloudhopperSender) {
34
		super(parent);
35
		this.cloudhopperSender = cloudhopperSender;
36
	}
37
38
	/**
39
	 * Ensures that splitter is correctly enabled or not. When Splitter is
40
	 * disabled, the splitter instance is {@link NoSplitMessageSplitter}.
41
	 * 
42
	 * @param matcher
43
	 *            the matcher to ensure that splitter is enabled or disabled
44
	 */
45
	public void enabled(Matcher<Boolean> matcher) {
46
		try {
47
			boolean noSplit = getSplitter() instanceof NoSplitMessageSplitter;
48 4 1. enabled : negated conditional → NO_COVERAGE
2. enabled : removed call to org/hamcrest/MatcherAssert::assertThat → SURVIVED
3. enabled : removed call to org/hamcrest/MatcherAssert::assertThat → NO_COVERAGE
4. enabled : negated conditional → KILLED
			assertThat(!noSplit, matcher);
49
		} catch (IllegalAccessException e) {
50
			throw new IllegalStateException("Failed to get 'messagePreparator.messageSplitter' of CloudhopperSMPPSender", e);
51
		}
52
	}
53
54
	private MessageSplitter getSplitter() throws IllegalAccessException {
55
		MessagePreparator preparator = (MessagePreparator) FieldUtils.readField(cloudhopperSender, "messagePreparator", true);
56 2 1. getSplitter : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperSplitterAssertions::getSplitter → NO_COVERAGE
2. getSplitter : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperSplitterAssertions::getSplitter → KILLED
		return (MessageSplitter) FieldUtils.readField(preparator, "messageSplitter", true);
57
	}
58
}

Mutations

48

1.1
Location : enabled
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : enabled
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
negated conditional → KILLED

3.3
Location : enabled
Killed by : none
removed call to org/hamcrest/MatcherAssert::assertThat → SURVIVED

4.4
Location : enabled
Killed by : none
removed call to org/hamcrest/MatcherAssert::assertThat → NO_COVERAGE

56

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

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

Active mutators

Tests examined


Report generated by PIT OGHAM