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
27
        // Construct a diff with the specified operation and text.
28
        this.operation = operation;
29
        this.text = text;
30
    }
31
32
    /**
33
     * Display a human-readable version of this Diff.
34
     * @return text version.
35
     */
36
    @Override
37
    public String toString() {
38
39
        String prettyText = this.text.replace('\n', '\u00b6');
40 1 1. toString : replaced return value with "" for com/jsql/model/injection/strategy/blind/patch/Diff::toString → NO_COVERAGE
        return "Diff(" + this.operation + ",\"" + prettyText + "\")";
41
    }
42
43
    /**
44
     * Create a numeric hash value for a Diff.
45
     * This function is not used by DMP.
46
     * @return Hash value.
47
     */
48
    @Override
49
    public int hashCode() {
50
51
        final int prime = 31;
52 1 1. hashCode : negated conditional → NO_COVERAGE
        int result = this.operation == null ? 0 : this.operation.hashCode();
53 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());
54 1 1. hashCode : replaced int return with 0 for com/jsql/model/injection/strategy/blind/patch/Diff::hashCode → NO_COVERAGE
        return result;
55
    }
56
57
    /**
58
     * Is this Diff equivalent to another Diff?
59
     * @param obj Another Diff to compare against.
60
     * @return true or false.
61
     */
62
    @Override
63
    public boolean equals(Object obj) {
64
65 1 1. equals : negated conditional → NO_COVERAGE
        if (this == obj) {
66 1 1. equals : replaced boolean return with false for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return true;
67
        }
68 1 1. equals : negated conditional → NO_COVERAGE
        if (obj == null) {
69 1 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return false;
70
        }
71 1 1. equals : negated conditional → NO_COVERAGE
        if (this.getClass() != obj.getClass()) {
72 1 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return false;
73
        }
74
75
        Diff other = (Diff) obj;
76 1 1. equals : negated conditional → NO_COVERAGE
        if (this.operation != other.operation) {
77 1 1. equals : replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE
            return false;
78
        }
79
80 1 1. equals : negated conditional → NO_COVERAGE
        if (this.text == null) {
81 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;
82
        } else {
83 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);
84
        }
85
    }
86
87
    @Override
88
    public int compareTo(Diff arg0) {
89 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(arg0.toString()) ? 0 : 1;
90
    }
91
92
93
    // Getter and setter
94
95
    public Operation getOperation() {
96 1 1. getOperation : replaced return value with null for com/jsql/model/injection/strategy/blind/patch/Diff::getOperation → NO_COVERAGE
        return this.operation;
97
    }
98
99
    public void setOperation(Operation operation) {
100
        this.operation = operation;
101
    }
102
103
    public String getText() {
104 1 1. getText : replaced return value with "" for com/jsql/model/injection/strategy/blind/patch/Diff::getText → NO_COVERAGE
        return this.text;
105
    }
106
107
    public void setText(String text) {
108
        this.text = text;
109
    }
110
}

Mutations

40

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

52

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

53

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

54

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

65

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

66

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

68

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

69

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

71

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

72

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
replaced boolean return with true for com/jsql/model/injection/strategy/blind/patch/Diff::equals → NO_COVERAGE

80

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

81

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

83

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

89

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

96

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

104

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.16.1