ActionCoder.java

1
package com.jsql.util.bruter;
2
3
import com.jsql.util.StringUtil;
4
import org.apache.commons.text.StringEscapeUtils;
5
6
import java.io.IOException;
7
import java.security.NoSuchAlgorithmException;
8
import java.util.Arrays;
9
import java.util.List;
10
import java.util.Optional;
11
import java.util.stream.Collectors;
12
13
public enum ActionCoder {
14
    MD2(Coder.MD2.label, true) {
15
        @Override
16
        public String run(String value) throws NoSuchAlgorithmException {
17 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$1::run → KILLED
            return HashUtil.toHash(this.name, value);
18
        }
19
    },
20
    MD4(Coder.MD4.label, true) {
21
        @Override
22
        public String run(String value) {
23 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$2::run → KILLED
            return HashUtil.toMd4(value);
24
        }
25
    },
26
    MD5(Coder.MD5.label, true) {
27
        @Override
28
        public String run(String value) throws NoSuchAlgorithmException {
29 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$3::run → KILLED
            return HashUtil.toHash(this.name, value);
30
        }
31
    },
32
    SHA_1(Coder.SHA1.label, true) {
33
        @Override
34
        public String run(String value) throws NoSuchAlgorithmException {
35 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$4::run → KILLED
            return HashUtil.toHash(this.name, value);
36
        }
37
    },
38
    SHA_256(Coder.SHA256.label, true) {
39
        @Override
40
        public String run(String value) throws NoSuchAlgorithmException {
41 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$5::run → KILLED
            return HashUtil.toHash(this.name, value);
42
        }
43
    },
44
    SHA_384(Coder.SHA384.label, true) {
45
        @Override
46
        public String run(String value) throws NoSuchAlgorithmException {
47 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$6::run → KILLED
            return HashUtil.toHash(this.name, value);
48
        }
49
    },
50
    SHA_512(Coder.SHA512.label, true) {
51
        @Override
52
        public String run(String value) throws NoSuchAlgorithmException {
53 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$7::run → KILLED
            return HashUtil.toHash(this.name, value);
54
        }
55
    },
56
    MYSQL(Coder.MYSQL.label, true) {
57
        @Override
58
        public String run(String value) throws NoSuchAlgorithmException {
59 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$8::run → KILLED
            return HashUtil.toMySql(value);
60
        }
61
    },
62
    ADLER32(Coder.ADLER32.label, true, false) {
63
        @Override
64
        public String run(String value) {
65 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$9::run → NO_COVERAGE
            return HashUtil.toAdler32(value);
66
        }
67
    },
68
    CRC16(Coder.CRC16.label, true, false) {
69
        @Override
70
        public String run(String value) {
71 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$10::run → NO_COVERAGE
            return HashUtil.toCrc16(value);
72
        }
73
    },
74
    CRC32(Coder.CRC32.label, true, false) {
75
        @Override
76
        public String run(String value) {
77 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$11::run → NO_COVERAGE
            return HashUtil.toCrc32(value);
78
        }
79
    },
80
    CRC64(Coder.CRC64.label, true, false) {
81
        @Override
82
        public String run(String value) {
83 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$12::run → NO_COVERAGE
            return HashUtil.toCrc64(value);
84
        }
85
    },
86
    ENCODE_TO_HEX(ActionCoder.ENCODE_TO + Coder.HEX) {
87
        @Override
88
        public String run(String value) {
89 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$13::run → NO_COVERAGE
            return StringUtil.toHex(value);
90
        }
91
    },
92
    ENCODE_TO_HEX_ZIP(ActionCoder.ENCODE_TO + Coder.HEX_ZIP) {
93
        @Override
94
        public String run(String value) throws IOException {
95 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$14::run → NO_COVERAGE
            return StringUtil.toHexZip(value);
96
        }
97
    },
98
    ENCODE_TO_BASE64_ZIP(ActionCoder.ENCODE_TO + Coder.BASE64_ZIP) {
99
        @Override
100
        public String run(String value) throws IOException {
101 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$15::run → NO_COVERAGE
            return StringUtil.toBase64Zip(value);
102
        }
103
    },
104
    ENCODE_TO_BASE64(ActionCoder.ENCODE_TO + Coder.BASE64) {
105
        @Override
106
        public String run(String value) {
107 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$16::run → NO_COVERAGE
            return StringUtil.base64Encode(value);
108
        }
109
    },
110
    ENCODE_TO_BASE32(ActionCoder.ENCODE_TO + Coder.BASE32) {
111
        @Override
112
        public String run(String value) {
113 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$17::run → NO_COVERAGE
            return StringUtil.base32Encode(value);
114
        }
115
    },
116
    ENCODE_TO_BASE58(ActionCoder.ENCODE_TO + Coder.BASE58) {
117
        @Override
118
        public String run(String value) {
119 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$18::run → NO_COVERAGE
            return StringUtil.base58Encode(value);
120
        }
121
    },
122
    ENCODE_TO_BASE16(ActionCoder.ENCODE_TO + Coder.BASE16) {
123
        @Override
124
        public String run(String value) {
125 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$19::run → NO_COVERAGE
            return StringUtil.base16Encode(value);
126
        }
127
    },
128
    ENCODE_TO_HTML(ActionCoder.ENCODE_TO + Coder.HTML) {
129
        @Override
130
        public String run(String value) {
131 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$20::run → NO_COVERAGE
            return StringUtil.toHtml(value);
132
        }
133
    },
134
    ENCODE_TO_HTML_DECIMAL(ActionCoder.ENCODE_TO + Coder.HTML_DECIMAL) {
135
        @Override
136
        public String run(String value) {
137 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$21::run → NO_COVERAGE
            return StringUtil.toHtmlDecimal(value);
138
        }
139
    },
140
    ENCODE_TO_URL(ActionCoder.ENCODE_TO + Coder.URL) {
141
        @Override
142
        public String run(String value) {
143 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$22::run → NO_COVERAGE
            return StringUtil.toUrl(value);
144
        }
145
    },
146
    ENCODE_TO_UNICODE(ActionCoder.ENCODE_TO + Coder.UNICODE) {
147
        @Override
148
        public String run(String value) {
149 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$23::run → NO_COVERAGE
            return StringEscapeUtils.escapeJava(value);
150
        }
151
    },
152
    DECODE_FROM_HEX(ActionCoder.DECODE_FROM + Coder.HEX) {
153
        @Override
154
        public String run(String value) {
155 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$24::run → NO_COVERAGE
            return StringUtil.fromHex(value);
156
        }
157
    },
158
    DECODE_FROM_HEX_ZIP(ActionCoder.DECODE_FROM + Coder.HEX_ZIP) {
159
        @Override
160
        public String run(String value) throws IOException {
161 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$25::run → NO_COVERAGE
            return StringUtil.fromHexZip(value);
162
        }
163
    },
164
    DECODE_FROM_BASE64_ZIP(ActionCoder.DECODE_FROM + Coder.BASE64_ZIP) {
165
        @Override
166
        public String run(String value) throws IOException {
167 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$26::run → NO_COVERAGE
            return StringUtil.fromBase64Zip(value);
168
        }
169
    },
170
    DECODE_FROM_BASE64(ActionCoder.DECODE_FROM + Coder.BASE64) {
171
        @Override
172
        public String run(String value) {
173 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$27::run → NO_COVERAGE
            return StringUtil.base64Decode(value);
174
        }
175
    },
176
    DECODE_FROM_BASE32(ActionCoder.DECODE_FROM + Coder.BASE32) {
177
        @Override
178
        public String run(String value) {
179 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$28::run → NO_COVERAGE
            return StringUtil.base32Decode(value);
180
        }
181
    },
182
    DECODE_FROM_BASE58(ActionCoder.DECODE_FROM + Coder.BASE58) {
183
        @Override
184
        public String run(String value) {
185 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$29::run → NO_COVERAGE
            return StringUtil.base58Decode(value);
186
        }
187
    },
188
    DECODE_FROM_BASE16(ActionCoder.DECODE_FROM + Coder.BASE16) {
189
        @Override
190
        public String run(String value) {
191 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$30::run → NO_COVERAGE
            return StringUtil.base16Decode(value);
192
        }
193
    },
194
    DECODE_FROM_HTML(ActionCoder.DECODE_FROM + Coder.HTML) {
195
        @Override
196
        public String run(String value) {
197 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$31::run → NO_COVERAGE
            return StringUtil.fromHtml(value);
198
        }
199
    },
200
    DECODE_FROM_UNICODE(ActionCoder.DECODE_FROM + Coder.UNICODE) {
201
        @Override
202
        public String run(String value) {
203 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$32::run → NO_COVERAGE
            return StringEscapeUtils.unescapeJava(value);
204
        }
205
    },
206
    DECODE_FROM_URL(ActionCoder.DECODE_FROM + Coder.URL) {
207
        @Override
208
        public String run(String value) {
209 1 1. run : replaced return value with "" for com/jsql/util/bruter/ActionCoder$33::run → NO_COVERAGE
            return StringUtil.fromUrl(value);
210
        }
211
    };
212
213
    public static final String ENCODE_TO = "Encode to ";
214
    public static final String DECODE_FROM = "Decode from ";
215
    
216
    protected final String name;
217
    private final boolean isHash;
218
    private final boolean isEmptyPossible;
219
220
    ActionCoder(String name) {
221
        this(name, false, false);
222
    }
223
    ActionCoder(String name, boolean isHash) {
224
        this(name, isHash, true);
225
    }
226
    ActionCoder(String name, boolean isHash, boolean isEmptyPossible) {
227
        this.name = name;
228
        this.isHash = isHash;
229
        this.isEmptyPossible = isEmptyPossible;
230
    }
231
232
    public static List<String> getHashes() {
233 1 1. getHashes : replaced return value with Collections.emptyList for com/jsql/util/bruter/ActionCoder::getHashes → NO_COVERAGE
        return Arrays.stream(ActionCoder.values())
234 2 1. lambda$getHashes$0 : replaced boolean return with true for com/jsql/util/bruter/ActionCoder::lambda$getHashes$0 → NO_COVERAGE
2. lambda$getHashes$0 : replaced boolean return with false for com/jsql/util/bruter/ActionCoder::lambda$getHashes$0 → NO_COVERAGE
            .filter(action -> action.isHash)
235 1 1. lambda$getHashes$1 : replaced return value with "" for com/jsql/util/bruter/ActionCoder::lambda$getHashes$1 → NO_COVERAGE
            .map(actionCoder -> actionCoder.name)
236
            .collect(Collectors.toList());
237
    }
238
239
    public static List<String> getHashesEmpty() {
240 1 1. getHashesEmpty : replaced return value with Collections.emptyList for com/jsql/util/bruter/ActionCoder::getHashesEmpty → SURVIVED
        return Arrays.stream(ActionCoder.values())
241 3 1. lambda$getHashesEmpty$2 : negated conditional → SURVIVED
2. lambda$getHashesEmpty$2 : replaced boolean return with true for com/jsql/util/bruter/ActionCoder::lambda$getHashesEmpty$2 → KILLED
3. lambda$getHashesEmpty$2 : negated conditional → KILLED
            .filter(action -> action.isHash && action.isEmptyPossible)
242 1 1. lambda$getHashesEmpty$3 : replaced return value with "" for com/jsql/util/bruter/ActionCoder::lambda$getHashesEmpty$3 → KILLED
            .map(actionCoder -> actionCoder.name)
243
            .collect(Collectors.toList());
244
    }
245
246
    public static Optional<ActionCoder> forName(String name) {
247 1 1. forName : replaced return value with Optional.empty for com/jsql/util/bruter/ActionCoder::forName → KILLED
        return Arrays.stream(ActionCoder.values())
248 2 1. lambda$forName$4 : replaced boolean return with true for com/jsql/util/bruter/ActionCoder::lambda$forName$4 → SURVIVED
2. lambda$forName$4 : replaced boolean return with false for com/jsql/util/bruter/ActionCoder::lambda$forName$4 → KILLED
            .filter(action -> name.equals(action.name))
249
            .findFirst();
250
    }
251
252
    public abstract String run(String value) throws IOException, NoSuchAlgorithmException;
253
254
    public String getName() {
255 1 1. getName : replaced return value with "" for com/jsql/util/bruter/ActionCoder::getName → NO_COVERAGE
        return this.name;
256
    }
257
}

Mutations

17

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$1::run → KILLED

23

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$2::run → KILLED

29

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$3::run → KILLED

35

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$4::run → KILLED

41

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$5::run → KILLED

47

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$6::run → KILLED

53

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$7::run → KILLED

59

1.1
Location : run
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder$8::run → KILLED

65

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$9::run → NO_COVERAGE

71

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$10::run → NO_COVERAGE

77

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$11::run → NO_COVERAGE

83

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$12::run → NO_COVERAGE

89

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$13::run → NO_COVERAGE

95

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$14::run → NO_COVERAGE

101

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$15::run → NO_COVERAGE

107

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$16::run → NO_COVERAGE

113

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$17::run → NO_COVERAGE

119

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$18::run → NO_COVERAGE

125

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$19::run → NO_COVERAGE

131

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$20::run → NO_COVERAGE

137

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$21::run → NO_COVERAGE

143

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$22::run → NO_COVERAGE

149

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$23::run → NO_COVERAGE

155

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$24::run → NO_COVERAGE

161

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$25::run → NO_COVERAGE

167

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$26::run → NO_COVERAGE

173

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$27::run → NO_COVERAGE

179

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$28::run → NO_COVERAGE

185

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$29::run → NO_COVERAGE

191

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$30::run → NO_COVERAGE

197

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$31::run → NO_COVERAGE

203

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$32::run → NO_COVERAGE

209

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder$33::run → NO_COVERAGE

233

1.1
Location : getHashes
Killed by : none
replaced return value with Collections.emptyList for com/jsql/util/bruter/ActionCoder::getHashes → NO_COVERAGE

234

1.1
Location : lambda$getHashes$0
Killed by : none
replaced boolean return with true for com/jsql/util/bruter/ActionCoder::lambda$getHashes$0 → NO_COVERAGE

2.2
Location : lambda$getHashes$0
Killed by : none
replaced boolean return with false for com/jsql/util/bruter/ActionCoder::lambda$getHashes$0 → NO_COVERAGE

235

1.1
Location : lambda$getHashes$1
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder::lambda$getHashes$1 → NO_COVERAGE

240

1.1
Location : getHashesEmpty
Killed by : none
replaced return value with Collections.emptyList for com/jsql/util/bruter/ActionCoder::getHashesEmpty → SURVIVED
Covering tests

241

1.1
Location : lambda$getHashesEmpty$2
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced boolean return with true for com/jsql/util/bruter/ActionCoder::lambda$getHashesEmpty$2 → KILLED

2.2
Location : lambda$getHashesEmpty$2
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
negated conditional → KILLED

3.3
Location : lambda$getHashesEmpty$2
Killed by : none
negated conditional → SURVIVED
Covering tests

242

1.1
Location : lambda$getHashesEmpty$3
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with "" for com/jsql/util/bruter/ActionCoder::lambda$getHashesEmpty$3 → KILLED

247

1.1
Location : forName
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced return value with Optional.empty for com/jsql/util/bruter/ActionCoder::forName → KILLED

248

1.1
Location : lambda$forName$4
Killed by : StringUtilSpock.[engine:spock]/[spec:StringUtilSpock]/[feature:$spock_feature_0_0]
replaced boolean return with false for com/jsql/util/bruter/ActionCoder::lambda$forName$4 → KILLED

2.2
Location : lambda$forName$4
Killed by : none
replaced boolean return with true for com/jsql/util/bruter/ActionCoder::lambda$forName$4 → SURVIVED
Covering tests

255

1.1
Location : getName
Killed by : none
replaced return value with "" for com/jsql/util/bruter/ActionCoder::getName → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1