JavaPropertiesResolver.java

1
package fr.sii.ogham.core.env;
2
3
import java.util.Properties;
4
5
import fr.sii.ogham.core.convert.Converter;
6
7
/**
8
 * Simple property resolver that delegates property resolution to a
9
 * {@link Properties} instance. Conversion of raw property values are done by
10
 * the provided {@link Converter} instance.
11
 * 
12
 * @author Aurélien Baudet
13
 *
14
 */
15
public class JavaPropertiesResolver implements PropertyResolver {
16
	private final Properties properties;
17
	private final Converter converter;
18
19
	/**
20
	 * Initializes with the {@link Properties} instance that is used to check
21
	 * property existence and get property values. Provperty values are then
22
	 * converted using the provided {@link Converter}.
23
	 * 
24
	 * @param properties
25
	 *            the properties map
26
	 * @param converter
27
	 *            used to convert raw values
28
	 */
29
	public JavaPropertiesResolver(Properties properties, Converter converter) {
30
		super();
31
		this.properties = properties;
32
		this.converter = converter;
33
	}
34
35
	@Override
36
	public boolean containsProperty(String key) {
37 14 1. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → NO_COVERAGE
2. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → NO_COVERAGE
3. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → TIMED_OUT
4. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → TIMED_OUT
5. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
6. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
7. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
8. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
9. containsProperty : replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
10. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
11. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
12. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
13. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
14. containsProperty : replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED
		return properties.containsKey(key);
38
	}
39
40
	@Override
41
	public String getProperty(String key) {
42 3 1. getProperty : replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → SURVIVED
2. getProperty : replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE
3. getProperty : replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED
		return properties.getProperty(key);
43
	}
44
45
	@Override
46
	public String getProperty(String key, String defaultValue) {
47 2 1. getProperty : replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE
2. getProperty : replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → SURVIVED
		return properties.getProperty(key, defaultValue);
48
	}
49
50
	@Override
51
	public <T> T getProperty(String key, Class<T> targetType) {
52
		Object property = properties.get(key);
53 6 1. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE
2. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED
3. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED
4. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED
5. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED
6. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED
		return converter.convert(property, targetType);
54
	}
55
56
	@Override
57
	public <T> T getProperty(String key, Class<T> targetType, T defaultValue) {
58
		String property = getProperty(key);
59 1 1. getProperty : negated conditional → NO_COVERAGE
		if (property == null) {
60 1 1. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE
			return defaultValue;
61
		}
62 1 1. getProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE
		return converter.convert(property, targetType);
63
	}
64
65
	@Override
66
	public String getRequiredProperty(String key) {
67
		String property = getProperty(key);
68 1 1. getRequiredProperty : negated conditional → NO_COVERAGE
		if (property == null) {
69
			throw new IllegalStateException("no value for required property " + key);
70
		}
71 1 1. getRequiredProperty : replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getRequiredProperty → NO_COVERAGE
		return property;
72
	}
73
74
	@Override
75
	public <T> T getRequiredProperty(String key, Class<T> targetType) {
76
		String property = getProperty(key);
77 1 1. getRequiredProperty : negated conditional → NO_COVERAGE
		if (property == null) {
78
			throw new IllegalStateException("no value for required property " + key);
79
		}
80 1 1. getRequiredProperty : replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getRequiredProperty → NO_COVERAGE
		return converter.convert(property, targetType);
81
	}
82
83
}

Mutations

37

1.1
Location : containsProperty
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

2.2
Location : containsProperty
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

3.3
Location : containsProperty
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → TIMED_OUT

4.4
Location : containsProperty
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

5.5
Location : containsProperty
Killed by : oghamjavamail.it.builder.OverridePropertiesTest.values(oghamjavamail.it.builder.OverridePropertiesTest)
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

6.6
Location : containsProperty
Killed by : oghamcore.it.core.configuration.ConfigurationLifecycleSpec
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

7.7
Location : containsProperty
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → NO_COVERAGE

8.8
Location : containsProperty
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → NO_COVERAGE

9.9
Location : containsProperty
Killed by : oghamjavamail.it.builder.OverridePropertiesTest.valuesWithEmptyProps(oghamjavamail.it.builder.OverridePropertiesTest)
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

10.10
Location : containsProperty
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

11.11
Location : containsProperty
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

12.12
Location : containsProperty
Killed by : oghamcore.it.core.convert.CustomConverterTest.asDeveloperIUseMyCustomConverter(oghamcore.it.core.convert.CustomConverterTest)
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

13.13
Location : containsProperty
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → TIMED_OUT

14.14
Location : containsProperty
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced boolean return with true for fr/sii/ogham/core/env/JavaPropertiesResolver::containsProperty → KILLED

42

1.1
Location : getProperty
Killed by : none
replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → SURVIVED

2.2
Location : getProperty
Killed by : oghamjavamail.it.builder.OverridePropertiesTest.values(oghamjavamail.it.builder.OverridePropertiesTest)
replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED

3.3
Location : getProperty
Killed by : none
replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE

47

1.1
Location : getProperty
Killed by : none
replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE

2.2
Location : getProperty
Killed by : none
replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → SURVIVED

53

1.1
Location : getProperty
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED

2.2
Location : getProperty
Killed by : oghamcore.it.core.configuration.ConfigurationLifecycleSpec
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED

3.3
Location : getProperty
Killed by : none
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE

4.4
Location : getProperty
Killed by : oghamjavamail.it.builder.OverridePropertiesTest.overrideProperties(oghamjavamail.it.builder.OverridePropertiesTest)
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED

5.5
Location : getProperty
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED

6.6
Location : getProperty
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → KILLED

59

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

60

1.1
Location : getProperty
Killed by : none
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE

62

1.1
Location : getProperty
Killed by : none
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getProperty → NO_COVERAGE

68

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

71

1.1
Location : getRequiredProperty
Killed by : none
replaced return value with "" for fr/sii/ogham/core/env/JavaPropertiesResolver::getRequiredProperty → NO_COVERAGE

77

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

80

1.1
Location : getRequiredProperty
Killed by : none
replaced return value with null for fr/sii/ogham/core/env/JavaPropertiesResolver::getRequiredProperty → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM