RequiredPropertyCondition.java

1
package fr.sii.ogham.core.condition;
2
3
import fr.sii.ogham.core.env.PropertyResolver;
4
import fr.sii.ogham.core.util.EqualsBuilder;
5
import fr.sii.ogham.core.util.HashCodeBuilder;
6
7
/**
8
 * Condition that checks if the provided property is defined either in the
9
 * system property or in the provided properties.
10
 * 
11
 * @author Aurélien Baudet
12
 *
13
 * @param <T>
14
 *            The type of the object to test for acceptance. Has no effect on
15
 *            the acceptance
16
 */
17
public class RequiredPropertyCondition<T> implements Condition<T> {
18
	/**
19
	 * The properties to use for checking if property is defined or not
20
	 */
21
	private PropertyResolver propertyResolver;
22
23
	/**
24
	 * The key to check if defined in the properties
25
	 */
26
	private String key;
27
28
	/**
29
	 * Initialize the condition with the provided key. It will check the
30
	 * existence of this key into the provided properties.
31
	 * 
32
	 * @param key
33
	 *            The key to check for existence
34
	 * @param propertyResolver
35
	 *            the property resolver used to get properties values
36
	 */
37
	public RequiredPropertyCondition(String key, PropertyResolver propertyResolver) {
38
		super();
39
		this.key = key;
40
		this.propertyResolver = propertyResolver;
41
	}
42
43
	@Override
44
	public boolean accept(T obj) {
45 10 1. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → NO_COVERAGE
2. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → NO_COVERAGE
3. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → TIMED_OUT
4. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → TIMED_OUT
5. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED
6. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED
7. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED
8. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED
9. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED
10. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED
		return propertyResolver.containsProperty(key);
46
	}
47
48
	@Override
49
	public boolean equals(Object obj) {
50 2 1. equals : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::equals → NO_COVERAGE
2. equals : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::equals → NO_COVERAGE
		return new EqualsBuilder(this, obj).appendFields("key", "propertyResolver").isEqual();
51
	}
52
	
53
	@Override
54
	public int hashCode() {
55 1 1. hashCode : replaced int return with 0 for fr/sii/ogham/core/condition/RequiredPropertyCondition::hashCode → NO_COVERAGE
		return new HashCodeBuilder().append(key, propertyResolver).hashCode();
56
	}
57
58
	@Override
59
	public String toString() {
60
		StringBuilder builder = new StringBuilder();
61
		builder.append("(Is ").append(key).append(" in properties ?)");
62 1 1. toString : replaced return value with "" for fr/sii/ogham/core/condition/RequiredPropertyCondition::toString → NO_COVERAGE
		return builder.toString();
63
	}
64
}

Mutations

45

1.1
Location : accept
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → NO_COVERAGE

2.2
Location : accept
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → TIMED_OUT

3.3
Location : accept
Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest)
replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED

4.4
Location : accept
Killed by : oghamcore.ut.core.condition.fluent.FluentConditionsTest.requiredMailHostAndMailPortProperties(oghamcore.ut.core.condition.fluent.FluentConditionsTest)
replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED

5.5
Location : accept
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED

6.6
Location : accept
Killed by : oghamcore.ut.core.condition.fluent.FluentConditionsTest.requiredMailHostAndMailPortProperties(oghamcore.ut.core.condition.fluent.FluentConditionsTest)
replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED

7.7
Location : accept
Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.noHostDefinedShouldFail(oghamjavamail.it.builder.JavaMailCustomConfigurationTest)
replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED

8.8
Location : accept
Killed by : oghamall.it.email.EmailCustomImplTest.simple(oghamall.it.email.EmailCustomImplTest)
replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → KILLED

9.9
Location : accept
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → TIMED_OUT

10.10
Location : accept
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::accept → NO_COVERAGE

50

1.1
Location : equals
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/condition/RequiredPropertyCondition::equals → NO_COVERAGE

2.2
Location : equals
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/condition/RequiredPropertyCondition::equals → NO_COVERAGE

55

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/condition/RequiredPropertyCondition::hashCode → NO_COVERAGE

62

1.1
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/core/condition/RequiredPropertyCondition::toString → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM