Skip to content

Commit

Permalink
PEK-823 fikse tester og fjerne deprecated @MockBean
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfofanov committed Dec 5, 2024
1 parent 499f9ee commit 466e34e
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.mockito.Mockito
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import org.springframework.http.MediaType
import org.springframework.security.test.context.support.WithMockUser
import org.springframework.test.web.servlet.MockMvc
Expand All @@ -36,13 +36,13 @@ class SimuleringAFPEndpointTest {
@Autowired
private lateinit var mockMvc: MockMvc

@MockBean
@MockitoBean
private lateinit var aadClient: AADClient

@MockBean
@MockitoBean
private lateinit var fssGatewayAuthService: FssGatewayAuthService

@MockBean
@MockitoBean
private lateinit var afpOffentligLivsvarigSimuleringService: AFPOffentligLivsvarigSimuleringService

private var wireMockServer = WireMockServer().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.mockito.kotlin.any
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import org.springframework.http.MediaType
import org.springframework.security.test.context.support.WithMockUser
import org.springframework.test.web.servlet.MockMvc
Expand All @@ -33,10 +33,10 @@ class TjenestepensjonSimuleringV2025ControllerTest {
@Autowired
private lateinit var mockMvc: MockMvc

@MockBean
@MockitoBean
private lateinit var aadClient: AADClient

@MockBean
@MockitoBean
private lateinit var service: TjenestepensjonV2025Service

private var wireMockServer = WireMockServer().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.mockito.Mockito
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean

@SpringBootTest(classes = [TpClient::class, WebClientConfig::class, ObjectMapperConfig::class, TestConfig::class])
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TpClientTest {

@MockBean
@MockitoBean
private lateinit var aadClient: AADClient

@MockBean
@MockitoBean
private lateinit var fssGatewayAuthService: FssGatewayAuthService

@Autowired
private lateinit var tpClient: TpClient

@MockBean
@MockitoBean
private lateinit var maskinportenTokenClient: MaskinportenTokenClient

private var wireMockServer = WireMockServer().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.mockito.Mockito.`when`
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import org.springframework.http.MediaType.APPLICATION_JSON
import org.springframework.security.test.context.support.WithMockUser
import org.springframework.test.context.ActiveProfiles
Expand All @@ -39,16 +39,16 @@ class SimuleringEndpointSecurityTest {
@Autowired
private lateinit var mockMvc: MockMvc

@MockBean
@MockitoBean
private lateinit var aadClient: AADClient

@MockBean
@MockitoBean
private lateinit var fssGatewayAuthService: FssGatewayAuthService

@MockBean
@MockitoBean
private lateinit var tokenService: TokenService

@MockBean
@MockitoBean
private lateinit var soapClient: SoapClient

private var wireMockServer = WireMockServer().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import no.nav.tjenestepensjon.simulering.defaultTPOrdningIdDto
import no.nav.tjenestepensjon.simulering.domain.TokenImpl
import no.nav.tjenestepensjon.simulering.model.domain.TpLeverandor
import no.nav.tjenestepensjon.simulering.model.domain.TpLeverandor.EndpointImpl.SOAP
import no.nav.tjenestepensjon.simulering.sporingslogg.SporingsloggService
import no.nav.tjenestepensjon.simulering.testHelper.anyNonNull
import no.nav.tjenestepensjon.simulering.v1.consumer.TokenClientOld
import no.nav.tjenestepensjon.simulering.v1.models.*
Expand All @@ -17,19 +18,22 @@ import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import org.springframework.ws.client.core.WebServiceTemplate


@SpringBootTest(classes = [TokenClientOld::class, WebServiceTemplate::class, SoapClient::class, SamlConfig::class, ObjectMapperConfig::class])
internal class SoapClientTest {

@MockBean
@MockitoBean
lateinit var template: WebServiceTemplate

@MockBean
@MockitoBean
lateinit var tokenClientOld: TokenClientOld

@MockitoBean
lateinit var sporingsloggService: SporingsloggService

@Autowired
lateinit var client: SoapClient

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.mockito.Mockito.`when`
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import org.springframework.http.MediaType.APPLICATION_JSON
import org.springframework.security.test.context.support.WithMockUser
import org.springframework.test.context.ActiveProfiles
Expand All @@ -34,13 +34,13 @@ class SimuleringEndpointSecurityTest {
@Autowired
private lateinit var mockMvc: MockMvc

@MockBean
@MockitoBean
private lateinit var aadClient: AADClient

@MockBean
@MockitoBean
private lateinit var soapClient: SoapClient

@MockBean
@MockitoBean
private lateinit var restClient: RestClient

private var wireMockServer = WireMockServer().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import org.springframework.http.HttpStatus
import org.springframework.web.reactive.function.client.WebClientResponseException
import org.springframework.web.server.ResponseStatusException
Expand All @@ -26,13 +26,13 @@ import kotlin.test.fail
@SpringBootTest
class TjenestepensjonV2025ServiceTest {

@MockBean
@MockitoBean
private lateinit var tp: TpClient

@MockBean
@MockitoBean
private lateinit var spk: SPKTjenestepensjonService

@MockBean
@MockitoBean
private lateinit var klp: KLPTjenestepensjonService

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import org.junit.jupiter.api.TestInstance
import org.mockito.Mockito
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import java.time.LocalDate

@SpringBootTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class SPKTjenestepensjonClientTest{

@MockBean
@MockitoBean
private lateinit var aadClient: AADClient
@MockBean
@MockitoBean
private lateinit var maskinportenTokenClient: MaskinportenTokenClient
@Autowired
private lateinit var spkClient: SPKTjenestepensjonClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.bean.override.mockito.MockitoBean
import java.time.LocalDate

@SpringBootTest
class SPKTjenestepensjonServiceTest {

@MockBean
@MockitoBean
private lateinit var client: SPKTjenestepensjonClient

@Autowired
Expand Down

0 comments on commit 466e34e

Please sign in to comment.