Update test dependencies / remove unnecessary public modifiers

- Update JUnit, Hamcrest, Mockito versions
- Remove Hamcrest exclusion from Mockito (they've removed Hamcrest as dependency a long time ago)
- Remove public modifiers from test methods and refactor them to be in line with our usual pattern
This commit is contained in:
ljacqu 2023-12-20 10:12:44 +01:00
parent ee424378ca
commit 67ec2189b2
5 changed files with 16 additions and 18 deletions

16
pom.xml
View File

@ -1013,33 +1013,27 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
<version>5.7.1</version>
<version>5.10.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
<version>5.7.1</version>
<version>5.10.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
<version>2.0.0.0</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<version>4.8.1</version>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>

View File

@ -243,9 +243,12 @@ class AuthMeApiTest {
}
@Test
public void testGetLastLoginMillis() {
AuthMeApi result = AuthMeApi.getInstance();
assertThat(result.getLastLoginTime("notAPlayer"), nullValue());
void shouldReturnNullLastLoginForUnknownPlayer() {
// given / when
Instant result = api.getLastLoginTime("notAPlayer");
// then
assertThat(result, nullValue());
}
@Test

View File

@ -59,7 +59,7 @@ class LimboPersistenceTest {
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

View File

@ -120,7 +120,7 @@ class GeoIpServiceTest {
}
@Test
public void shouldNotLookUpCountryNameIfDisabled() throws Exception {
void shouldNotLookUpCountryNameIfDisabled() throws Exception {
// given
InetAddress ip = InetAddress.getByName("24.45.167.89");
given(settings.getProperty(ProtectionSettings.ENABLE_GEOIP)).willReturn(false);

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.settings;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.service.BukkitService;
@ -60,7 +59,8 @@ class SettingsWarnerTest {
}
@Test
public void shouldWarnBungeeWithoutSpigot() {
void shouldWarnBungeeWithoutSpigot() {
// given
Logger logger = TestHelper.setupLogger();
// this cannot be covered above, because it's conflicting with the other settings
@ -81,6 +81,7 @@ class SettingsWarnerTest {
@Test
void shouldNotLogAnyWarning() {
// given
Logger logger = TestHelper.setupLogger();
given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true);
given(settings.getProperty(EmailSettings.SMTP_PORT)).willReturn(25);