From 1b69abd09ebb40c3e2f57b674166b2e524cfd315 Mon Sep 17 00:00:00 2001 From: "Gabriele C." Date: Fri, 26 Apr 2024 01:29:21 +0200 Subject: [PATCH] Update to spigot 1.20.5, bump mvn plugin version, require jvm 17, require mvn 3.9, require spigot 1.19, use the spigot runtime dependency download system, use the official maxmind geoip database parser --- pom.xml | 518 ++++++++---------- .../authme/initialization/OnStartupTasks.java | 6 +- .../protocollib/InventoryPacketAdapter.java | 7 +- .../fr/xephi/authme/service/GeoIpService.java | 33 +- src/main/resources/plugin.yml | 22 +- .../persistence/LimboPersistenceTest.java | 5 +- .../authme/service/GeoIpServiceTest.java | 26 +- 7 files changed, 277 insertions(+), 340 deletions(-) diff --git a/pom.xml b/pom.xml index 581affd15..3f57df922 100644 --- a/pom.xml +++ b/pom.xml @@ -60,14 +60,13 @@ UTF-8 UTF-8 - 1.8 - 1.8 - 8 - 11 - 3.6.3 + 17 + 17 + 17 + 17 + 3.9.0 - 1.19.2-R0.1-SNAPSHOT AuthMe @@ -80,6 +79,31 @@ ${project.versionCode} ${project.groupId}.${project.artifactId}.${pluginDescription.name} sgdc3, ljacqu, games647, Hex3l, krusic22 + + + 1.0 + 1.0.0 + 4.2.0 + 2.5 + 1.6.0 + 5.1.0 + 2.0.13 + 0.1.1-SNAPSHOT + 8.3.0 + 3.3.3 + 42.5.1 + 1.1.4 + 2.11 + 0.9.0 + 1.5.0 + 1.4.1 + + 1.20.5-R0.1-SNAPSHOT + 31.1-jre + 2.10 + 2.19.0 + + 3.0.2 @@ -154,7 +178,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.6.3 @@ -164,7 +188,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.1.0 + 3.4.1 enforce-environment @@ -177,7 +201,7 @@ ${maven.minimumVersion} - [11,) + [${java.compiler.minimumVersion},) true @@ -189,19 +213,19 @@ org.apache.maven.plugins maven-clean-plugin - 3.2.0 + 3.3.2 org.apache.maven.plugins maven-resources-plugin - 3.3.0 + 3.3.1 org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.13.0 ${java.source} ${java.target} @@ -212,7 +236,13 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.12 + + + fr/xephi/authme/* + fr/xephi/authme/**/* + + pre-unit-test @@ -232,11 +262,12 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.2.5 + - -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=en @{argLine} + --add-opens=java.base/java.lang=ALL-UNNAMED -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=en @{argLine} ${project.skipExtendedHashTests} @@ -248,7 +279,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.1 @@ -257,7 +288,7 @@ ${project.finalNameBase} - 8 + ${java.source} @@ -272,7 +303,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.1 ${project.finalNameBase} @@ -289,7 +320,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.0 + 3.5.3 shaded-jar @@ -297,52 +328,6 @@ shade - - - - - com.google.guava:guava - com.google.guava:failureaccess - com.google.guava:listenablefuture - com.google.errorprone:error_prone_annotations - com.google.j2objc:j2objc-annotations - - com.google.code.gson:gson - - - - - - shaded-jar-legacy - package - - shade - - - ${project.finalNameBase}-legacy - - - com.google.common - fr.xephi.authme.libs.com.google.common - - - com.google.thirdparty - fr.xephi.authme.libs.com.google.thirdparty - - - com.google.j2objc - fr.xephi.authme.libs.com.google.j2objc - - - com.google.errorprone - fr.xephi.authme.libs.com.google.errorprone - - - com.google.gson - fr.xephi.authme.libs.com.google.gson - - - @@ -353,87 +338,10 @@ ${project.finalNameBase} - - + - ch.jalu - fr.xephi.authme.libs.ch.jalu - - - com.zaxxer.hikari - fr.xephi.authme.libs.com.zaxxer.hikari - - - org.slf4j - fr.xephi.authme.libs.org.slf4j - - - com.maxmind.db - fr.xephi.authme.libs.com.maxmind.db - - - com.ice.tar - fr.xephi.authme.libs.com.icetar.tar - - - net.ricecode.similarity - fr.xephi.authme.libs.ricecode.net.ricecode.similarity - - - de.rtner - fr.xephi.authme.libs.de.rtner - - - org.picketbox - fr.xephi.authme.libs.org.picketbox - - - org.jboss.crypto - fr.xephi.authme.libs.org.jboss.crypto - - - org.jboss.security - fr.xephi.authme.libs.org.jboss.security - - - de.mkammerer - fr.xephi.authme.libs.de.mkammerer - - - com.warrenstrange - fr.xephi.authme.libs.com.warrenstrange - - - javax.inject - fr.xephi.authme.libs.javax.inject - - - at.favre.lib - fr.xephi.authme.libs.at.favre.lib - - - org.postgresql - fr.xephi.authme.libs.org.postgresql - - - - org.bstats - fr.xephi.authme.libs.org.bstats - - - org.mariadb.jdbc - fr.xephi.authme.libs.org.mariadb.jdbc - - - com.mysql - fr.xephi.authme.libs.com.mysql - - - com.google.protobuf - fr.xephi.authme.libs.com.google.protobuf + ch.jalu.datasourcecolumns + fr.xephi.authme.libs.ch.jalu.datasourcecolumns @@ -467,13 +375,13 @@ org.apache.maven.plugins maven-install-plugin - 3.0.1 + 3.1.1 org.apache.maven.plugins maven-deploy-plugin - 3.0.0 + 3.1.1 @@ -602,54 +510,39 @@ ch.jalu injector - 1.0 - true + ${dependencies.injector.version} + provided net.ricecode string-similarity - 1.0.0 - true + ${dependencies.string-similarity.version} + provided - - + - com.maxmind.db - maxmind-db-gson - 2.0.3 - true - - - com.google.code.gson - gson - - + com.maxmind.geoip2 + geoip2 + ${dependencies.geoip2.version} + provided javatar javatar - 2.5 - true + ${dependencies.javatar.version} + provided org.apache.commons commons-email - 1.6-SNAPSHOT - true - - - - - org.apache.logging.log4j - log4j-core - 2.8.1 + ${dependencies.commons-email.version} provided @@ -657,88 +550,62 @@ com.zaxxer HikariCP - 4.0.3 - true - - - slf4j-api - org.slf4j - - - - - - org.slf4j - slf4j-simple - 1.7.36 - true - - - - - de.rtner - PBKDF2 - 1.1.4 - true - - - - - com.mysql - mysql-connector-j - 8.0.31 - true - - - org.mariadb.jdbc - mariadb-java-client - 3.0.8 - true - - - - - de.mkammerer - argon2-jvm-nolibs - 2.11 - true - - - - - com.warrenstrange - googleauth - 1.5.0 - true - - - - - org.spigotmc - spigot-api - ${spigot.version} + ${dependencies.hikaricp.version} provided - junit - junit - - - bungeecord-chat - net.md-5 - - - com.googlecode.json-simple - json-simple + org.slf4j + slf4j-api - - com.google.guava - guava - 31.0.1-jre - true + org.slf4j + slf4j-simple + ${dependencies.slf4j.version} + provided + + + + + ch.jalu + datasourcecolumns + ${dependencies.datasourcecolumns.version} + + + + + + com.mysql + mysql-connector-j + ${dependencies.mysql-connector-j.version} + provided + + + + + org.mariadb.jdbc + mariadb-java-client + ${dependencies.mariadb-java-client.version} + provided + + + org.checkerframework + checker-qual + + + com.google.errorprone + error_prone_annotations + + + + + + + org.postgresql + postgresql + ${dependencies.postgresql.version} + provided org.checkerframework @@ -746,43 +613,112 @@ - + + - com.google.code.gson - gson - 2.8.9 - true + de.rtner + PBKDF2 + ${dependencies.pbkdf2.version} + provided - + + + de.mkammerer + argon2-jvm-nolibs + ${dependencies.argon2-jvm-nolibs.version} + provided + + + + + at.favre.lib + bcrypt + ${dependencies.bcrypt.version} + provided + + + + + com.warrenstrange + googleauth + ${dependencies.googleauth.version} + provided + ch.jalu configme - 1.3.0 - true + ${dependencies.configme.version} + provided + + + + + org.spigotmc + spigot-api + ${dependencies.spigot.version} + provided + + com.google.guava + guava + + + com.google.code.gson + gson + + + org.joml + joml + + + net.md-5 + bungeecord-chat + org.yaml snakeyaml + + com.google.guava + guava + ${dependencies.guava.version} + provided + + + com.google.code.gson + gson + ${dependencies.gson.version} + provided + + + org.apache.logging.log4j + log4j-core + ${dependencies.log4j-core.version} + provided + + + org.bstats bstats-bukkit - 3.0.0 - true + ${dependencies.bstats.version} + provided + + com.comphenix.protocol ProtocolLib - 4.8.0 + 5.1.0 provided @@ -925,7 +861,7 @@ net.essentialsx EssentialsX - 2.19.7 + 2.20.1 provided @@ -971,14 +907,6 @@ - - - at.favre.lib - bcrypt - 0.9.0 - true - - de.luricos.bukkit @@ -987,60 +915,42 @@ provided - - ch.jalu - datasourcecolumns - 0.1.1-SNAPSHOT - true - - - - org.postgresql - postgresql - 42.5.0 - true - - - org.checkerframework - checker-qual - - - - + junit junit test 4.13.2 + + + org.hamcrest + hamcrest-core + + org.hamcrest - java-hamcrest + hamcrest test - 2.0.0.0 + 2.2 + org.mockito mockito-core test - 4.8.1 - - - hamcrest-core - org.hamcrest - - + 4.11.0 org.checkerframework checker-qual - 3.26.0 + 3.42.0 test @@ -1048,13 +958,19 @@ org.xerial sqlite-jdbc - 3.39.3.0 + 3.45.3.0 test + + + org.slf4j + slf4j-api + + com.h2database h2 - 2.1.214 + 2.2.224 test diff --git a/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java b/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java index 029c9b608..c750b6d11 100644 --- a/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java +++ b/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java @@ -32,7 +32,7 @@ import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS; */ public class OnStartupTasks { - private static ConsoleLogger consoleLogger = ConsoleLoggerFactory.get(OnStartupTasks.class); + private static final ConsoleLogger consoleLogger = ConsoleLoggerFactory.get(OnStartupTasks.class); @Inject private DataSource dataSource; @@ -53,6 +53,8 @@ public class OnStartupTasks { * @param settings the settings */ public static void sendMetrics(AuthMe plugin, Settings settings) { + // We do not relocate as the library is downloaded at runtime + System.setProperty("bstats.relocatecheck", "false"); final Metrics metrics = new Metrics(plugin, 164); metrics.addCustomChart(new SimplePie("messages_language", @@ -109,6 +111,6 @@ public class OnStartupTasks { } }); } - }, 1, TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL)); + }, 1, (long) TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL)); } } diff --git a/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java index bceeaca7a..bef64b3cf 100644 --- a/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java @@ -34,14 +34,13 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; class InventoryPacketAdapter extends PacketAdapter { private static final int PLAYER_INVENTORY = 0; - // http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 hotbar, 45 off hand) + // http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 hotbar, 45 offhand) // +1 because an index starts with 0 private static final int CRAFTING_SIZE = 5; private static final int ARMOR_SIZE = 4; @@ -116,8 +115,8 @@ class InventoryPacketAdapter extends PacketAdapter { try { protocolManager.sendServerPacket(player, inventoryPacket, false); - } catch (InvocationTargetException invocationExc) { - logger.logException("Error during sending blank inventory", invocationExc); + } catch (Throwable throwable) { + logger.logException("Error during sending blank inventory", throwable); } } } diff --git a/src/main/java/fr/xephi/authme/service/GeoIpService.java b/src/main/java/fr/xephi/authme/service/GeoIpService.java index d2e7324fe..fd365969b 100644 --- a/src/main/java/fr/xephi/authme/service/GeoIpService.java +++ b/src/main/java/fr/xephi/authme/service/GeoIpService.java @@ -4,12 +4,12 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.hash.HashCode; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; -import com.maxmind.db.GeoIp2Provider; -import com.maxmind.db.Reader; +import com.maxmind.db.CHMCache; import com.maxmind.db.Reader.FileMode; -import com.maxmind.db.cache.CHMCache; -import com.maxmind.db.model.Country; -import com.maxmind.db.model.CountryResponse; +import com.maxmind.geoip2.DatabaseReader; +import com.maxmind.geoip2.exception.GeoIp2Exception; +import com.maxmind.geoip2.model.AbstractCountryResponse; +import com.maxmind.geoip2.record.Country; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.output.ConsoleLoggerFactory; @@ -61,21 +61,21 @@ public class GeoIpService { private final BukkitService bukkitService; private final Settings settings; - private GeoIp2Provider databaseReader; + private DatabaseReader databaseReader; private volatile boolean downloading; @Inject - GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings) { + public GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings) { this.bukkitService = bukkitService; this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE); this.settings = settings; - // Fires download of recent data or the initialization of the look up service + // Fires download of recent data or the initialization of the look-up service isDataAvailable(); } @VisibleForTesting - GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings, GeoIp2Provider reader) { + GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings, DatabaseReader reader) { this.bukkitService = bukkitService; this.settings = settings; this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE); @@ -105,7 +105,7 @@ public class GeoIpService { if (Duration.between(lastModifiedTime.toInstant(), Instant.now()).toDays() <= UPDATE_INTERVAL_DAYS) { startReading(); - // don't fire the update task - we are up to date + // don't fire the update task - we are up-to-date return true; } else { logger.debug("GEO IP database is older than " + UPDATE_INTERVAL_DAYS + " Days"); @@ -149,6 +149,7 @@ public class GeoIpService { extractDatabase(downloadFile, tempFile); // MD5 checksum verification + //noinspection deprecation verifyChecksum(Hashing.md5(), tempFile, expectedChecksum); Files.copy(tempFile, dataFile, StandardCopyOption.REPLACE_EXISTING); @@ -170,7 +171,7 @@ public class GeoIpService { } private void startReading() throws IOException { - databaseReader = new Reader(dataFile.toFile(), FileMode.MEMORY, new CHMCache()); + databaseReader = new DatabaseReader.Builder(dataFile.toFile()).withCache(new CHMCache()).fileMode(FileMode.MEMORY).build(); logger.info(LICENSE); // clear downloading flag, because we now have working reader instance @@ -178,7 +179,7 @@ public class GeoIpService { } /** - * Downloads the archive to the destination file if it's newer than the locally version. + * Downloads the archive to the destination file if it's newer than the local version. * * @param lastModified modification timestamp of the already present file * @param destination save file @@ -220,7 +221,7 @@ public class GeoIpService { } /** - * Downloads the archive to the destination file if it's newer than the locally version. + * Downloads the archive to the destination file if it's newer than the local version. * * @param destination save file * @return null if no updates were found, the MD5 hash of the downloaded archive if successful @@ -320,11 +321,11 @@ public class GeoIpService { InetAddress address = InetAddress.getByName(ip); // Reader.getCountry() can be null for unknown addresses - return Optional.ofNullable(databaseReader.getCountry(address)).map(CountryResponse::getCountry); + return Optional.ofNullable(databaseReader.country(address)).map(AbstractCountryResponse::getCountry); } catch (UnknownHostException e) { // Ignore invalid ip addresses - // Legacy GEO IP Database returned a unknown country object with Country-Code: '--' and Country-Name: 'N/A' - } catch (IOException ioEx) { + // Legacy GEO IP Database returned an unknown country object with Country-Code: '--' and Country-Name: 'N/A' + } catch (GeoIp2Exception | IOException ioEx) { logger.logException("Cannot lookup country for " + ip + " at GEO IP database", ioEx); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index aa267deac..9391aedf2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,13 @@ +# noinspection YAMLSchemaValidation name: ${pluginDescription.name} +# noinspection YAMLSchemaValidation authors: [${pluginDescription.authors}] website: ${project.url} description: ${project.description} +# noinspection YAMLSchemaValidation main: ${pluginDescription.main} version: ${pluginDescription.version} -api-version: 1.13 +api-version: 1.19 softdepend: - Vault - LuckPerms @@ -15,6 +18,23 @@ softdepend: - Essentials - EssentialsSpawn - ProtocolLib +libraries: + - ch.jalu:injector:${dependencies.injector.version} + - net.ricecode:string-similarity:${dependencies.string-similarity.version} + - com.maxmind.geoip2:geoip2:${dependencies.geoip2.version} + - javatar:javatar:${dependencies.javatar.version} + - org.apache.commons:commons-email:${dependencies.commons-email.version} + - com.zaxxer:HikariCP:${dependencies.hikaricp.version} + - org.slf4j:slf4j-simple:${dependencies.slf4j.version} + - com.mysql:mysql-connector-j:${dependencies.mysql-connector-j.version} + - org.mariadb.jdbc:mariadb-java-client:${dependencies.mariadb-java-client.version} + - org.postgresql:postgresql:${dependencies.postgresql.version} + - de.rtner:PBKDF2:${dependencies.pbkdf2.version} + - de.mkammerer:argon2-jvm-nolibs:${dependencies.argon2-jvm-nolibs.version} + - at.favre.lib:bcrypt:${dependencies.bcrypt.version} + - com.warrenstrange:googleauth:${dependencies.googleauth.version} + - ch.jalu:configme:${dependencies.configme.version} + - org.bstats:bstats-bukkit:${dependencies.bstats.version} commands: authme: description: AuthMe op commands diff --git a/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java b/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java index b9ac1cd81..e8aba73fe 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java @@ -18,6 +18,7 @@ import org.mockito.Mock; import java.util.logging.Logger; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -25,7 +26,6 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; @@ -40,6 +40,7 @@ import static org.mockito.hamcrest.MockitoHamcrest.argThat; @RunWith(DelayedInjectionRunner.class) public class LimboPersistenceTest { + @SuppressWarnings("unused") @InjectDelayed private LimboPersistence limboPersistence; @@ -59,7 +60,7 @@ public class LimboPersistenceTest { public void setUpMocks() { given(settings.getProperty(LimboSettings.LIMBO_PERSISTENCE_TYPE)).willReturn(LimboPersistenceType.DISABLED); given(handlerFactory.newInstance(any(Class.class))) - .willAnswer(invocation -> mock(invocation.getArgument(0))); + .willAnswer(invocation -> mock((Class) invocation.getArgument(0))); } @Test diff --git a/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java b/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java index 8654ec8b5..9dea8037b 100644 --- a/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java @@ -1,13 +1,12 @@ package fr.xephi.authme.service; -import com.maxmind.db.GeoIp2Provider; -import com.maxmind.db.model.Country; -import com.maxmind.db.model.CountryResponse; - import java.io.File; import java.io.IOException; import java.net.InetAddress; +import com.maxmind.geoip2.DatabaseReader; +import com.maxmind.geoip2.model.CountryResponse; +import com.maxmind.geoip2.record.Country; import fr.xephi.authme.settings.Settings; import org.junit.Before; import org.junit.Rule; @@ -17,11 +16,11 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -33,10 +32,9 @@ import static org.mockito.Mockito.verify; public class GeoIpServiceTest { private GeoIpService geoIpService; - private File dataFolder; @Mock - private GeoIp2Provider lookupService; + private DatabaseReader lookupService; @Mock private BukkitService bukkitService; @@ -49,7 +47,7 @@ public class GeoIpServiceTest { @Before public void initializeGeoLiteApi() throws IOException { - dataFolder = temporaryFolder.newFolder(); + File dataFolder = temporaryFolder.newFolder(); geoIpService = new GeoIpService(dataFolder, bukkitService, settings, lookupService); } @@ -64,14 +62,14 @@ public class GeoIpServiceTest { CountryResponse response = mock(CountryResponse.class); given(response.getCountry()).willReturn(country); - given(lookupService.getCountry(ip)).willReturn(response); + given(lookupService.country(ip)).willReturn(response); // when String result = geoIpService.getCountryCode(ip.getHostAddress()); // then assertThat(result, equalTo(countryCode)); - verify(lookupService).getCountry(ip); + verify(lookupService).country(ip); } @Test @@ -84,7 +82,7 @@ public class GeoIpServiceTest { // then assertThat(result, equalTo("LOCALHOST")); - verify(lookupService, never()).getCountry(any()); + verify(lookupService, never()).country(any()); } @Test @@ -98,14 +96,14 @@ public class GeoIpServiceTest { CountryResponse response = mock(CountryResponse.class); given(response.getCountry()).willReturn(country); - given(lookupService.getCountry(ip)).willReturn(response); + given(lookupService.country(ip)).willReturn(response); // when String result = geoIpService.getCountryName(ip.getHostAddress()); // then assertThat(result, equalTo(countryName)); - verify(lookupService).getCountry(ip); + verify(lookupService).country(ip); } @Test @@ -118,6 +116,6 @@ public class GeoIpServiceTest { // then assertThat(result, equalTo("LocalHost")); - verify(lookupService, never()).getCountry(ip); + verify(lookupService, never()).country(ip); } }