JavaMailAssertions.java

1
package fr.sii.ogham.testing.assertion.internal;
2
3
import static fr.sii.ogham.testing.assertion.internal.helper.ImplementationFinder.findSender;
4
import static fr.sii.ogham.testing.assertion.util.AssertionHelper.assertThat;
5
import static org.apache.commons.lang3.reflect.FieldUtils.readField;
6
7
import java.util.Properties;
8
9
import org.hamcrest.Matcher;
10
11
import fr.sii.ogham.core.service.MessagingService;
12
import fr.sii.ogham.email.sender.impl.JavaMailSender;
13
import fr.sii.ogham.testing.util.HasParent;
14
15
/**
16
 * Helper to mke assertions on {@link JavaMailSender} instance created by Ogham.
17
 * 
18
 * @author Aurélien Baudet
19
 *
20
 */
21
public class JavaMailAssertions extends HasParent<MessagingServiceAssertions> {
22
	private final JavaMailSender javaMailSender;
23
24
	public JavaMailAssertions(MessagingServiceAssertions parent, JavaMailSender javaMailSender) {
25
		super(parent);
26
		this.javaMailSender = javaMailSender;
27
	}
28
29
	/**
30
	 * Ensure that host value is correctly configured as expected.
31
	 * 
32
	 * @param matcher
33
	 *            the matcher used to check that host is configured as expected.
34
	 * @return this instance for fluent chaining
35
	 */
36
	public JavaMailAssertions host(Matcher<String> matcher) {
37 2 1. host : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE
2. host : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED
		assertThat(getHost(javaMailSender), matcher);
38 3 1. host : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::host → NO_COVERAGE
2. host : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::host → SURVIVED
3. host : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::host → TIMED_OUT
		return this;
39
	}
40
41
	/**
42
	 * Find the {@link JavaMailSender} instance.
43
	 * 
44
	 * @param messagingService
45
	 *            the messaging service
46
	 * @return the found instance
47
	 */
48
	public static JavaMailSender getJavaMailSender(MessagingService messagingService) {
49 4 1. getJavaMailSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → NO_COVERAGE
2. getJavaMailSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → TIMED_OUT
3. getJavaMailSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → KILLED
4. getJavaMailSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → KILLED
		return findSender(messagingService, JavaMailSender.class);
50
	}
51
52
	private String getHost(JavaMailSender javaMailSender) {
53
		Properties properties = getProperties(javaMailSender);
54 4 1. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → NO_COVERAGE
2. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → KILLED
3. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → KILLED
4. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → KILLED
		return properties.getProperty("mail.smtp.host", properties.getProperty("mail.host"));
55
	}
56
57
	private static Properties getProperties(JavaMailSender javaMailSender) {
58
		try {
59 4 1. getProperties : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → NO_COVERAGE
2. getProperties : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → KILLED
3. getProperties : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → KILLED
4. getProperties : replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → KILLED
			return (Properties) readField(javaMailSender, "properties", true);
60
		} catch (IllegalAccessException e) {
61
			throw new IllegalStateException("Failed to get 'properties' of JavaMailSender", e);
62
		}
63
	}
64
}

Mutations

37

1.1
Location : host
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE

2.2
Location : host
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED

38

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

2.2
Location : host
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::host → SURVIVED

3.3
Location : host
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::host → TIMED_OUT

49

1.1
Location : getJavaMailSender
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → TIMED_OUT

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

3.3
Location : getJavaMailSender
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → KILLED

4.4
Location : getJavaMailSender
Killed by : oghamall.it.configuration.JavaMailConfigurationTest.asDeveloperIDefineHostUsingProperties(oghamall.it.configuration.JavaMailConfigurationTest)
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getJavaMailSender → KILLED

54

1.1
Location : getHost
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → KILLED

2.2
Location : getHost
Killed by : oghamall.it.configuration.JavaMailConfigurationTest.asDeveloperIDefineHostUsingProperties(oghamall.it.configuration.JavaMailConfigurationTest)
replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → KILLED

3.3
Location : getHost
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → KILLED

4.4
Location : getHost
Killed by : none
replaced return value with "" for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getHost → NO_COVERAGE

59

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

2.2
Location : getProperties
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → KILLED

3.3
Location : getProperties
Killed by : oghamall.it.configuration.JavaMailConfigurationTest.asDeveloperIDefineHostUsingProperties(oghamall.it.configuration.JavaMailConfigurationTest)
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → KILLED

4.4
Location : getProperties
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/testing/assertion/internal/JavaMailAssertions::getProperties → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM