From 2e6cf5ac87d1fb454871dc4ff0f8677dce133061 Mon Sep 17 00:00:00 2001 From: Ivan-Shaml <72102779+Ivan-Shaml@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:42:45 +0200 Subject: [PATCH] chore: linting --- .../registration/RegistrationService.kt | 2 +- .../userservice/backend/tos/TosService.kt | 1 - .../userservice/tos/TosServiceTest.kt | 20 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/faforever/userservice/backend/registration/RegistrationService.kt b/src/main/kotlin/com/faforever/userservice/backend/registration/RegistrationService.kt index 5fa1e035..a70c0a9d 100644 --- a/src/main/kotlin/com/faforever/userservice/backend/registration/RegistrationService.kt +++ b/src/main/kotlin/com/faforever/userservice/backend/registration/RegistrationService.kt @@ -143,7 +143,7 @@ class RegistrationService( password = encodedPassword, email = email, ip = ipAddress.value, - acceptedTos = tosService.findLatestTos()?.version + acceptedTos = tosService.findLatestTos()?.version, ) userRepository.persist(user) diff --git a/src/main/kotlin/com/faforever/userservice/backend/tos/TosService.kt b/src/main/kotlin/com/faforever/userservice/backend/tos/TosService.kt index 2a78ef64..691e6578 100644 --- a/src/main/kotlin/com/faforever/userservice/backend/tos/TosService.kt +++ b/src/main/kotlin/com/faforever/userservice/backend/tos/TosService.kt @@ -6,7 +6,6 @@ import com.faforever.userservice.backend.domain.UserRepository import jakarta.enterprise.context.ApplicationScoped import jakarta.transaction.Transactional - @ApplicationScoped class TosService( private val userRepository: UserRepository, diff --git a/src/test/kotlin/com/faforever/userservice/tos/TosServiceTest.kt b/src/test/kotlin/com/faforever/userservice/tos/TosServiceTest.kt index 9e878bb3..5d26d20b 100644 --- a/src/test/kotlin/com/faforever/userservice/tos/TosServiceTest.kt +++ b/src/test/kotlin/com/faforever/userservice/tos/TosServiceTest.kt @@ -8,10 +8,10 @@ import com.faforever.userservice.backend.tos.TosService import io.quarkus.test.InjectMock import io.quarkus.test.junit.QuarkusTest import jakarta.inject.Inject -import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -26,7 +26,8 @@ class TosServiceTest { companion object { private const val USER_ID = 1 private const val LATEST_VERSION: Short = 2 - private val LATEST_TOS = TermsOfService(version = LATEST_VERSION, validFrom = LocalDateTime.now(), content = "Latest TOS") + private val LATEST_TOS = + TermsOfService(version = LATEST_VERSION, validFrom = LocalDateTime.now(), content = "Latest TOS") } @InjectMock @@ -42,7 +43,14 @@ class TosServiceTest { @BeforeEach fun setUp() { - user = User(id = USER_ID, username = "testUser", password = "password", email = "test@example.com", ip = "127.0.0.1", acceptedTos = 1) + user = User( + id = USER_ID, + username = "testUser", + password = "password", + email = "test@example.com", + ip = "127.0.0.1", + acceptedTos = 1, + ) whenever(tosRepository.findLatest()).thenReturn(LATEST_TOS) } @@ -77,7 +85,7 @@ class TosServiceTest { fun testHasUserAcceptedLatestTosWhenUserNotExist() { whenever(userRepository.findById(eq(USER_ID))).thenReturn(null) - assertThrows{ tosService.hasUserAcceptedLatestTos(USER_ID) } + assertThrows { tosService.hasUserAcceptedLatestTos(USER_ID) } } @Test @@ -93,7 +101,7 @@ class TosServiceTest { fun testAcceptLatestTosUserNotFoundThrowsException() { whenever(userRepository.findById(eq(USER_ID))).thenReturn(null) - assertThrows{ tosService.acceptLatestTos(USER_ID) } + assertThrows { tosService.acceptLatestTos(USER_ID) } } @Test