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

Mutations

16

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

22

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

28

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

34

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

40

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

46

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

52

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

58

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

64

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

70

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

76

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

82

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

88

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

94

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

100

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

106

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

112

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

118

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

124

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

130

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

136

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

142

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

148

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

154

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

160

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

166

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

172

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

178

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

184

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

190

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

196

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

202

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

208

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

232

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

233

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

234

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

239

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

240

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

241

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

246

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

247

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

254

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