PriorizedList.java

1
package fr.sii.ogham.core.util;
2
3
import static java.util.stream.Collectors.toList;
4
5
import java.util.ArrayList;
6
import java.util.List;
7
8
/**
9
 * Helper class that registers objects with associated priority. Each registered
10
 * object is then returned as list ordered by priority. The higher priority
11
 * value comes first in the list.
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 * @param <P>
16
 *            the type of priorized objects
17
 */
18
public class PriorizedList<P> {
19
	private final List<WithPriority<P>> priorities;
20
21
	/**
22
	 * Initializes with an empty list
23
	 */
24
	public PriorizedList() {
25
		this(new ArrayList<>());
26
	}
27
28
	/**
29
	 * Initializes with some priorized objects
30
	 * 
31
	 * @param priorities
32
	 *            the priorized objects
33
	 */
34
	public PriorizedList(List<WithPriority<P>> priorities) {
35
		super();
36
		this.priorities = priorities;
37
	}
38
39
	/**
40
	 * Registers a new priorized object
41
	 * 
42
	 * @param priorized
43
	 *            the wrapped object with its priority
44
	 * @return this instance for fluent chaining
45
	 */
46
	public PriorizedList<P> register(WithPriority<P> priorized) {
47
		priorities.add(priorized);
48 1 1. register : replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → NO_COVERAGE
		return this;
49
	}
50
51
	/**
52
	 * Registers an object with its priority
53
	 * 
54
	 * @param priorized
55
	 *            the object to register
56
	 * @param priority
57
	 *            the associated priority
58
	 * @return this instance for fluent chaining
59
	 */
60
	public PriorizedList<P> register(P priorized, int priority) {
61
		priorities.add(new WithPriority<>(priorized, priority));
62 3 1. register : replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → SURVIVED
2. register : replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → NO_COVERAGE
3. register : replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → TIMED_OUT
		return this;
63
	}
64
65
	/**
66
	 * Merge all priorities of another {@link PriorizedList} into this one.
67
	 * 
68
	 * @param other
69
	 *            the priority list
70
	 * @return this isntance for fluent chaining
71
	 */
72
	public PriorizedList<P> register(PriorizedList<P> other) {
73
		priorities.addAll(other.getPriorities());
74 2 1. register : replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → SURVIVED
2. register : replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → NO_COVERAGE
		return this;
75
	}
76
77
	/**
78
	 * Returns true if this list contains no elements.
79
	 * 
80
	 * @return if this list contains no elements
81
	 */
82
	public boolean isEmpty() {
83 4 1. isEmpty : replaced boolean return with false for fr/sii/ogham/core/util/PriorizedList::isEmpty → NO_COVERAGE
2. isEmpty : replaced boolean return with true for fr/sii/ogham/core/util/PriorizedList::isEmpty → SURVIVED
3. isEmpty : replaced boolean return with true for fr/sii/ogham/core/util/PriorizedList::isEmpty → NO_COVERAGE
4. isEmpty : replaced boolean return with false for fr/sii/ogham/core/util/PriorizedList::isEmpty → KILLED
		return priorities.isEmpty();
84
	}
85
86
	/**
87
	 * Get the list of priorities ordered by priority
88
	 * 
89
	 * @return ordered list of priorities
90
	 */
91
	public List<WithPriority<P>> getPriorities() {
92 2 1. getPriorities : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getPriorities → SURVIVED
2. getPriorities : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getPriorities → NO_COVERAGE
		return sort();
93
	}
94
95
	/**
96
	 * Get the list of priorized objects ordered by highest priority.
97
	 * 
98
	 * @return list of objects ordered by highet priority
99
	 */
100
	public List<P> getOrdered() {
101 8 1. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → NO_COVERAGE
2. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
3. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
4. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
5. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
6. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
7. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
8. getOrdered : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED
		return sort().stream().map(WithPriority::getPriorized).collect(toList());
102
	}
103
104
	private List<WithPriority<P>> sort() {
105 7 1. sort : removed call to java/util/List::sort → SURVIVED
2. sort : removed call to java/util/List::sort → NO_COVERAGE
3. sort : removed call to java/util/List::sort → KILLED
4. sort : removed call to java/util/List::sort → KILLED
5. sort : removed call to java/util/List::sort → KILLED
6. sort : removed call to java/util/List::sort → KILLED
7. sort : removed call to java/util/List::sort → KILLED
		priorities.sort(WithPriority.comparator());
106 8 1. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → NO_COVERAGE
2. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
3. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
4. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
5. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
6. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
7. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
8. sort : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED
		return priorities;
107
	}
108
}

Mutations

48

1.1
Location : register
Killed by : none
replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → NO_COVERAGE

62

1.1
Location : register
Killed by : none
replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → SURVIVED

2.2
Location : register
Killed by : none
replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → TIMED_OUT

3.3
Location : register
Killed by : none
replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → NO_COVERAGE

74

1.1
Location : register
Killed by : none
replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → SURVIVED

2.2
Location : register
Killed by : none
replaced return value with null for fr/sii/ogham/core/util/PriorizedList::register → NO_COVERAGE

83

1.1
Location : isEmpty
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/PriorizedList::isEmpty → NO_COVERAGE

2.2
Location : isEmpty
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledButAutoGuessNotEnabledAndNoEncodingConfiguredAndLongMessageShouldFailIndicatingThatNoSplitterIsConfigured(oghamcloudhopper.it.PartialConfigurationTest)
replaced boolean return with false for fr/sii/ogham/core/util/PriorizedList::isEmpty → KILLED

3.3
Location : isEmpty
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/PriorizedList::isEmpty → SURVIVED

4.4
Location : isEmpty
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/PriorizedList::isEmpty → NO_COVERAGE

92

1.1
Location : getPriorities
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getPriorities → SURVIVED

2.2
Location : getPriorities
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getPriorities → NO_COVERAGE

101

1.1
Location : getOrdered
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

2.2
Location : getOrdered
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

3.3
Location : getOrdered
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → NO_COVERAGE

4.4
Location : getOrdered
Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

5.5
Location : getOrdered
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

6.6
Location : getOrdered
Killed by : oghamcloudhopper.it.SpecialCharactersTest.gsm8bit(oghamcloudhopper.it.SpecialCharactersTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

7.7
Location : getOrdered
Killed by : oghamspringbootv1autoconfigure.it.SpringWebBeanResolutionTest.smsUsingThymeleafTemplateShouldResolveBeansAndUrls(oghamspringbootv1autoconfigure.it.SpringWebBeanResolutionTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

8.8
Location : getOrdered
Killed by : oghamspringbootv2autoconfigure.it.SpringWebBeanResolutionTest.smsUsingThymeleafTemplateShouldResolveBeansAndUrls(oghamspringbootv2autoconfigure.it.SpringWebBeanResolutionTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::getOrdered → KILLED

105

1.1
Location : sort
Killed by : none
removed call to java/util/List::sort → SURVIVED

2.2
Location : sort
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
removed call to java/util/List::sort → KILLED

3.3
Location : sort
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1SendGridAutoConfigurationTests.oghamWithSendGridAutoConfigShouldUseSpringSendGridClient(oghamspringbootv1autoconfigure.it.OghamSpringBoot1SendGridAutoConfigurationTests)
removed call to java/util/List::sort → KILLED

4.4
Location : sort
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests.oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration(oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests)
removed call to java/util/List::sort → KILLED

5.5
Location : sort
Killed by : none
removed call to java/util/List::sort → NO_COVERAGE

6.6
Location : sort
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
removed call to java/util/List::sort → KILLED

7.7
Location : sort
Killed by : oghamall.it.sms.FluentSmsTest.useTemplateString(oghamall.it.sms.FluentSmsTest)
removed call to java/util/List::sort → KILLED

106

1.1
Location : sort
Killed by : oghamspringbootv2autoconfigure.it.SpringWebBeanResolutionTest.smsUsingThymeleafTemplateShouldResolveBeansAndUrls(oghamspringbootv2autoconfigure.it.SpringWebBeanResolutionTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

2.2
Location : sort
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

3.3
Location : sort
Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

4.4
Location : sort
Killed by : oghamspringbootv1autoconfigure.it.SpringWebBeanResolutionTest.smsUsingThymeleafTemplateShouldResolveBeansAndUrls(oghamspringbootv1autoconfigure.it.SpringWebBeanResolutionTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

5.5
Location : sort
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → NO_COVERAGE

6.6
Location : sort
Killed by : oghamcloudhopper.it.SpecialCharactersTest.gsm8bit(oghamcloudhopper.it.SpecialCharactersTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

7.7
Location : sort
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

8.8
Location : sort
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with Collections.emptyList for fr/sii/ogham/core/util/PriorizedList::sort → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM