NamedCallable.java

1
package fr.sii.ogham.core.retry;
2
3
import java.util.concurrent.Callable;
4
5
/**
6
 * A simple wrapper that allows to name a callable. This is useful to debug and
7
 * when there is an error.
8
 * 
9
 * @author Aurélien Baudet
10
 *
11
 * @param <V>
12
 *            the result type of method call
13
 */
14
public class NamedCallable<V> implements Callable<V> {
15
	private final String name;
16
	private final Callable<V> delegate;
17
18
	/**
19
	 * Name a callable (action) for debugging purpose.
20
	 * 
21
	 * @param name
22
	 *            the name of the action
23
	 * @param delegate
24
	 *            the real callable
25
	 */
26
	public NamedCallable(String name, Callable<V> delegate) {
27
		super();
28
		this.name = name;
29
		this.delegate = delegate;
30
	}
31
32
	@Override
33
	public V call() throws Exception {
34 5 1. call : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → NO_COVERAGE
2. call : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → SURVIVED
3. call : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → TIMED_OUT
4. call : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → KILLED
5. call : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → KILLED
		return delegate.call();
35
	}
36
37
	public String getName() {
38 2 1. getName : replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::getName → NO_COVERAGE
2. getName : replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::getName → SURVIVED
		return name;
39
	}
40
41
	@Override
42
	public String toString() {
43 2 1. toString : replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::toString → NO_COVERAGE
2. toString : replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::toString → SURVIVED
		return name;
44
	}
45
46
	/**
47
	 * Wrap an action to provide a name. This is useful for debugging purpose
48
	 * and in logs.
49
	 * 
50
	 * @param <V>
51
	 *            the type of the returned value of the original action
52
	 * @param name
53
	 *            the name to use for the action
54
	 * @param action
55
	 *            the real action to execute
56
	 * @return the wrapped action
57
	 */
58
	public static <V> Callable<V> named(String name, Callable<V> action) {
59 3 1. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → NO_COVERAGE
2. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → TIMED_OUT
3. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED
		return new NamedCallable<>(name, action);
60
	}
61
62
	/**
63
	 * Wrap an action to provide a name. This is useful for debugging purpose
64
	 * and in logs.
65
	 * 
66
	 * @param name
67
	 *            the name to use for the action
68
	 * @param action
69
	 *            the real action to execute
70
	 * @return the wrapped action
71
	 */
72
	public static Callable<Void> named(String name, Executable action) {
73 4 1. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → NO_COVERAGE
2. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED
3. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED
4. named : replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED
		return new NamedCallable<>(name, () -> {
74 4 1. lambda$named$0 : removed call to fr/sii/ogham/core/retry/Executable::execute → NO_COVERAGE
2. lambda$named$0 : removed call to fr/sii/ogham/core/retry/Executable::execute → KILLED
3. lambda$named$0 : removed call to fr/sii/ogham/core/retry/Executable::execute → KILLED
4. lambda$named$0 : removed call to fr/sii/ogham/core/retry/Executable::execute → KILLED
			action.execute();
75
			return null;
76
		});
77
	}
78
}

Mutations

34

1.1
Location : call
Killed by : none
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → TIMED_OUT

2.2
Location : call
Killed by : none
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → NO_COVERAGE

3.3
Location : call
Killed by : none
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → SURVIVED

4.4
Location : call
Killed by : oghamall.it.sms.SmsSMPPGsm7bitTest.longMessage(oghamall.it.sms.SmsSMPPGsm7bitTest)
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → KILLED

5.5
Location : call
Killed by : oghamcloudhopper.it.PartialConfigurationTest.nothingConfiguredAndLongMessageShouldSendOneLongMessageUsingDefaultEncoding(oghamcloudhopper.it.PartialConfigurationTest)
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::call → KILLED

38

1.1
Location : getName
Killed by : none
replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::getName → NO_COVERAGE

2.2
Location : getName
Killed by : none
replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::getName → SURVIVED

43

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

2.2
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/core/retry/NamedCallable::toString → SURVIVED

59

1.1
Location : named
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledAndAutoGuessEnabledAndGsm7bitEncodingConfiguredAndLongMessageWithUnsupportedCharactersShouldFailIndicatingThatMessageCantBeSplit(oghamcloudhopper.it.PartialConfigurationTest)
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED

2.2
Location : named
Killed by : none
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → NO_COVERAGE

3.3
Location : named
Killed by : none
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → TIMED_OUT

73

1.1
Location : named
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED

2.2
Location : named
Killed by : oghamall.it.retry.AutoRetryTest.doNotResendEmailIfTemplateNotFound(oghamall.it.retry.AutoRetryTest)
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED

3.3
Location : named
Killed by : none
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → NO_COVERAGE

4.4
Location : named
Killed by : oghamcore.it.core.sender.AutoRetryTest.smsSentSuccessfullyOnFirstExecution(oghamcore.it.core.sender.AutoRetryTest)
replaced return value with null for fr/sii/ogham/core/retry/NamedCallable::named → KILLED

74

1.1
Location : lambda$named$0
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
removed call to fr/sii/ogham/core/retry/Executable::execute → KILLED

2.2
Location : lambda$named$0
Killed by : oghamall.it.retry.AutoRetryTest.doNotResendEmailIfTemplateNotFound(oghamall.it.retry.AutoRetryTest)
removed call to fr/sii/ogham/core/retry/Executable::execute → KILLED

3.3
Location : lambda$named$0
Killed by : oghamcore.it.core.sender.AutoRetryTest.smsSentSuccessfullyOnFirstExecution(oghamcore.it.core.sender.AutoRetryTest)
removed call to fr/sii/ogham/core/retry/Executable::execute → KILLED

4.4
Location : lambda$named$0
Killed by : none
removed call to fr/sii/ogham/core/retry/Executable::execute → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM