Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package io.tolgee.configuration

import io.tolgee.component.ResilientCacheAccessor
import io.tolgee.component.TolgeeCacheErrorHandler
import org.springframework.cache.annotation.CachingConfigurerSupport
import org.springframework.cache.annotation.CachingConfigurer
import org.springframework.cache.interceptor.CacheErrorHandler
import org.springframework.context.annotation.Configuration

@Configuration
class CacheConfiguration(
private val resilientCacheAccessor: ResilientCacheAccessor,
) : CachingConfigurerSupport() {
) : CachingConfigurer {
override fun errorHandler(): CacheErrorHandler {
return TolgeeCacheErrorHandler(resilientCacheAccessor)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class OctetStreamSupportConfiguration : WebMvcConfigurer {
// The non-deprecated ServerBuilder API bypasses Spring HATEOAS's HAL converter registration.
@Suppress("OVERRIDE_DEPRECATION")
override fun extendMessageConverters(converters: MutableList<HttpMessageConverter<*>>) {
converters
.filterIsInstance<JacksonJsonHttpMessageConverter>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class PublicController(
fun validateEmail(
@RequestBody email: StringNode,
): Boolean {
return userAccountService.findActive(email.asText()) == null
return userAccountService.findActive(email.asString()) == null
}

@GetMapping("/authorize_oauth/{serviceType}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OrganizationInvitationModelAssembler(
return OrganizationInvitationModel(
entity.id!!,
entity.code,
entity.organizationRole!!.type!!,
entity.organizationRole!!.type,
entity.createdAt!!,
invitedUserName = entity.name,
invitedUserEmail = entity.email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SimpleOrganizationModelAssembler(
SimpleOrganizationModel::class.java,
) {
override fun toModel(entity: Organization): SimpleOrganizationModel {
val link = linkTo<OrganizationController> { get(entity.slug ?: "") }.withSelfRel()
val link = linkTo<OrganizationController> { get(entity.slug) }.withSelfRel()
return SimpleOrganizationModel(
entity.id,
entity.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TranslationSuggestionModelAssembler(
return TranslationSuggestionModel(
id = entity.id,
languageId = entity.language!!.id,
keyId = entity.key!!.id,
keyId = entity.key.id,
translation = entity.translation,
author = simpleUserAccountModelAssembler.toModel(entity.author!!),
state = entity.state,
Expand Down
2 changes: 1 addition & 1 deletion backend/app/src/main/kotlin/io/tolgee/ExceptionHandlers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ExceptionHandlers : Logging {
@ExceptionHandler(MethodArgumentTypeMismatchException::class)
fun handleValidationExceptions(ex: MethodArgumentTypeMismatchException): ResponseEntity<ErrorResponseBody> {
return ResponseEntity(
ErrorResponseBody(Message.WRONG_PARAM_TYPE.code, listOf(ex.parameter.parameterName) as List<Serializable>?),
ErrorResponseBody(Message.WRONG_PARAM_TYPE.code, listOfNotNull(ex.parameter.parameterName)),
HttpStatus.BAD_REQUEST,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TolgeeSentryUserProvider(
override fun provideUser(): User? {
return authenticationFacade.authenticatedUserOrNull?.let { user ->
return User().apply {
name = user.username
username = user.username
email = user.username
id = user.id.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EventStreamConfig(
private val objectMapper: ObjectMapper,
) : WebMvcConfigurer {
// The non-deprecated ServerBuilder API bypasses Spring HATEOAS's HAL converter registration.
@Suppress("DEPRECATION")
@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")
override fun extendMessageConverters(converters: MutableList<HttpMessageConverter<*>>) {
converters.add(EventStreamHttpMessageConverter(objectMapper))
converters.add(JavascriptHttpMessageConverter(objectMapper))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.springframework.context.annotation.Lazy
import org.springframework.context.annotation.Primary
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
import org.springframework.http.client.SimpleClientHttpRequestFactory
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
import org.springframework.http.converter.xml.JacksonXmlHttpMessageConverter
import org.springframework.stereotype.Component
import org.springframework.web.client.RestTemplate

Expand All @@ -29,7 +29,7 @@ class RestTemplateConfiguration {
}

private fun RestTemplate.removeXmlConverter(): RestTemplate {
messageConverters.removeIf { it is MappingJackson2XmlHttpMessageConverter }
messageConverters.removeIf { it is JacksonXmlHttpMessageConverter }
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package io.tolgee.configuration

import org.springframework.context.annotation.Configuration
import org.springframework.http.converter.HttpMessageConverter
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
import org.springframework.http.converter.xml.JacksonXmlHttpMessageConverter
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class WebMvcConfiguration : WebMvcConfigurer {
// The non-deprecated ServerBuilder API bypasses Spring HATEOAS's HAL converter registration.
@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")
override fun configureMessageConverters(converters: MutableList<HttpMessageConverter<*>>) {
converters.removeIf { it is MappingJackson2XmlHttpMessageConverter }
converters.removeIf { it is JacksonXmlHttpMessageConverter }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class NullTypedActivityRevisionStorageTest : AuthorizedControllerTest() {
entityManager
.createQuery(
"select count(ar) from ActivityRevision ar where ar.projectId = :projectId",
java.lang.Long::class.java,
Long::class.javaObjectType,
).setParameter("projectId", testData.project.id)
.singleResult
.toLong()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ProjectExportImportControllerTest : AuthorizedControllerTest() {
entityManager
.createQuery(
"select count(kd) from KeysDistance kd where kd.project.id = :p",
java.lang.Long::class.java,
Long::class.javaObjectType,
).setParameter("p", testData.project.id)
.singleResult
.toLong()
Expand All @@ -135,7 +135,7 @@ class ProjectExportImportControllerTest : AuthorizedControllerTest() {
.createQuery(
"select count(a) from TranslationMemoryProject a " +
"where a.project.id = :p and a.translationMemory.type = :t",
java.lang.Long::class.java,
Long::class.javaObjectType,
).setParameter("p", testData.project.id)
.setParameter("t", TranslationMemoryType.PROJECT)
.singleResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class OrganizationFloorAccessTest : AuthorizedControllerTest() {
.path("_embedded")
.path("languages")
.values()
.map { it.path("tag").asText() }
.map { it.path("tag").asString() }
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ class TranslationSuggestionControllerMtTest : ProjectAuthControllerTest("/v2/pro
)
}

@Suppress("UNCHECKED_CAST")
private fun verifyServiceFirst(service: String) {
val result = performMtRequest().andIsOk.andReturn().mapResponseTo<Map<String, Any>>()
val services = (result["machineTranslations"] as Map<String, String>).keys.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class TranslationsControllerFilterTest : ProjectAuthControllerTest("/v2/projects

@ProjectJWTAuthTestMethod
@Test
fun `filters "without tag" specified by empty tag`() {
fun `filters 'without tag' specified by empty tag`() {
testData.addFewKeysWithTags()
testData.addKeysWithScreenshots()
testDataService.saveTestData(testData.root)
Expand Down Expand Up @@ -418,7 +418,7 @@ class TranslationsControllerFilterTest : ProjectAuthControllerTest("/v2/projects

@ProjectJWTAuthTestMethod
@Test
fun `filters in combination with "without tag"`() {
fun `filters in combination with 'without tag'`() {
testData.addFewKeysWithTags()
testData.addKeysWithScreenshots()
testDataService.saveTestData(testData.root)
Expand Down Expand Up @@ -454,7 +454,7 @@ class TranslationsControllerFilterTest : ProjectAuthControllerTest("/v2/projects

@ProjectJWTAuthTestMethod
@Test
fun `excludes by "Without tag"`() {
fun `excludes by 'Without tag'`() {
testData.addKeysWithScreenshots()
testDataService.saveTestData(testData.root)
userAccount = testData.user
Expand Down Expand Up @@ -482,7 +482,7 @@ class TranslationsControllerFilterTest : ProjectAuthControllerTest("/v2/projects

@ProjectJWTAuthTestMethod
@Test
fun `excludes in combination with "Without tag"`() {
fun `excludes in combination with 'Without tag'`() {
testData.addKeysWithScreenshots()
testDataService.saveTestData(testData.root)
userAccount = testData.user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class TranslationsControllerHistoryTest : ProjectAuthControllerTest("/v2/project
translationService.find(emptyKey, lang).get()
}

performProjectAuthGet("/translations/${translation!!.id}/history").andPrettyPrint.andAssertThatJson {
performProjectAuthGet("/translations/${translation.id}/history").andPrettyPrint.andAssertThatJson {
node("page.totalElements").isEqualTo(0)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,8 @@ class V2ImportControllerAddFilesTest : ProjectAuthControllerTest("/v2/projects/"
assertThat(
it.files[0]
.issues[0]
.params
?.get(0)
?.value,
.params[0]
.value,
).isEqualTo("too_long")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ class KeySoftDeleteNamespaceTest : ProjectAuthControllerTest("/v2/projects/") {
.path("_embedded")
.path("namespaces")
.values()
.map { it.path("name").textValue() }
.map { it.path("name").stringValue() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class ProjectsControllerTest : ProjectAuthControllerTest("/v2/projects/") {
val usersAndOrganizations = dbPopulator.createUsersAndOrganizations()
val repo = usersAndOrganizations[1].organizationRoles[0].organization!!.projects[0]
val user = dbPopulator.createUserIfNotExists("jirina")
organizationRoleService.grantOwnerRoleToUser(user, repo.organizationOwner!!)
organizationRoleService.grantOwnerRoleToUser(user, repo.organizationOwner)

loginAsUser(usersAndOrganizations[1].name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ abstract class AbstractBatchJobsGeneralTest :

executions
.last()
.successTargets!!
.successTargets
.assert
.size()
.isEqualTo(2) // 2 failed items in a chunk are retried successfully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.Date
import java.util.function.Consumer
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream

@AutoConfigureMockMvc
Expand Down Expand Up @@ -191,12 +190,9 @@ class ExportControllerTest : ProjectAuthControllerTest() {
val byteArrayInputStream = ByteArrayInputStream(responseContent)
val zipInputStream = ZipInputStream(byteArrayInputStream)
val result = HashMap<String, Long>()
var nextEntry: ZipEntry?
while (zipInputStream.nextEntry.also {
nextEntry = it
} != null
) {
result[nextEntry!!.name] = nextEntry!!.size
while (true) {
val nextEntry = zipInputStream.nextEntry ?: break
result[nextEntry.name] = nextEntry.size
}
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class AllOrganizationOwnerJobTest : AbstractSpringTest() {
fun `deletes permission`() {
allOrganizationOwnerJobRunner.run()
transactionTemplate.execute {
val firstProject = projectRepository.getById(project1.id)
val firstProject = projectRepository.getReferenceById(project1.id)
assertThat(firstProject.permissions).isEmpty()
}
}
Expand All @@ -104,7 +104,7 @@ class AllOrganizationOwnerJobTest : AbstractSpringTest() {
fun `reuses existing organization`() {
allOrganizationOwnerJobRunner.run()
transactionTemplate.execute {
val firstProject = projectRepository.getById(project1.id)
val firstProject = projectRepository.getReferenceById(project1.id)
assertThat(firstProject.permissions).isEmpty()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class McpBatchToolsTest : AbstractMcpTest() {
),
)
assertThat(json["jobId"]).isNotNull()
assertThat(json["type"].asText()).isEqualTo("MACHINE_TRANSLATE")
assertThat(json["type"].asString()).isEqualTo("MACHINE_TRANSLATE")
}

@Test
Expand Down Expand Up @@ -83,7 +83,7 @@ class McpBatchToolsTest : AbstractMcpTest() {
),
)
assertThat(json["jobId"]).isNotNull()
assertThat(json["type"].asText()).isEqualTo("MACHINE_TRANSLATE")
assertThat(json["type"].asString()).isEqualTo("MACHINE_TRANSLATE")
assertThat(json["totalItems"].asInt()).isEqualTo(1)

val jobDto = batchJobService.findJobDto(json["jobId"].asLong())
Expand Down Expand Up @@ -127,7 +127,7 @@ class McpBatchToolsTest : AbstractMcpTest() {
)
assertThat(json["id"].asLong()).isEqualTo(jobId)
assertThat(json["status"]).isNotNull()
assertThat(json["type"].asText()).isEqualTo("MACHINE_TRANSLATE")
assertThat(json["type"].asString()).isEqualTo("MACHINE_TRANSLATE")
assertThat(json["totalItems"].asInt()).isEqualTo(1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class McpKeyToolsTest : AbstractMcpTest() {
assertThat(json["totalItems"].asLong()).isEqualTo(3)
assertThat(json["page"].asInt()).isEqualTo(0)
assertThat(json["totalPages"].asInt()).isEqualTo(1)
val keyNames = (0 until json["items"].size()).map { json["items"][it]["keyName"].asText() }
val keyNames = (0 until json["items"].size()).map { json["items"][it]["keyName"].asString() }
assertThat(keyNames).containsExactlyInAnyOrder("first.key", "second.key", "third.key")
}

Expand Down Expand Up @@ -88,7 +88,7 @@ class McpKeyToolsTest : AbstractMcpTest() {
mapOf("projectId" to data.projectId, "query" to "search.target"),
)
assertThat(json["items"].isArray).isTrue()
val keyNames = (0 until json["items"].size()).map { json["items"][it]["keyName"].asText() }
val keyNames = (0 until json["items"].size()).map { json["items"][it]["keyName"].asString() }
assertThat(keyNames).contains("search.target")
}

Expand All @@ -110,7 +110,7 @@ class McpKeyToolsTest : AbstractMcpTest() {
mapOf("projectId" to data.projectId, "keyName" to "detail.key"),
)
assertThat(json["keyId"]).isNotNull()
assertThat(json["keyName"].asText()).isEqualTo("detail.key")
assertThat(json["keyName"].asString()).isEqualTo("detail.key")
}

@Test
Expand All @@ -134,7 +134,7 @@ class McpKeyToolsTest : AbstractMcpTest() {
"newName" to "new.name",
),
)
assertThat(json["name"].asText()).isEqualTo("new.name")
assertThat(json["name"].asString()).isEqualTo("new.name")

val key = keyService.find(data.projectId, "new.name", null)
assertThat(key).isNotNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class McpLanguageToolsTest : AbstractMcpTest() {
fun `list_languages auto-resolves projectId from PAK`() {
val json = callToolAndGetJson(client, "list_languages")
assertThat(json["items"].isArray).isTrue()
val tags = (0 until json["items"].size()).map { json["items"][it]["tag"].asText() }
val tags = (0 until json["items"].size()).map { json["items"][it]["tag"].asString() }
assertThat(tags).contains("en")
}

@Test
fun `list_languages returns project languages`() {
val json = callToolAndGetJson(client, "list_languages", mapOf("projectId" to data.projectId))
assertThat(json["items"].isArray).isTrue()
val tags = (0 until json["items"].size()).map { json["items"][it]["tag"].asText() }
val tags = (0 until json["items"].size()).map { json["items"][it]["tag"].asString() }
assertThat(tags).contains("en")
}

Expand All @@ -41,7 +41,7 @@ class McpLanguageToolsTest : AbstractMcpTest() {
mapOf("projectId" to data.projectId, "name" to "German", "tag" to "de"),
)
assertThat(json["id"]).isNotNull()
assertThat(json["tag"].asText()).isEqualTo("de")
assertThat(json["tag"].asString()).isEqualTo("de")

val language = languageService.getEntity(json["id"].asLong())
assertThat(language.tag).isEqualTo("de")
Expand All @@ -63,7 +63,7 @@ class McpLanguageToolsTest : AbstractMcpTest() {

val json = callToolAndGetJson(client, "list_namespaces", mapOf("projectId" to data.projectId))
assertThat(json.isArray).isTrue()
val nsNames = (0 until json.size()).mapNotNull { json[it]["name"]?.asText() }
val nsNames = (0 until json.size()).mapNotNull { json[it]["name"]?.asString() }
assertThat(nsNames).contains("my-namespace")
}
}
Loading
Loading