AnnotationPriorityProvider.java

1
package fr.sii.ogham.core.builder.priority;
2
3
import static java.util.Arrays.asList;
4
5
import fr.sii.ogham.core.builder.context.BuildContext;
6
7
/**
8
 * Provide the priority of an implementation based on {@link Priority}
9
 * annotation that is present on the class (if any).
10
 * 
11
 * <p>
12
 * If no annotation or no priority is configured, then a default priority is
13
 * provided (delegating to another {@link PriorityProvider} implementation).
14
 * 
15
 * @author Aurélien Baudet
16
 *
17
 */
18
public class AnnotationPriorityProvider implements PriorityProvider<Class<?>> {
19
	private final BuildContext buildContext;
20
	private final PriorityProvider<Class<?>> defaultProvider;
21
22
	/**
23
	 * Initializes with the build context and a default provider if the priority
24
	 * is not provided through the annotation.
25
	 * 
26
	 * @param buildContext
27
	 *            for property evaluation
28
	 * @param defaultProvider
29
	 *            in case that there is no priority provided using the
30
	 *            annotation
31
	 */
32
	public AnnotationPriorityProvider(BuildContext buildContext, PriorityProvider<Class<?>> defaultProvider) {
33
		super();
34
		this.buildContext = buildContext;
35
		this.defaultProvider = defaultProvider;
36
	}
37
38
	@Override
39
	public int provide(Class<?> source) {
40
		Priority priority = source.getAnnotation(Priority.class);
41 5 1. provide : negated conditional → SURVIVED
2. provide : negated conditional → NO_COVERAGE
3. provide : negated conditional → KILLED
4. provide : negated conditional → KILLED
5. provide : negated conditional → KILLED
		if (priority == null) {
42 2 1. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → SURVIVED
2. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → NO_COVERAGE
			return defaultProvider.provide(source);
43
		}
44
		int value = computePriority(priority.properties(), priority.defaultValue());
45 5 1. provide : changed conditional boundary → SURVIVED
2. provide : changed conditional boundary → NO_COVERAGE
3. provide : negated conditional → NO_COVERAGE
4. provide : negated conditional → SURVIVED
5. provide : negated conditional → KILLED
		if (value > 0) {
46 3 1. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → SURVIVED
2. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → NO_COVERAGE
3. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → KILLED
			return value;
47
		}
48 1 1. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → NO_COVERAGE
		return defaultProvider.provide(source);
49
	}
50
51
	private int computePriority(String[] properties, int defaultValue) {
52
		Integer value = buildContext.evaluate(asList(properties), Integer.class);
53 10 1. computePriority : changed conditional boundary → NO_COVERAGE
2. computePriority : negated conditional → NO_COVERAGE
3. computePriority : negated conditional → NO_COVERAGE
4. computePriority : negated conditional → KILLED
5. computePriority : negated conditional → KILLED
6. computePriority : negated conditional → KILLED
7. computePriority : negated conditional → KILLED
8. computePriority : negated conditional → KILLED
9. computePriority : negated conditional → KILLED
10. computePriority : negated conditional → KILLED
		if (value != null && value > 0) {
54 1 1. computePriority : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → NO_COVERAGE
			return value;
55
		}
56 3 1. computePriority : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → NO_COVERAGE
2. computePriority : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → SURVIVED
3. computePriority : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → KILLED
		return defaultValue;
57
	}
58
59
}

Mutations

41

1.1
Location : provide
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
negated conditional → KILLED

2.2
Location : provide
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
negated conditional → KILLED

3.3
Location : provide
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
negated conditional → KILLED

4.4
Location : provide
Killed by : none
negated conditional → SURVIVED

5.5
Location : provide
Killed by : none
negated conditional → NO_COVERAGE

42

1.1
Location : provide
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → SURVIVED

2.2
Location : provide
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → NO_COVERAGE

45

1.1
Location : provide
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : provide
Killed by : none
changed conditional boundary → NO_COVERAGE

3.3
Location : provide
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : provide
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
negated conditional → KILLED

5.5
Location : provide
Killed by : none
negated conditional → SURVIVED

46

1.1
Location : provide
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → KILLED

2.2
Location : provide
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → SURVIVED

3.3
Location : provide
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → NO_COVERAGE

48

1.1
Location : provide
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::provide → NO_COVERAGE

53

1.1
Location : computePriority
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : computePriority
Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.noHostDefinedShouldFail(oghamjavamail.it.builder.JavaMailCustomConfigurationTest)
negated conditional → KILLED

3.3
Location : computePriority
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
negated conditional → KILLED

4.4
Location : computePriority
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : computePriority
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

6.6
Location : computePriority
Killed by : oghamcloudhopper.it.ConnectionFailureTest.invalidSystemId(oghamcloudhopper.it.ConnectionFailureTest)
negated conditional → KILLED

7.7
Location : computePriority
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
negated conditional → KILLED

8.8
Location : computePriority
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
negated conditional → KILLED

9.9
Location : computePriority
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
negated conditional → KILLED

10.10
Location : computePriority
Killed by : none
negated conditional → NO_COVERAGE

54

1.1
Location : computePriority
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → NO_COVERAGE

56

1.1
Location : computePriority
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → KILLED

2.2
Location : computePriority
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → NO_COVERAGE

3.3
Location : computePriority
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/builder/priority/AnnotationPriorityProvider::computePriority → SURVIVED

Active mutators

Tests examined


Report generated by PIT OGHAM