| 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 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 14.14 |
|
| 42 |
1.1 2.2 3.3 |
|
| 47 |
1.1 2.2 |
|
| 53 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 59 |
1.1 |
|
| 60 |
1.1 |
|
| 62 |
1.1 |
|
| 68 |
1.1 |
|
| 71 |
1.1 |
|
| 77 |
1.1 |
|
| 80 |
1.1 |