| 1 |
|
package org.europa.together.utils; |
| 2 |
|
|
| 3 |
|
import java.lang.reflect.Constructor; |
| 4 |
|
import java.time.ZoneId; |
| 5 |
|
import org.europa.together.application.LogbackLogger; |
| 6 |
|
import org.europa.together.business.Logger; |
| 7 |
|
import static org.junit.jupiter.api.Assertions.*; |
| 8 |
|
import org.junit.jupiter.api.Test; |
| 9 |
|
import java.time.ZonedDateTime; |
| 10 |
|
import org.europa.together.JUnit5Preperator; |
| 11 |
|
import org.junit.jupiter.api.DisplayName; |
| 12 |
|
import org.junit.jupiter.api.extension.ExtendWith; |
| 13 |
|
import org.junit.jupiter.params.ParameterizedTest; |
| 14 |
|
import org.junit.jupiter.params.provider.ValueSource; |
| 15 |
|
import org.springframework.test.context.ContextConfiguration; |
| 16 |
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 17 |
|
|
| 18 |
|
@SuppressWarnings("unchecked") |
| 19 |
|
@ExtendWith({JUnit5Preperator.class}) |
| 20 |
|
@ExtendWith(SpringExtension.class) |
| 21 |
|
@ContextConfiguration(locations = {"/applicationContext.xml"}) |
| |
|
| 97.9% |
Uncovered Elements: 3 (145) |
Complexity: 55 |
Complexity Density: 0.61 |
|
| 22 |
|
public class ValidatorTest { |
| 23 |
|
|
| 24 |
|
private static final Logger LOGGER = new LogbackLogger(ValidatorTest.class); |
| 25 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
4-
|
|
| 26 |
1 |
@Test... |
| 27 |
|
void privateConstructor() throws Exception { |
| 28 |
1 |
Constructor<Validator> clazz |
| 29 |
|
= Validator.class.getDeclaredConstructor(); |
| 30 |
1 |
clazz.setAccessible(true); |
| 31 |
1 |
assertThrows(Exception.class, () -> { |
| 32 |
1 |
Validator call = clazz.newInstance(); |
| 33 |
|
}); |
| 34 |
|
} |
| 35 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 36 |
8 |
@ParameterizedTest... |
| 37 |
|
@ValueSource(strings = {"true", "false", "TRUE", "FALSE", "TrUe", |
| 38 |
|
"fAlSe", "1", "0"}) |
| 39 |
|
void isBooleanRegex(String input) { |
| 40 |
8 |
assertTrue(Validator.validate(input, Validator.BOOLEAN)); |
| 41 |
|
} |
| 42 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 43 |
2 |
@ParameterizedTest... |
| 44 |
|
@ValueSource(strings = {"-1", "5"}) |
| 45 |
|
void isNotBooleanRegex(String input) { |
| 46 |
2 |
assertFalse(Validator.validate(input, Validator.BOOLEAN)); |
| 47 |
|
} |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 49 |
4 |
@ParameterizedTest... |
| 50 |
|
@ValueSource(strings = {"1", "0000", "1234567890", "1 2 345 6 789 0"}) |
| 51 |
|
void isDigitRegex(String input) { |
| 52 |
4 |
assertTrue(Validator.validate(input, Validator.DIGIT)); |
| 53 |
|
} |
| 54 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 55 |
1 |
@ParameterizedTest... |
| 56 |
|
@ValueSource(strings = {"ABC.01"}) |
| 57 |
|
void isNotDigitRegex(String input) { |
| 58 |
1 |
assertFalse(Validator.validate(input, Validator.DIGIT)); |
| 59 |
|
} |
| 60 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 61 |
3 |
@ParameterizedTest... |
| 62 |
|
@ValueSource(strings = {"abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", |
| 63 |
|
"abc XYZ"}) |
| 64 |
|
void isCharacterRegex(String input) { |
| 65 |
3 |
assertTrue(Validator.validate(input, Validator.ASCII_CHARACTER)); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 68 |
2 |
@ParameterizedTest... |
| 69 |
|
@ValueSource(strings = {"äöü ÄÖÜ ß", "abc 123 XYZ"}) |
| 70 |
|
void isNotCharacterRegex(String input) { |
| 71 |
2 |
assertFalse(Validator.validate(input, Validator.ASCII_CHARACTER)); |
| 72 |
|
} |
| 73 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 74 |
7 |
@ParameterizedTest... |
| 75 |
|
@ValueSource(strings = {"A fool with a tool is still a fool.", "EN/00001.III-D", |
| 76 |
|
"Remember, remember the 1 st. of November!", "Math: 1 + ~1 : 12 * 4/3 = -10%", |
| 77 |
|
"Brackets: <>(){}[]", "Symbols 01: ?!.,;_", "Symbols 02: ¬&§$@€#"}) |
| 78 |
|
void isTextRegex(String input) { |
| 79 |
7 |
assertTrue(Validator.validate(input, Validator.TEXT)); |
| 80 |
|
} |
| 81 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 82 |
1 |
@ParameterizedTest... |
| 83 |
|
@ValueSource(strings = {"äöüÄÖÜß"}) |
| 84 |
|
void isNotTextRegex(String input) { |
| 85 |
1 |
assertFalse(Validator.validate(input, Validator.TEXT)); |
| 86 |
|
} |
| 87 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 88 |
4 |
@ParameterizedTest... |
| 89 |
|
@ValueSource(strings = {"abcdefXYZ", "a", "A", "ABCxyz"}) |
| 90 |
|
void isRegexLetters(String input) { |
| 91 |
4 |
assertTrue(Validator.validate(input, Validator.LETTERS)); |
| 92 |
|
} |
| 93 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 94 |
3 |
@ParameterizedTest... |
| 95 |
|
@ValueSource(strings = {"äöüÄÖÜß", "12345678890", "!§$%"}) |
| 96 |
|
void isNotRegexLetters(String input) { |
| 97 |
3 |
assertFalse(Validator.validate(input, Validator.LETTERS)); |
| 98 |
|
} |
| 99 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 100 |
10 |
@ParameterizedTest... |
| 101 |
|
@ValueSource(strings = {"0000", "1", "1234567890", "1 2 345 6 789 0", "0.0", |
| 102 |
|
"-0.0", "0.123456789", "-0.123456789", "0123456789.0987654321", "-0123456789.0987654321"}) |
| 103 |
|
void isFloatingPointRegex(String input) { |
| 104 |
10 |
assertTrue(Validator.validate(input, Validator.FLOATING_POINT)); |
| 105 |
|
} |
| 106 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 107 |
7 |
@ParameterizedTest... |
| 108 |
|
@ValueSource(strings = {"0.", "-0.", ".0", "-.0", ".", "-.", "ABC.01"}) |
| 109 |
|
void isNotFloatingPointRegex(String input) { |
| 110 |
7 |
assertFalse(Validator.validate(input, Validator.FLOATING_POINT)); |
| 111 |
|
} |
| 112 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 113 |
37 |
@ParameterizedTest... |
| 114 |
|
@ValueSource(strings = {"00:00", "00:01", "00:09", "00:10", "01:11", "01:19", |
| 115 |
|
"02:20", "02:21", "02:29", "03:30", "03:31", "03:39", "04:40", "04:41", |
| 116 |
|
"04:49", "05:50", "05:51", "05:59", "06:00", "07:00", "08:00", "09:00", |
| 117 |
|
"10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", |
| 118 |
|
"18:00", "19:00", "20:00", "21:00", "22:00", "23:00", "23:59"}) |
| 119 |
|
void isTime24Regex(String input) { |
| 120 |
37 |
assertTrue(Validator.validate(input, Validator.TIME_24H)); |
| 121 |
|
} |
| 122 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 123 |
9 |
@ParameterizedTest... |
| 124 |
|
@ValueSource(strings = {"24:00", "24:01", "25:00", "0:0", "1:20", "01:2", |
| 125 |
|
"10:60", "10:61", "10:69"}) |
| 126 |
|
void isNotTime24Regex(String input) { |
| 127 |
9 |
assertFalse(Validator.validate(input, Validator.TIME_24H)); |
| 128 |
|
} |
| 129 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 130 |
13 |
@ParameterizedTest... |
| 131 |
|
@ValueSource(strings = {"#000", "#fff", "#f0A", "#000000", "#123451", "#999999", |
| 132 |
|
"#aAAAaa", "#BBbbbb", "#cCcccC", "#dDdDdd", "#eEeeEE", "#fFFfff", "#996789"}) |
| 133 |
|
void isRGBColor(String input) { |
| 134 |
13 |
assertTrue(Validator.validate(input, Validator.RGB_COLOR)); |
| 135 |
|
} |
| 136 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 137 |
8 |
@ParameterizedTest... |
| 138 |
|
@ValueSource(strings = {"#0", "#11af990", "#9999", "#09090", "#a", "#ffff", |
| 139 |
|
"#ggg", "#AFaFA"}) |
| 140 |
|
void isNotRGBColor(String input) { |
| 141 |
8 |
assertFalse(Validator.validate(input, Validator.RGB_COLOR)); |
| 142 |
|
} |
| 143 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 144 |
1 |
@ParameterizedTest... |
| 145 |
|
@ValueSource(strings = {"localhost"}) |
| 146 |
|
void isValidIP4ForLocalhost(String input) { |
| 147 |
1 |
assertTrue(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 148 |
|
} |
| 149 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 150 |
1 |
@ParameterizedTest... |
| 151 |
|
@ValueSource(strings = {"localhost:80"}) |
| 152 |
|
void isValidIP4ForLocalhostWithPort(String input) { |
| 153 |
1 |
assertTrue(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 154 |
|
} |
| 155 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 156 |
10 |
@ParameterizedTest... |
| 157 |
|
@ValueSource(strings = {"0.0.0.0", "1.0.0.0", "0.1.0.0", "0.0.1.0", "0.0.0.1", |
| 158 |
|
"127.0.0.1", "20.20.20.20", "99.100.200.10", "140.145.240.245", "255.255.255.255"}) |
| 159 |
|
void isValidIP4(String input) { |
| 160 |
10 |
assertTrue(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 161 |
|
} |
| 162 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 163 |
25 |
@ParameterizedTest... |
| 164 |
|
@ValueSource(strings = {"127.0.0.1:80", "127.0.0.1:0", "127.0.0.1:1", "127.0.0.1:10", |
| 165 |
|
"127.0.0.1:100", "127.0.0.1:1000", "127.0.0.1:9999", "127.0.0.1:10000", "127.0.0.1:19999", |
| 166 |
|
"127.0.0.1:29999", "127.0.0.1:39999", "127.0.0.1:49999", "127.0.0.1:59999", |
| 167 |
|
"127.0.0.1:60000", "127.0.0.1:61000", "127.0.0.1:62000", "127.0.0.1:63000", |
| 168 |
|
"127.0.0.1:64000", "127.0.0.1:64999", "127.0.0.1:65000", "127.0.0.1:65499", |
| 169 |
|
"127.0.0.1:65500", "127.0.0.1:65529", "127.0.0.1:65530", "127.0.0.1:65535"}) |
| 170 |
|
void isValidIP4_WithPort(String input) { |
| 171 |
25 |
assertTrue(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 172 |
|
} |
| 173 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 174 |
2 |
@ParameterizedTest... |
| 175 |
|
@ValueSource(strings = {"127.0.0.1:65536", "127.0.0.1:555555"}) |
| 176 |
|
void isIP4_WithInvalidPort(String input) { |
| 177 |
2 |
assertFalse(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 178 |
|
} |
| 179 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 180 |
3 |
@ParameterizedTest... |
| 181 |
|
@ValueSource(strings = {"255.255.255", "255.255", "255"}) |
| 182 |
|
void isInvalidIP4_Format(String input) { |
| 183 |
3 |
assertFalse(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 184 |
|
} |
| 185 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 186 |
8 |
@ParameterizedTest... |
| 187 |
|
@ValueSource(strings = {"1.1.1.01", "1.1.1.001", "1.1.01.1", "1.1.001.1", |
| 188 |
|
"1.01.1.1", "1.001.1.1", "01.1.1.1", "001.1.1.1"}) |
| 189 |
|
void isInvalidIP4_LedingZeros(String input) { |
| 190 |
8 |
assertFalse(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 191 |
|
} |
| 192 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 193 |
5 |
@ParameterizedTest... |
| 194 |
|
@ValueSource(strings = {"256.255.255.255", "255.256.255.255", "255.255.256.255", |
| 195 |
|
"255.255.255.256", "355.255.255.255"}) |
| 196 |
|
void isInvalidIP4_Ending(String input) { |
| 197 |
5 |
assertFalse(Validator.validate(input, Validator.IP4_ADDRESS)); |
| 198 |
|
} |
| 199 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 200 |
14 |
@ParameterizedTest... |
| 201 |
|
@ValueSource(strings = {"1", "9", "1.0", "1.0.0", "1.10", "1.0.10", "10.100.1000", |
| 202 |
|
"123.1234.12345", "1234", "12.1-SNAPSHOT", "1.109.1234567890", "1-xYz", |
| 203 |
|
"1.2-SNAPSHOT", "1.2.3-xyzXYZxyzX"}) |
| 204 |
|
void isVersionNumber(String input) { |
| 205 |
14 |
assertTrue(Validator.validate(input, Validator.SEMANTIC_VERSION_NUMBER)); |
| 206 |
|
} |
| 207 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 208 |
4 |
@ParameterizedTest... |
| 209 |
|
@ValueSource(strings = {"0", "01.02", "1.0.03", "0.0.0-LABEL"}) |
| 210 |
|
void isNotVersionNumber_StartWithZero(String input) { |
| 211 |
4 |
assertFalse(Validator.validate(input, Validator.SEMANTIC_VERSION_NUMBER)); |
| 212 |
|
} |
| 213 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 214 |
8 |
@ParameterizedTest... |
| 215 |
|
@ValueSource(strings = {"1.0.0.0", "A", ".1", "1.", "1.0.", "1.0.0.", "1.0.0-", |
| 216 |
|
"1.0.0-abcabcabcab"}) |
| 217 |
|
void isNotVersionNumber_Format(String input) { |
| 218 |
8 |
assertFalse(Validator.validate(input, Validator.SEMANTIC_VERSION_NUMBER)); |
| 219 |
|
} |
| 220 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 221 |
9 |
@ParameterizedTest... |
| 222 |
|
@ValueSource(strings = {"john@sample.eu", "john.doe@sample.org", "john_doe@sample.org", |
| 223 |
|
"john-doe@sample.org", "john_doe@sample.org", "_john-doe@sample.org", "123@sample.org", |
| 224 |
|
"_1@sample.org", "a@sample.org"}) |
| 225 |
|
void isValidEMail(String input) { |
| 226 |
9 |
assertTrue(Validator.validate(input, Validator.E_MAIL_ADDRESS)); |
| 227 |
|
} |
| 228 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 229 |
4 |
@ParameterizedTest... |
| 230 |
|
@ValueSource(strings = {"john@sample", "john@", "@sample.o", "-john.sample.o",}) |
| 231 |
|
void isInvalidEMail(String input) { |
| 232 |
4 |
assertFalse(Validator.validate(input, Validator.E_MAIL_ADDRESS)); |
| 233 |
|
} |
| 234 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
4-
|
|
| 235 |
1 |
@Test... |
| 236 |
|
void isIntegerInRange() { |
| 237 |
1 |
assertTrue(Validator.isIntegerInRange(1, 1, 5)); |
| 238 |
1 |
assertTrue(Validator.isIntegerInRange(3, 1, 5)); |
| 239 |
1 |
assertTrue(Validator.isIntegerInRange(5, 1, 5)); |
| 240 |
|
} |
| 241 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 242 |
1 |
@Test... |
| 243 |
|
void isIntegerNotInRange() { |
| 244 |
1 |
assertFalse(Validator.isIntegerInRange(0, 1, 5)); |
| 245 |
1 |
assertFalse(Validator.isIntegerInRange(6, 1, 5)); |
| 246 |
|
} |
| 247 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 248 |
1 |
@Test... |
| 249 |
|
void isDateAfter() { |
| 250 |
|
|
| 251 |
1 |
assertTrue(Validator.isDateAfter(ZonedDateTime.now(), |
| 252 |
|
ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")))); |
| 253 |
|
|
| 254 |
1 |
assertTrue(Validator.isDateAfter(ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 255 |
|
ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")))); |
| 256 |
|
} |
| 257 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4-
|
|
| 258 |
1 |
@Test... |
| 259 |
|
void isDateNotAfter() { |
| 260 |
|
|
| 261 |
1 |
assertFalse(Validator.isDateAfter(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 262 |
|
ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")))); |
| 263 |
|
|
| 264 |
1 |
assertFalse(Validator.isDateAfter(null, null)); |
| 265 |
1 |
assertFalse(Validator.isDateAfter(ZonedDateTime.now(), null)); |
| 266 |
1 |
assertFalse(Validator.isDateAfter(null, ZonedDateTime.now())); |
| 267 |
|
|
| 268 |
1 |
assertFalse(Validator.isDateAfter(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), ZonedDateTime.now())); |
| 269 |
1 |
assertFalse(Validator.isDateAfter(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 270 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")))); |
| 271 |
|
} |
| 272 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 273 |
1 |
@Test... |
| 274 |
|
void isDateBefore() { |
| 275 |
|
|
| 276 |
1 |
assertTrue(Validator.isDateBefore(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 277 |
|
ZonedDateTime.now())); |
| 278 |
|
|
| 279 |
1 |
assertTrue(Validator.isDateBefore(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 280 |
|
ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")))); |
| 281 |
|
} |
| 282 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4-
|
|
| 283 |
1 |
@Test... |
| 284 |
|
void isDateNotBefore() { |
| 285 |
|
|
| 286 |
1 |
assertFalse(Validator.isDateAfter(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 287 |
|
ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")))); |
| 288 |
|
|
| 289 |
1 |
assertFalse(Validator.isDateBefore(null, null)); |
| 290 |
1 |
assertFalse(Validator.isDateBefore(ZonedDateTime.now(), null)); |
| 291 |
1 |
assertFalse(Validator.isDateBefore(null, ZonedDateTime.now())); |
| 292 |
|
|
| 293 |
1 |
assertFalse(Validator.isDateBefore(ZonedDateTime.now(), ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")))); |
| 294 |
1 |
assertFalse(Validator.isDateBefore(ZonedDateTime.of(2015, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 295 |
|
ZonedDateTime.of(2015, 12, 31, 23, 49, 0, 0, ZoneId.of("UTC")))); |
| 296 |
|
} |
| 297 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 298 |
1 |
@Test... |
| 299 |
|
void isDateInRange() { |
| 300 |
1 |
assertTrue(Validator.isDateInRange( |
| 301 |
|
ZonedDateTime.of(2015, 6, 15, 12, 0, 0, 0, ZoneId.of("UTC")), |
| 302 |
|
ZonedDateTime.of(2014, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 303 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")) |
| 304 |
|
)); |
| 305 |
|
} |
| 306 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 307 |
1 |
@Test... |
| 308 |
|
void isDateNotInRange() { |
| 309 |
1 |
ZonedDateTime check = ZonedDateTime.now(); |
| 310 |
1 |
assertFalse(Validator.isDateInRange(check, check, check)); |
| 311 |
|
} |
| 312 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 313 |
1 |
@Test... |
| 314 |
|
void isDateNotInRange_LowerBoundry() { |
| 315 |
1 |
assertFalse(Validator.isDateInRange( |
| 316 |
|
ZonedDateTime.of(2014, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 317 |
|
ZonedDateTime.of(2014, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 318 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")) |
| 319 |
|
)); |
| 320 |
|
} |
| 321 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 322 |
1 |
@Test... |
| 323 |
|
void isDateNotInRange_UpperBoundry() { |
| 324 |
1 |
assertFalse(Validator.isDateInRange( |
| 325 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")), |
| 326 |
|
ZonedDateTime.of(2014, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 327 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")) |
| 328 |
|
)); |
| 329 |
|
} |
| 330 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 331 |
1 |
@Test... |
| 332 |
|
void isDateNotInRange_After() { |
| 333 |
1 |
assertFalse(Validator.isDateInRange( |
| 334 |
|
ZonedDateTime.of(2017, 1, 1, 12, 0, 0, 0, ZoneId.of("UTC")), |
| 335 |
|
ZonedDateTime.of(2014, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 336 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")) |
| 337 |
|
)); |
| 338 |
|
} |
| 339 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 340 |
1 |
@Test... |
| 341 |
|
void isDateNotInRange_Before() { |
| 342 |
1 |
assertFalse(Validator.isDateInRange( |
| 343 |
|
ZonedDateTime.of(2013, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 344 |
|
ZonedDateTime.of(2014, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")), |
| 345 |
|
ZonedDateTime.of(2016, 12, 31, 23, 59, 0, 0, ZoneId.of("UTC")) |
| 346 |
|
)); |
| 347 |
|
} |
| 348 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
4-
|
|
| 349 |
1 |
@Test... |
| 350 |
|
void isDateNotInRange_NullPointer() { |
| 351 |
1 |
assertFalse(Validator.isDateInRange(null, ZonedDateTime.now(), ZonedDateTime.now())); |
| 352 |
1 |
assertFalse(Validator.isDateInRange(ZonedDateTime.now(), null, ZonedDateTime.now())); |
| 353 |
1 |
assertFalse(Validator.isDateInRange(ZonedDateTime.now(), ZonedDateTime.now(), null)); |
| 354 |
|
|
| 355 |
1 |
assertFalse(Validator.isDateInRange(ZonedDateTime.now(), null, null)); |
| 356 |
1 |
assertFalse(Validator.isDateInRange(null, ZonedDateTime.now(), null)); |
| 357 |
1 |
assertFalse(Validator.isDateInRange(null, null, ZonedDateTime.now())); |
| 358 |
|
|
| 359 |
1 |
assertFalse(Validator.isDateInRange(null, null, null)); |
| 360 |
|
} |
| 361 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
4-
|
|
| 362 |
1 |
@Test... |
| 363 |
|
void isValidIsbn10() { |
| 364 |
1 |
assertTrue(Validator.isIsbn("3836278340")); |
| 365 |
1 |
assertTrue(Validator.isIsbn("38-3627-834-0")); |
| 366 |
1 |
assertTrue(Validator.isIsbn("0-9752298-0-X")); |
| 367 |
|
} |
| 368 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 369 |
1 |
@Test... |
| 370 |
|
void isInvalidIsbn10() { |
| 371 |
1 |
assertFalse(Validator.isIsbn("3836278344")); |
| 372 |
1 |
assertFalse(Validator.isIsbn("9836278340")); |
| 373 |
|
} |
| 374 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 375 |
1 |
@Test... |
| 376 |
|
void isValidIsbn13() { |
| 377 |
1 |
assertTrue(Validator.isIsbn("9783836278348")); |
| 378 |
1 |
assertTrue(Validator.isIsbn("978-3-8362-7834-8")); |
| 379 |
|
} |
| 380 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 381 |
1 |
@Test... |
| 382 |
|
void isInvalidIsbn13() { |
| 383 |
1 |
assertFalse(Validator.isIsbn("9783846278348")); |
| 384 |
|
} |
| 385 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 386 |
1 |
@Test... |
| 387 |
|
void isInvalidIsbn_NotInterger() throws Exception { |
| 388 |
1 |
assertThrows(Exception.class, () -> { |
| 389 |
1 |
Validator.isIsbn("d836278340"); |
| 390 |
|
}); |
| 391 |
|
} |
| 392 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 393 |
1 |
@Test... |
| 394 |
|
void isInvalidIsbn_empty() throws Exception { |
| 395 |
1 |
assertThrows(Exception.class, () -> { |
| 396 |
1 |
Validator.isIsbn(""); |
| 397 |
|
}); |
| 398 |
|
} |
| 399 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 400 |
1 |
@Test... |
| 401 |
|
void isInvalidIsbn10_toShort() throws Exception { |
| 402 |
1 |
assertThrows(Exception.class, () -> { |
| 403 |
1 |
Validator.isIsbn("383627834"); |
| 404 |
|
}); |
| 405 |
|
} |
| 406 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 407 |
0 |
void isInvalidIsbn10_tolong() throws Exception {... |
| 408 |
0 |
assertThrows(Exception.class, () -> { |
| 409 |
0 |
Validator.isIsbn("38362783400"); |
| 410 |
|
}); |
| 411 |
|
} |
| 412 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 413 |
1 |
@Test... |
| 414 |
|
void isInvalidIsbn13_toShort() throws Exception { |
| 415 |
1 |
assertThrows(Exception.class, () -> { |
| 416 |
1 |
Validator.isIsbn("978383627834"); |
| 417 |
|
}); |
| 418 |
|
} |
| 419 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
| 420 |
1 |
@Test... |
| 421 |
|
void isInvalidIsbn13_tolong() throws Exception { |
| 422 |
1 |
assertThrows(Exception.class, () -> { |
| 423 |
1 |
Validator.isIsbn("97838362783481"); |
| 424 |
|
}); |
| 425 |
|
} |
| 426 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 427 |
1 |
@Test... |
| 428 |
|
void luhnNumberChecksumTest() { |
| 429 |
1 |
assertTrue(Validator.luhnNumberChecksum("5374343040363120")); |
| 430 |
|
} |
| 431 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 432 |
1 |
@Test... |
| 433 |
|
void failLuhnNumberChecksumTest() { |
| 434 |
1 |
assertFalse(Validator.luhnNumberChecksum("79927398713")); |
| 435 |
|
} |
| 436 |
|
|
| 437 |
|
} |