ContextBranch.java

1
package pro.verron.officestamper.core;
2
3
import pro.verron.officestamper.api.ContextTree;
4
5
import java.util.AbstractSequentialList;
6
import java.util.ArrayList;
7
import java.util.List;
8
import java.util.ListIterator;
9
10
/// A branch in the context tree.
11
public class ContextBranch
12
        extends AbstractSequentialList<Object>
13
        implements ContextTree {
14
    private final ContextRoot tree;
15
    private final List<Object> branch;
16
17
    /// Constructs a ContextBranch with a single root object.
18
    ///
19
    /// @param tree the context root tree.
20
    /// @param root the root object of the branch.
21
    public ContextBranch(ContextRoot tree, Object root) {
22
        this(tree, List.of(root));
23
    }
24
25
    /// Constructs a ContextBranch with a list of objects forming the branch.
26
    ///
27
    /// @param tree the context root tree.
28
    /// @param branch the list of objects in the branch.
29
    public ContextBranch(ContextRoot tree, List<Object> branch) {
30
        this.tree = tree;
31
        this.branch = List.copyOf(branch);
32
    }
33
34
    /// Adds a new branch with the given object.
35
    ///
36
    /// @param object the object to add to the branch.
37
    ///
38
    /// @return the key of the added branch.
39
    public String addBranch(Object object) {
40
        var newBranch = new ArrayList<>(branch);
41
        newBranch.add(object);
42
        var contextBranch = new ContextBranch(tree, newBranch);
43 1 1. addBranch : replaced return value with "" for pro/verron/officestamper/core/ContextBranch::addBranch → KILLED
        return tree.addBranch(contextBranch);
44
    }
45
46
    /// Returns the root object of the branch.
47
    ///
48
    /// @return the root object.
49
    public Object root() {
50 1 1. root : replaced return value with null for pro/verron/officestamper/core/ContextBranch::root → KILLED
        return branch.getFirst();
51
    }
52
53
    @Override
54
    public int size() {
55 1 1. size : replaced int return with 0 for pro/verron/officestamper/core/ContextBranch::size → NO_COVERAGE
        return branch.size();
56
    }
57
58
    @Override
59
    public String toString() {
60 1 1. toString : replaced return value with "" for pro/verron/officestamper/core/ContextBranch::toString → NO_COVERAGE
        return String.valueOf(branch);
61
    }
62
63
    @Override
64
    public ListIterator<Object> listIterator(int index) {
65 1 1. listIterator : replaced return value with null for pro/verron/officestamper/core/ContextBranch::listIterator → KILLED
        return branch.listIterator();
66
    }
67
}

Mutations

43

1.1
Location : addBranch
Killed by : pro.verron.officestamper.test.ProcessorRepeatDocPart_BadPlaceholderTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPart_BadPlaceholderTest]/[test-template:testBadExpressionShouldNotBlockCallerThread(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with "" for pro/verron/officestamper/core/ContextBranch::addBranch → KILLED

50

1.1
Location : root
Killed by : pro.verron.officestamper.test.ProcessorRepeatDocPartTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPartTest]/[test-template:shouldImportImageDataWithThisInTheMainDocument()]/[test-template-invocation:#2]
replaced return value with null for pro/verron/officestamper/core/ContextBranch::root → KILLED

55

1.1
Location : size
Killed by : none
replaced int return with 0 for pro/verron/officestamper/core/ContextBranch::size → NO_COVERAGE

60

1.1
Location : toString
Killed by : none
replaced return value with "" for pro/verron/officestamper/core/ContextBranch::toString → NO_COVERAGE

65

1.1
Location : listIterator
Killed by : pro.verron.officestamper.test.SpelInjectionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInjectionTest]/[test-template:spelInjectionTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with null for pro/verron/officestamper/core/ContextBranch::listIterator → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1