Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Shaml committed Jan 7, 2025
1 parent ab24762 commit 2e6cf5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class RegistrationService(
password = encodedPassword,
email = email,
ip = ipAddress.value,
acceptedTos = tosService.findLatestTos()?.version
acceptedTos = tosService.findLatestTos()?.version,
)

userRepository.persist(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 14 additions & 6 deletions src/test/kotlin/com/faforever/userservice/tos/TosServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -42,7 +43,14 @@ class TosServiceTest {

@BeforeEach
fun setUp() {
user = User(id = USER_ID, username = "testUser", password = "password", email = "[email protected]", ip = "127.0.0.1", acceptedTos = 1)
user = User(
id = USER_ID,
username = "testUser",
password = "password",
email = "[email protected]",
ip = "127.0.0.1",
acceptedTos = 1,
)
whenever(tosRepository.findLatest()).thenReturn(LATEST_TOS)
}

Expand Down Expand Up @@ -77,7 +85,7 @@ class TosServiceTest {
fun testHasUserAcceptedLatestTosWhenUserNotExist() {
whenever(userRepository.findById(eq(USER_ID))).thenReturn(null)

assertThrows<IllegalStateException>{ tosService.hasUserAcceptedLatestTos(USER_ID) }
assertThrows<IllegalStateException> { tosService.hasUserAcceptedLatestTos(USER_ID) }
}

@Test
Expand All @@ -93,7 +101,7 @@ class TosServiceTest {
fun testAcceptLatestTosUserNotFoundThrowsException() {
whenever(userRepository.findById(eq(USER_ID))).thenReturn(null)

assertThrows<IllegalStateException>{ tosService.acceptLatestTos(USER_ID) }
assertThrows<IllegalStateException> { tosService.acceptLatestTos(USER_ID) }
}

@Test
Expand Down

0 comments on commit 2e6cf5a

Please sign in to comment.