-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonalDataCheckServiceTest.java
More file actions
134 lines (99 loc) · 4.25 KB
/
PersonalDataCheckServiceTest.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
package org.eclipse.foodity.elasticsearch.service;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
class PersonalDataCheckServiceTest {
private final PersonalDataCheckService service = new PersonalDataCheckService();
@Test
void shouldNotFlagCoordinateTupleAsPhoneNumber() {
String content = "6.0366893 -4.9784965 54.0 3.0";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagUuidLikeNumericFragmentAsPhoneNumber() {
String content = "17024320-1817-4a6e-89f3-e3203273be1f";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagDateTimeFragmentAsPhoneNumber() {
String content = "16/06/2021 16:53";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagBarcodeLikeNumericIdentifierAsPhoneNumber() {
String content = "0000000000017";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagSlashSeparatedNumericIdentifierAsPhoneNumber() {
String content = "000/000/000/0017";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagSlashPathNumericIdentifierAsPhoneNumber() {
String content = "000/000/000/5";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagSlashTailNumericIdentifierAsPhoneNumber() {
String content = "0000000015707/8";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagDecimalNumericValueAsPhoneNumber() {
String content = "13.6857142857143";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagLeadingZerosIdentifierAsPhoneNumber() {
String content = "0000000005";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldFlagRealPhoneNumber() {
String content = "contact: +33 6 12 34 56 78";
assertThrows(PersonalDataException.class, () -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagLocalPhoneNumberWithoutCountryPrefix() {
String content = "0612345678";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagSlashSeparatedLocalPhoneWithoutCountryPrefix() {
String content = "06/12/34/56/78";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldFlagEuropeanInternationalPhoneNumber() {
String content = "0044 20 7946 0958";
assertThrows(PersonalDataException.class, () -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldNotFlagNonEuropeanInternationalPhoneNumber() {
String content = "+1 202 555 0123";
assertDoesNotThrow(() -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
@Test
void shouldFlagRealEmailAddress() {
String content = "mail=test.user@foodity.org";
assertThrows(PersonalDataException.class, () -> service
.validateHardPersonalDataOnly(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
}
}