Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonalDataCheckServiceTest.java
More file actions
Latest commit
134 lines (99 loc) · 4.25 KB
/
Copy pathPersonalDataCheckServiceTest.java
File metadata and controls
134 lines (99 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
packageorg.eclipse.foodity.elasticsearch.service;
importstaticorg.junit.jupiter.api.Assertions.assertDoesNotThrow;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importjava.io.ByteArrayInputStream;
importjava.nio.charset.StandardCharsets;
importorg.junit.jupiter.api.Test;
classPersonalDataCheckServiceTest {
privatefinalPersonalDataCheckServiceservice = newPersonalDataCheckService();
@Test
voidshouldNotFlagCoordinateTupleAsPhoneNumber() {
Stringcontent = "6.0366893 -4.9784965 54.0 3.0";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagUuidLikeNumericFragmentAsPhoneNumber() {
Stringcontent = "17024320-1817-4a6e-89f3-e3203273be1f";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagDateTimeFragmentAsPhoneNumber() {
Stringcontent = "16/06/2021 16:53";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagBarcodeLikeNumericIdentifierAsPhoneNumber() {
Stringcontent = "0000000000017";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagSlashSeparatedNumericIdentifierAsPhoneNumber() {
Stringcontent = "000/000/000/0017";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagSlashPathNumericIdentifierAsPhoneNumber() {
Stringcontent = "000/000/000/5";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagSlashTailNumericIdentifierAsPhoneNumber() {
Stringcontent = "0000000015707/8";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagDecimalNumericValueAsPhoneNumber() {
Stringcontent = "13.6857142857143";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagLeadingZerosIdentifierAsPhoneNumber() {
Stringcontent = "0000000005";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldFlagRealPhoneNumber() {
Stringcontent = "contact: +33 6 12 34 56 78";
assertThrows(PersonalDataException.class, () -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagLocalPhoneNumberWithoutCountryPrefix() {
Stringcontent = "0612345678";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagSlashSeparatedLocalPhoneWithoutCountryPrefix() {
Stringcontent = "06/12/34/56/78";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldFlagEuropeanInternationalPhoneNumber() {
Stringcontent = "0044 20 7946 0958";
assertThrows(PersonalDataException.class, () -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldNotFlagNonEuropeanInternationalPhoneNumber() {
Stringcontent = "+1 202 555 0123";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
voidshouldFlagRealEmailAddress() {
Stringcontent = "mail=test.user@foodity.org";
assertThrows(PersonalDataException.class, () -> service
.validateHardPersonalDataOnly(newByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
}