hotfix(ci): fixed tests and style #37

Merged
devitq merged 4 commits from hotfix/fix-ci into develop 2026-05-03 18:12:10 +00:00
9 changed files with 100 additions and 89 deletions
@@ -62,11 +62,12 @@ class FilmRepository(
)
override fun findByTitle(title: String): Film? {
val films = jdbc.query(
"SELECT id, title, description FROM films WHERE title = ?",
filmRowMapper,
title
)
val films =
jdbc.query(
"SELECT id, title, description FROM films WHERE title = ?",
filmRowMapper,
title,
)
return films.firstOrNull()
}
@@ -69,10 +69,11 @@ class UserRepository(
}
override fun findAll(): List<User> =
jdbc.query(
"SELECT id, name, email, provider, provider_id, created_at FROM users",
userEntityRowMapper,
).map { it.toDomain() }
jdbc
.query(
"SELECT id, name, email, provider, provider_id, created_at FROM users",
userEntityRowMapper,
).map { it.toDomain() }
override fun deleteById(id: UUID) {
jdbc.update("DELETE FROM users WHERE id = ?", id)
@@ -84,7 +85,10 @@ class UserRepository(
): User? {
val entities =
jdbc.query(
"SELECT id, name, email, provider, provider_id, created_at FROM users WHERE provider = ? AND provider_id = ?",
"""
SELECT id, name, email, provider, provider_id, created_at FROM users
WHERE provider = ? AND provider_id = ?
""".trimIndent(),
userEntityRowMapper,
provider.name,
providerId,
@@ -56,10 +56,11 @@ class FilmController(
FilmResponse.fromDomain(
editFilmUseCase.edit(
id = id,
command = EditFilmCommand(
title = request.title,
description = request.description,
),
command =
EditFilmCommand(
title = request.title,
description = request.description,
),
),
)
@@ -72,16 +73,13 @@ class FilmController(
@GetMapping("/{id}")
fun getById(
@PathVariable id: UUID,
): FilmResponse =
FilmResponse.fromDomain(getFilmByIdUseCase.getById(id))
): FilmResponse = FilmResponse.fromDomain(getFilmByIdUseCase.getById(id))
@GetMapping("/search")
fun searchByTitle(
@RequestParam title: String,
): FilmResponse? =
searchFilmByTitleUseCase.searchByTitle(title)?.let { FilmResponse.fromDomain(it) }
): FilmResponse? = searchFilmByTitleUseCase.searchByTitle(title)?.let { FilmResponse.fromDomain(it) }
@GetMapping
fun getAll(): List<FilmResponse> =
getAllFilmsUseCase.getAll().map { FilmResponse.fromDomain(it) }
fun getAll(): List<FilmResponse> = getAllFilmsUseCase.getAll().map { FilmResponse.fromDomain(it) }
}
@@ -63,9 +63,10 @@ class FilmLibraryController(
fun getAllFilmsInLibrary(
@PathVariable userId: UUID,
): List<FilmResponse> {
val library = getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId)
)
val library =
getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId),
)
val film = getFilmByIdUseCase.getById(library.filmId)
@@ -92,20 +93,23 @@ class FilmLibraryController(
fun removeFilm(
@PathVariable userId: UUID,
@PathVariable filmId: UUID,
) = removeFilmFromLibraryUseCase.removeFilm(
RemoveFilmFromLibraryCommand(
userId = userId,
filmId = filmId,
),
)
) {
removeFilmFromLibraryUseCase.removeFilm(
RemoveFilmFromLibraryCommand(
userId = userId,
filmId = filmId,
),
)
}
@GetMapping("/available-films")
fun getAvailableFilms(
@PathVariable userId: UUID,
): List<FilmResponse> {
val userLibrary = getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId)
)
val userLibrary =
getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId),
)
val allFilms = getAllFilmsUseCase.getAll()
@@ -46,14 +46,12 @@ class UserController(
)
@GetMapping
fun getAll(): List<UserResponse> =
getAllUsersUseCase.getAll().map { UserResponse.fromDomain(it) }
fun getAll(): List<UserResponse> = getAllUsersUseCase.getAll().map { UserResponse.fromDomain(it) }
@GetMapping("/{id}")
fun getById(
@PathVariable id: UUID,
): UserResponse =
UserResponse.fromDomain(getUserByIdUseCase.getById(id))
): UserResponse = UserResponse.fromDomain(getUserByIdUseCase.getById(id))
@PatchMapping("/{id}")
fun edit(
@@ -63,9 +61,10 @@ class UserController(
UserResponse.fromDomain(
editUserUseCase.edit(
id = id,
command = EditUserCommand(
name = request.name,
),
command =
EditUserCommand(
name = request.name,
),
),
)
@@ -28,7 +28,6 @@ class FilmService(
GetFilmByIdUseCase,
GetAllFilmsUseCase,
SearchFilmByTitleUseCase {
override fun create(command: CreateFilmCommand): Film {
if (filmConfig.isBlocked(command.title)) {
throw BlockedValueException(target = "Film", field = "title")
@@ -37,15 +36,19 @@ class FilmService(
throw BlockedValueException(target = "Film", field = "description")
}
val film = Film(
id = idGenerator.generateId(),
title = command.title,
description = command.description,
)
val film =
Film(
id = idGenerator.generateId(),
title = command.title,
description = command.description,
)
return filmRepository.save(film)
}
override fun edit(id: UUID, command: EditFilmCommand): Film {
override fun edit(
id: UUID,
command: EditFilmCommand,
): Film {
if (filmConfig.isBlocked(command.title)) {
throw BlockedValueException(target = "Film", field = "title")
}
@@ -63,9 +66,8 @@ class FilmService(
filmRepository.deleteById(id)
}
override fun getById(id: UUID): Film {
return filmRepository.findById(id) ?: throw EntityNotFoundException(entity = "Film", id = id.toString())
}
override fun getById(id: UUID): Film =
filmRepository.findById(id) ?: throw EntityNotFoundException(entity = "Film", id = id.toString())
override fun getAll(): List<Film> = filmRepository.findAll()
@@ -26,18 +26,18 @@ class UserService(
DeleteUserUseCase,
GetUserByIdUseCase,
GetAllUsersUseCase {
override fun create(command: CreateUserCommand): User {
if (userConfig.isBlocked(command.name)) {
throw BlockedValueException(target = "User", field = "name")
}
val user = User(
id = idGenerator.generateId(),
name = command.name,
email = command.email,
library = null,
)
val user =
User(
id = idGenerator.generateId(),
name = command.name,
email = command.email,
library = null,
)
return userRepository.save(user)
}
@@ -59,9 +59,8 @@ class UserService(
userRepository.deleteById(id)
}
override fun getById(id: UUID): User {
return userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
}
override fun getById(id: UUID): User =
userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
override fun getAll(): List<User> = userRepository.findAll()
}
+4 -1
View File
@@ -1,7 +1,10 @@
CREATE TABLE IF NOT EXISTS public.users (
id UUID PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(320) NOT NULL UNIQUE
email VARCHAR(320) NOT NULL UNIQUE,
provider VARCHAR(64),
provider_id VARCHAR(255),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
copilot-pull-request-reviewer[bot] commented 2026-05-03 16:54:14 +00:00 (Migrated from github.com)
Review

Editing an existing V1__init.sql migration will break deployments on any environment that has already applied version 1, because Flyway validates migration checksums and will fail startup when a previously executed migration changes. This needs to be introduced as a new forward-only migration instead of rewriting V1.

Editing an existing `V1__init.sql` migration will break deployments on any environment that has already applied version 1, because Flyway validates migration checksums and will fail startup when a previously executed migration changes. This needs to be introduced as a new forward-only migration instead of rewriting `V1`.
copilot-pull-request-reviewer[bot] commented 2026-05-03 17:20:26 +00:00 (Migrated from github.com)
Review

This changes the contents of the already-versioned V1__init.sql migration instead of adding a new migration. Flyway will not re-run V1 in environments that have already applied it, so those databases will still be missing provider, provider_id, and created_at, and the updated repository queries will start failing at runtime when they select these columns.

This changes the contents of the already-versioned `V1__init.sql` migration instead of adding a new migration. Flyway will not re-run `V1` in environments that have already applied it, so those databases will still be missing `provider`, `provider_id`, and `created_at`, and the updated repository queries will start failing at runtime when they select these columns.
CREATE TABLE IF NOT EXISTS public.films (
@@ -9,17 +9,17 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
class UserEntityMappingTest {
@Test
fun `toDomain maps UserEntity correctly`() {
val entity = UserEntity(
id = UUID.randomUUID(),
name = "John Pork",
email = "john@email.com",
provider = "GOOGLE",
providerId = "google1234",
createdAt = LocalDateTime.now(),
)
val entity =
UserEntity(
id = UUID.randomUUID(),
name = "John Pork",
email = "john@email.com",
provider = "GOOGLE",
providerId = "google1234",
createdAt = LocalDateTime.now(),
)
val user = entity.toDomain()
assertEquals(entity.id, user.id)
@@ -30,12 +30,13 @@ class UserEntityMappingTest {
@Test
fun `toEntity maps User with OAuth provider`() {
val user = User(
id = UUID.randomUUID(),
name = "Jane",
email = "jane@mail.com",
library = null
)
val user =
User(
id = UUID.randomUUID(),
name = "Jane",
email = "jane@mail.com",
library = null,
)
val entity = user.toEntity(AuthProvider.YANDEX, "yandex456")
@@ -48,12 +49,13 @@ class UserEntityMappingTest {
@Test
fun `toEntity maps User without OAuth provider`() {
val user = User(
id = UUID.randomUUID(),
name = "Bob",
email = "bob@mail.com",
library = null
)
val user =
User(
id = UUID.randomUUID(),
name = "Bob",
email = "bob@mail.com",
library = null,
)
val entity = user.toEntity()
@@ -63,12 +65,13 @@ class UserEntityMappingTest {
@Test
fun `mapping is reversible for basic fields`() {
val original = User(
id = UUID.randomUUID(),
name = "Alice",
email = "alice@email.com",
library = null
)
val original =
User(
id = UUID.randomUUID(),
name = "Alice",
email = "alice@email.com",
library = null,
)
val mapped = original.toEntity().toDomain()
@@ -76,6 +79,4 @@ class UserEntityMappingTest {
assertEquals(original.name, mapped.name)
assertEquals(original.email, mapped.email)
}
}