Diff.java

1
package com.jsql.model.injection.strategy.blind.patch;
2
3
import com.jsql.model.injection.strategy.blind.patch.DiffMatchPatch.Operation;
4
5
/**
6
 * Class representing one diff operation.
7
 */
8
public class Diff implements Comparable<Diff> {
9
10
    /**
11
     * One of: INSERT, DELETE or EQUAL.
12
     */
13
    private Operation operation;
14
15
    /**
16
     * The text associated with this diff operation.
17
     */
18
    private String text;
19
20
    /**
21
     * Constructor.  Initializes the diff with the provided values.
22
     * @param operation One of INSERT, DELETE or EQUAL.
23
     * @param text The text being applied.
24
     */
25
    public Diff(Operation operation, String text) {
26
        // Construct a diff with the specified operation and text.
27
        this.operation = operation;
28
        this.text = text;
29
    }
30
31
    /**
32
     * Display a human-readable version of this Diff.
33
     * @return text version.
34
     */
35
    @Override
36
    public String toString() {
37
        String prettyText = this.text.replace('\n', '\u00b6');
38 1 1. toString : replaced return value with "" for com/jsql/model/injection/strategy/blind/patch/Diff::toString → NO_COVERAGE
        return "Diff(" + this.operation + ",\"" + prettyText + "\")";
39
    }
40
41
    /**
42
     * Create a numeric hash value for a Diff.
43
     * This function is not used by DMP.
44
     * @return Hash value.
45
     */
46
    @Override
47
    public int hashCode() {
48
        final int prime = 31;
49 1 1. hashCode : negated conditional → NO_COVERAGE
        int result = this.operation == null ? 0 : this.operation.hashCode();
50 3 1. hashCode : Replaced integer addition with subtraction → NO_COVERAGE
2. hashCode : Replaced integer multiplication with division → NO_COVERAGE
3. hashCode : negated conditional → NO_COVERAGE
        result += prime * (this.text == null ? 0 : this.text.hashCode());
51 1 1. hashCode : replaced int return with 0 for com/jsql/model/injection/strategy/blind/patch/Diff::hashCode → NO_COVERAGE
        return result;
52
    }
53
54
    /**
55
     * Is this Diff equivalent to another Diff?
56
     * @param obj Another Diff to compare against.
57
     * @return true or false.
58
     */
59
    @Override
60
    public boolean equals(Object obj) {
61 1 1. equals : negated conditional → NO_COVERAGE
        if (this == obj) {
62 1 1. equals : replaced boolean return with false for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return true;
63
        }
64 1 1. equals : negated conditional → NO_COVERAGE
        if (obj == null) {
65 1 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return false;
66
        }
67 1 1. equals : negated conditional → NO_COVERAGE
        if (this.getClass() != obj.getClass()) {
68 1 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return false;
69
        }
70
71
        Diff other = (Diff) obj;
72 1 1. equals : negated conditional → NO_COVERAGE
        if (this.operation != other.operation) {
73 1 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return false;
74
        }
75
76 1 1. equals : negated conditional → NO_COVERAGE
        if (this.text == null) {
77 2 1. equals : negated conditional → NO_COVERAGE
2. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return other.text == null;
78
        } else {
79 2 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
2. equals : replaced boolean return with false for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return this.text.equals(other.text);
80
        }
81
    }
82
83
    @Override
84
    public int compareTo(Diff diff) {
85 2 1. compareTo : negated conditional → NO_COVERAGE
2. compareTo : replaced int return with 0 for com/jsql/model/injection/strategy/blind/patch/Diff::compareTo → NO_COVERAGE
        return this.toString().equals(diff.toString()) ? 0 : 1;
86
    }
87
88
89
    // Getter and setter
90
91
    public Operation getOperation() {
92 1 1. getOperation : replaced return value with null for com/jsql/model/injection/strategy/blind/patch/Diff::getOperation → NO_COVERAGE
        return this.operation;
93
    }
94
95
    public void setOperation(Operation operation) {
96
        this.operation = operation;
97
    }
98
99
    public String getText() {
100 1 1. getText : replaced return value with "" for com/jsql/model/injection/strategy/blind/patch/Diff::getText → NO_COVERAGE
        return this.text;
101
    }
102
103
    public void setText(String text) {
104
        this.text = text;
105
    }
106
}

Mutations

38

1.1
Location : toString
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/blind/patch/Diff::toString → NO_COVERAGE

49

1.1
Location : hashCode
Killed by : none
negated conditional → NO_COVERAGE

50

1.1
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : hashCode
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

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

51

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/jsql/model/injection/strategy/blind/patch/Diff::hashCode → NO_COVERAGE

61

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

62

1.1
Location : equals
Killed by : none
replaced boolean return with false for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

64

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

65

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

67

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

68

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

72

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

73

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

76

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

77

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

79

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

2.2
Location : equals
Killed by : none
replaced boolean return with false for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

85

1.1
Location : compareTo
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : compareTo
Killed by : none
replaced int return with 0 for com/jsql/model/injection/strategy/blind/patch/Diff::compareTo → NO_COVERAGE

92

1.1
Location : getOperation
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/blind/patch/Diff::getOperation → NO_COVERAGE

100

1.1
Location : getText
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/blind/patch/Diff::getText → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.0