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
    /// @return the key of the added branch.
38
    public String addBranch(Object object) {
39
        var newBranch = new ArrayList<>(branch);
40
        newBranch.add(object);
41
        var contextBranch = new ContextBranch(tree, newBranch);
42 1 1. addBranch : replaced return value with "" for pro/verron/officestamper/core/ContextBranch::addBranch → KILLED
        return tree.addBranch(contextBranch);
43
    }
44
45
    /// Returns the root object of the branch.
46
    ///
47
    /// @return the root object.
48
    public Object root() {
49 1 1. root : replaced return value with null for pro/verron/officestamper/core/ContextBranch::root → KILLED
        return branch.getFirst();
50
    }
51
52
    @Override
53
    public int size() {
54 1 1. size : replaced int return with 0 for pro/verron/officestamper/core/ContextBranch::size → TIMED_OUT
        return branch.size();
55
    }
56
57
    @Override
58
    public String toString() {
59 1 1. toString : replaced return value with "" for pro/verron/officestamper/core/ContextBranch::toString → NO_COVERAGE
        return String.valueOf(branch);
60
    }
61
62
    @Override
63
    public ListIterator<Object> listIterator(int index) {
64 1 1. listIterator : replaced return value with null for pro/verron/officestamper/core/ContextBranch::listIterator → KILLED
        return branch.listIterator();
65
    }
66
}

Mutations

42

1.1
Location : addBranch
Killed by : pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#3]
replaced return value with "" for pro/verron/officestamper/core/ContextBranch::addBranch → KILLED

49

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

54

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

59

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

64

1.1
Location : listIterator
Killed by : pro.verron.officestamper.test.CustomProcessorTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomProcessorTests]/[test-template:should_allow_custom_processors_injection(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.25.5 support