Skip to content

Commit 0c4bc9b

Browse files
committed
Drop the buildEvent helper
1 parent cd41af1 commit 0c4bc9b

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,30 @@
2828
* https://publicsuffix.org/learn/
2929
*/
3030
public class RegisteredDomainProcessorTests extends ESTestCase {
31-
private Map<String, Object> buildEvent(String domain) {
32-
return Map.of("domain", domain);
33-
}
3431

3532
public void testBasic() throws Exception {
36-
testRegisteredDomainProcessor(buildEvent("www.google.com"), "www.google.com", "google.com", "com", "www");
37-
testRegisteredDomainProcessor(buildEvent("google.com"), "google.com", "google.com", "com", null);
38-
testRegisteredDomainProcessor(buildEvent(""), null, null, null, null);
39-
testRegisteredDomainProcessor(buildEvent("."), null, null, null, null);
40-
testRegisteredDomainProcessor(buildEvent("$"), null, null, null, null);
41-
testRegisteredDomainProcessor(buildEvent("foo.bar.baz"), null, null, null, null);
42-
testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books");
33+
testRegisteredDomainProcessor("www.google.com", "www.google.com", "google.com", "com", "www");
34+
testRegisteredDomainProcessor("google.com", "google.com", "google.com", "com", null);
35+
testRegisteredDomainProcessor("", null, null, null, null);
36+
testRegisteredDomainProcessor(".", null, null, null, null);
37+
testRegisteredDomainProcessor("$", null, null, null, null);
38+
testRegisteredDomainProcessor("foo.bar.baz", null, null, null, null);
39+
testRegisteredDomainProcessor("www.books.amazon.co.uk", "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books");
4340
// Verify "com" is returned as the eTLD, for that FQDN or subdomain
44-
testRegisteredDomainProcessor(buildEvent("com"), "com", null, "com", null);
45-
testRegisteredDomainProcessor(buildEvent("example.com"), "example.com", "example.com", "com", null);
46-
testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", "googleapis.com", "com", null);
41+
testRegisteredDomainProcessor("com", "com", null, "com", null);
42+
testRegisteredDomainProcessor("example.com", "example.com", "example.com", "com", null);
43+
testRegisteredDomainProcessor("googleapis.com", "googleapis.com", "googleapis.com", "com", null);
4744
testRegisteredDomainProcessor(
48-
buildEvent("content-autofill.googleapis.com"),
45+
"content-autofill.googleapis.com",
4946
"content-autofill.googleapis.com",
5047
"googleapis.com",
5148
"com",
5249
"content-autofill"
5350
);
5451
// Verify "ssl.fastly.net" is returned as the eTLD, for that FQDN or subdomain
52+
testRegisteredDomainProcessor("global.ssl.fastly.net", "global.ssl.fastly.net", "global.ssl.fastly.net", "ssl.fastly.net", null);
5553
testRegisteredDomainProcessor(
56-
buildEvent("global.ssl.fastly.net"),
57-
"global.ssl.fastly.net",
58-
"global.ssl.fastly.net",
59-
"ssl.fastly.net",
60-
null
61-
);
62-
testRegisteredDomainProcessor(
63-
buildEvent("1.www.global.ssl.fastly.net"),
54+
"1.www.global.ssl.fastly.net",
6455
"1.www.global.ssl.fastly.net",
6556
"global.ssl.fastly.net",
6657
"ssl.fastly.net",
@@ -121,7 +112,7 @@ public void testIgnoreMissing() throws Exception {
121112
}
122113

123114
private void testRegisteredDomainProcessor(
124-
Map<String, Object> source,
115+
String fqdn,
125116
String expectedDomain,
126117
String expectedRegisteredDomain,
127118
String expectedETLD,
@@ -134,7 +125,7 @@ private void testRegisteredDomainProcessor(
134125

135126
var processor = new RegisteredDomainProcessor(null, null, "domain", "url", true);
136127

137-
IngestDocument document = TestIngestDocument.withDefaultVersion(source);
128+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of("domain", fqdn));
138129
processor.execute(document);
139130

140131
String domain = document.getFieldValue(domainField, String.class, expectedDomain == null);

0 commit comments

Comments
 (0)