Skip to content

Commit e65ee92

Browse files
authored
Move tests out of geo ip processor tests (#114656)
1 parent 693fb95 commit e65ee92

File tree

3 files changed

+353
-433
lines changed

3 files changed

+353
-433
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.ingest.geoip;
11+
12+
import org.elasticsearch.common.util.set.Sets;
13+
import org.elasticsearch.test.ESTestCase;
14+
15+
import java.util.Set;
16+
17+
import static org.hamcrest.Matchers.empty;
18+
import static org.hamcrest.Matchers.equalTo;
19+
import static org.hamcrest.Matchers.is;
20+
21+
public class DatabaseTests extends ESTestCase {
22+
23+
public void testDatabasePropertyInvariants() {
24+
// the city database is like a specialization of the country database
25+
assertThat(Sets.difference(Database.Country.properties(), Database.City.properties()), is(empty()));
26+
assertThat(Sets.difference(Database.Country.defaultProperties(), Database.City.defaultProperties()), is(empty()));
27+
28+
// the isp database is like a specialization of the asn database
29+
assertThat(Sets.difference(Database.Asn.properties(), Database.Isp.properties()), is(empty()));
30+
assertThat(Sets.difference(Database.Asn.defaultProperties(), Database.Isp.defaultProperties()), is(empty()));
31+
32+
// the enterprise database is like these other databases joined together
33+
for (Database type : Set.of(
34+
Database.City,
35+
Database.Country,
36+
Database.Asn,
37+
Database.AnonymousIp,
38+
Database.ConnectionType,
39+
Database.Domain,
40+
Database.Isp
41+
)) {
42+
assertThat(Sets.difference(type.properties(), Database.Enterprise.properties()), is(empty()));
43+
}
44+
// but in terms of the default fields, it's like a drop-in replacement for the city database
45+
// n.b. this is just a choice we decided to make here at Elastic
46+
assertThat(Database.Enterprise.defaultProperties(), equalTo(Database.City.defaultProperties()));
47+
}
48+
}

0 commit comments

Comments
 (0)