Skip to content

Commit 9f6b995

Browse files
Minor cleanup
1 parent ea4d2f0 commit 9f6b995

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpTestUtils.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.elasticsearch.common.CheckedBiFunction;
1818
import org.elasticsearch.common.network.InetAddresses;
1919
import org.elasticsearch.core.SuppressForbidden;
20+
import org.elasticsearch.ingest.geoip.MaxmindIpDataLookups.CacheableCityResponse;
21+
import org.elasticsearch.ingest.geoip.MaxmindIpDataLookups.CacheableCountryResponse;
2022

2123
import java.io.FileNotFoundException;
2224
import java.io.IOException;
@@ -42,7 +44,7 @@ private static boolean isDirectory(final Path path) {
4244
return path.toFile().isDirectory();
4345
}
4446

45-
public static void copyDatabase(final String databaseName, final Path destination) {
47+
static void copyDatabase(final String databaseName, final Path destination) {
4648
try (InputStream is = GeoIpTestUtils.class.getResourceAsStream("/" + databaseName)) {
4749
if (is == null) {
4850
throw new FileNotFoundException("Resource [" + databaseName + "] not found in classpath");
@@ -54,13 +56,13 @@ public static void copyDatabase(final String databaseName, final Path destinatio
5456
}
5557
}
5658

57-
public static void copyDefaultDatabases(final Path directory) {
59+
static void copyDefaultDatabases(final Path directory) {
5860
for (final String database : DEFAULT_DATABASES) {
5961
copyDatabase(database, directory);
6062
}
6163
}
6264

63-
public static void copyDefaultDatabases(final Path directory, ConfigDatabases configDatabases) {
65+
static void copyDefaultDatabases(final Path directory, ConfigDatabases configDatabases) {
6466
for (final String database : DEFAULT_DATABASES) {
6567
copyDatabase(database, directory);
6668
configDatabases.updateDatabase(directory.resolve(database), true);
@@ -73,12 +75,10 @@ public static void copyDefaultDatabases(final Path directory, ConfigDatabases co
7375
* <p>
7476
* Like this: {@code CacheableCityResponse city = loader.getResponse("some.ip.address", GeoIpTestUtils::getCity);}
7577
*/
76-
public static MaxmindIpDataLookups.CacheableCityResponse getCity(Reader reader, String ip) throws IOException {
78+
public static CacheableCityResponse getCity(Reader reader, String ip) throws IOException {
7779
DatabaseRecord<CityResponse> record = reader.getRecord(InetAddresses.forString(ip), CityResponse.class);
7880
CityResponse data = record.getData();
79-
return data == null
80-
? null
81-
: MaxmindIpDataLookups.CacheableCityResponse.from(new CityResponse(data, ip, record.getNetwork(), List.of("en")));
81+
return data == null ? null : CacheableCityResponse.from(new CityResponse(data, ip, record.getNetwork(), List.of("en")));
8282
}
8383

8484
/**
@@ -87,11 +87,9 @@ public static MaxmindIpDataLookups.CacheableCityResponse getCity(Reader reader,
8787
* <p>
8888
* Like this: {@code CacheableCountryResponse country = loader.getResponse("some.ip.address", GeoIpTestUtils::getCountry);}
8989
*/
90-
public static MaxmindIpDataLookups.CacheableCountryResponse getCountry(Reader reader, String ip) throws IOException {
90+
public static CacheableCountryResponse getCountry(Reader reader, String ip) throws IOException {
9191
DatabaseRecord<CountryResponse> record = reader.getRecord(InetAddresses.forString(ip), CountryResponse.class);
9292
CountryResponse data = record.getData();
93-
return data == null
94-
? null
95-
: MaxmindIpDataLookups.CacheableCountryResponse.from(new CountryResponse(data, ip, record.getNetwork(), List.of("en")));
93+
return data == null ? null : CacheableCountryResponse.from(new CountryResponse(data, ip, record.getNetwork(), List.of("en")));
9694
}
9795
}

0 commit comments

Comments
 (0)