Skip to content

Commit

Permalink
Fix tests after #2344
Browse files Browse the repository at this point in the history
### What's done:
- avoid changing Spring's ObjectMapper

It's part of #2336
  • Loading branch information
nulls committed Jul 24, 2023
1 parent fe3e0c6 commit 8aba361
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.springframework.http.MediaType
import org.springframework.security.core.userdetails.User as SpringUser
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.jackson2.CoreJackson2Module
import org.springframework.security.jackson2.SecurityJackson2Modules
import org.springframework.stereotype.Service
import org.springframework.web.reactive.function.client.WebClient
Expand All @@ -20,12 +21,11 @@ import reactor.core.publisher.Mono
@Service
class BackendService(
configurationProperties: ConfigurationProperties,
objectMapper: ObjectMapper,
) {
private val springUserDetailsReader = objectMapper
.also {
it.registerModules(SecurityJackson2Modules.getModules(javaClass.classLoader))
}
private val springUserDetailsReader = ObjectMapper()
.findAndRegisterModules()
.registerModule(CoreJackson2Module())
.registerModules(SecurityJackson2Modules.getModules(javaClass.classLoader))
.readerFor(SpringUser::class.java)
private val webClient = WebClient.create(configurationProperties.backend.url)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.saveourtool.save.utils.StringResponse
import com.fasterxml.jackson.databind.ObjectMapper
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.security.jackson2.CoreJackson2Module
import org.springframework.security.core.userdetails.User as SpringUser
import org.springframework.security.jackson2.SecurityJackson2Modules
import org.springframework.transaction.annotation.Transactional
Expand All @@ -26,13 +27,12 @@ import reactor.core.publisher.Mono
class UsersController(
private val userService: UserDetailsService,
private val originalLoginRepository: OriginalLoginRepository,
objectMapper: ObjectMapper,
) {
private val logger = LoggerFactory.getLogger(javaClass)
private val springUserDetailsWriter = objectMapper
.also {
it.registerModules(SecurityJackson2Modules.getModules(javaClass.classLoader))
}
private val springUserDetailsWriter = ObjectMapper()
.findAndRegisterModules()
.registerModule(CoreJackson2Module())
.registerModules(SecurityJackson2Modules.getModules(javaClass.classLoader))
.writerFor(SpringUser::class.java)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ class BackendInternalFileStorage(
s3Operations,
) {
override suspend fun doInitAdditionally(underlying: DefaultStorageCoroutines<InternalFileKey>) {
underlying.downloadSaveCliFromGithub()
// underlying.downloadSaveCliFromGithub()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import reactor.kotlin.core.publisher.toMono
import java.time.Instant

@SpringBootTest(classes = [SaveApplication::class])
@AutoConfigureWebTestClient
@AutoConfigureWebTestClient(timeout = "5d")
@ExtendWith(InfraExtension::class)
@MockBeans(
MockBean(ProjectController::class),
Expand Down Expand Up @@ -163,7 +163,7 @@ class TestExecutionControllerTest {
webClient.post()
.uri("/internal/saveTestResult")
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(listOf(testExecutionDtoFirst, testExecutionDtoSecond)))
.body(BodyInserters.fromValue(listOf(testExecutionDtoFirst, testExecutionDtoSecond).toMutableList()))
.exchange()
.expectBody<String>()
.isEqualTo("Saved")
Expand Down

0 comments on commit 8aba361

Please sign in to comment.