From ce5b7d73571b050fe2a33e00740b5e6f6e98f2b9 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 14:18:12 +0100 Subject: [PATCH] Removed mocks of JwtDecoder. --- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 8 ------- .../BrukerServiceIntegrationTest.java | 21 +++++++---------- .../no/nav/dolly/MockedJwtDecoderConfig.java | 22 ------------------ .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 9 +++----- .../ApplicationContextTest.java | 12 ++++------ .../ApplicationContextTest.java | 12 ++++------ .../ApplicationContextTest.java | 12 ++++------ .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 18 +++------------ .../orgnrservice/ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../personservice/ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 21 ----------------- .../consumer/ArenaForvalterConsumerTest.java | 19 ++++----------- .../consumer/PdlConsumerTest.java | 21 ++++------------- .../PensjonTestdataFacadeConsumerTest.java | 11 +++------ .../consumer/PersonSearchConsumerTest.java | 10 +++----- .../SyntVedtakshistorikkConsumerTest.java | 10 ++------ .../sdforvalter/JwtDecoderConfig.java | 23 ------------------- .../ApplicationContextTest.java | 7 ------ .../controller/VarslingerControllerTest.java | 5 ---- .../VarslingerPersonControllerTest.java | 12 ---------- 29 files changed, 91 insertions(+), 272 deletions(-) delete mode 100644 apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java delete mode 100644 apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java delete mode 100644 apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java diff --git a/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java b/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java index 2eb944da40e..c4a8080629f 100644 --- a/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java +++ b/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java b/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java index ff2a9c6e847..49691443caf 100644 --- a/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java +++ b/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java @@ -1,10 +1,7 @@ package no.nav.registre.testnorge.arbeidsforholdservice; -import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -13,12 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @DisplayName("Application context should load") void load_app_context() { assertThat(true).isTrue(); } diff --git a/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java b/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java index 0a880e2a08a..91b0dd22dab 100644 --- a/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java +++ b/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java @@ -8,29 +8,22 @@ import no.nav.testnav.libs.securitycore.domain.AccessToken; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.junit.jupiter.api.*; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; import java.io.IOException; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @Tag("integration") class BrukerServiceIntegrationTest { private static final String PID = "01810048413"; private static final String ORGNUMMER = "811306312"; public static MockWebServer mockBackEnd; - @MockBean - JwtDecoder jwtDecoder; private ObjectMapper objectMapper; private WebClient webClient; @@ -65,7 +58,7 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws .setBody(objectMapper.writeValueAsString(new AccessToken("test")))); var token = tokendingsClient.generateToken("dev-gcp:dolly:testnav-bruker-service", PID).block(); - + assertThat(token).isNotNull(); // Create user var expected = new BrukerDTO(null, "username", ORGNUMMER, null, null); @@ -83,7 +76,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws .bodyToMono(BrukerDTO.class) .block(); - Assertions.assertThat(bruker) + assertThat(bruker) + .isNotNull() .usingRecursiveComparison() .comparingOnlyFields("brukernavn", "organisasjonsnummer") .isEqualTo(expected); @@ -132,7 +126,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws .bodyToMono(BrukerDTO.class) .block(); - Assertions.assertThat(updatedUser.brukernavn()).isEqualTo("new-username"); + assertThat(updatedUser).isNotNull(); + assertThat(updatedUser.brukernavn()).isEqualTo("new-username"); mockBackEnd.enqueue( new MockResponse().setResponseCode(200) diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java b/apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java deleted file mode 100644 index 91ea6e800d3..00000000000 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package no.nav.dolly; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.jwt.JwtDecoder; - -@Configuration -@Slf4j -public class MockedJwtDecoderConfig { - - @MockBean - private JwtDecoder jwtDecoder; - - @Bean - public JwtDecoder jwtDecoder() { - log.info("Using a mocked JwtDecoder"); - return jwtDecoder; - } - -} diff --git a/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java b/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java index 1b2c4d1c9b8..205b1bd0fb4 100644 --- a/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java +++ b/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java b/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java index 054bfe6bd61..dd102f395c8 100644 --- a/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java +++ b/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java b/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java index 77490415474..355fae27f01 100644 --- a/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java +++ b/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java b/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java index 9a3aaac3414..f178668a74c 100644 --- a/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java +++ b/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java b/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java index a54dd5c821e..828115f0d3c 100644 --- a/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java +++ b/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java @@ -2,20 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java b/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java index 9fc4b631887..b5c2a008670 100644 --- a/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java +++ b/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java b/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java index b6b552e1b36..671643c7fe8 100644 --- a/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java +++ b/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @ActiveProfiles("test") @SpringBootTest -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java b/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java index 44ecb7599b0..beb878a52ca 100644 --- a/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java +++ b/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @ActiveProfiles("test") @SpringBootTest -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java b/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java index 0a3ef843ece..62b6f52369a 100644 --- a/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java +++ b/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java @@ -3,19 +3,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } \ No newline at end of file diff --git a/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java b/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java index ba30cd1d952..b6071475775 100644 --- a/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java +++ b/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java @@ -3,19 +3,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java b/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java index 28a222eebd2..352c8aa0ee3 100644 --- a/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java +++ b/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - private JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java b/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java index b5cebbd5b6b..6dd3857d70e 100644 --- a/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java +++ b/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java @@ -1,28 +1,16 @@ package no.nav.registre.testnorge.organisasjonservice; import org.junit.Test; -import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@AutoConfigureWireMock(port = 0) -@TestPropertySource(locations = "classpath:application-test.yml") +@SpringBootTest +@ActiveProfiles("test") public class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") public void loadAppContext() { assertThat(true).isTrue(); } diff --git a/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java b/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java index 96a45c6acd5..9183af0d4f0 100644 --- a/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java +++ b/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java b/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java index 821f8f6468b..c1429860143 100644 --- a/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java +++ b/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java b/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java index 369d96f7540..b371304188d 100644 --- a/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java +++ b/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java deleted file mode 100644 index 80ae5ae509b..00000000000 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.testnav.apps.syntvedtakshistorikkservice; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; - - @Test - @SuppressWarnings("java:S2699") - void load_app_context() { - } -} - diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java index a37b8a6e2f3..0131865be90 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java @@ -5,7 +5,6 @@ import no.nav.testnav.libs.securitycore.domain.AccessToken; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -14,8 +13,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; @@ -23,14 +23,10 @@ import java.util.List; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; import static org.junit.jupiter.api.Assertions.assertThrows; - -import org.springframework.test.context.junit.jupiter.SpringExtension; -import reactor.core.publisher.Mono; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -38,9 +34,6 @@ @AutoConfigureWireMock(port = 0) class ArenaForvalterConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -58,9 +51,7 @@ public void setup() { @Test void checkExceptionOccursOnBadSentTilArenaForvalterRequest() { stubOpprettErrorResponse(); - assertThrows(Exception.class, () -> { - arenaForvalterConsumer.sendBrukereTilArenaForvalter(null); - }); + assertThrows(Exception.class, () -> arenaForvalterConsumer.sendBrukereTilArenaForvalter(null)); } @@ -235,7 +226,7 @@ void shouldOppretteRettighetTillegg() { var response = arenaForvalterConsumer.opprettRettighet(rettigheter); - assertThat(response.get(fnr).get(0).getNyeRettigheterTillegg()).hasSize(1); + assertThat(response.get(fnr).getFirst().getNyeRettigheterTillegg()).hasSize(1); } private void stubArenaForvalterOpprettTilleggRettighet() { diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java index bf6f7fe9a56..f5fb7a98982 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java @@ -11,25 +11,17 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import reactor.core.publisher.Mono; import java.util.Collections; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static no.nav.testnav.apps.syntvedtakshistorikkservice.service.TagsService.SYNT_TAGS; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; - -import static no.nav.testnav.apps.syntvedtakshistorikkservice.service.TagsService.SYNT_TAGS; - +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -37,9 +29,6 @@ @AutoConfigureWireMock(port = 0) class PdlConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -57,7 +46,7 @@ void shouldGetPdlPerson() { var response = pdlProxyConsumer.getPdlPerson(IDENT).getData(); var ident = response.getHentIdenter().getIdenter().stream() .filter(identer -> identer.getGruppe().equals(PdlPerson.Gruppe.FOLKEREGISTERIDENT)) - .toList().get(0).getIdent(); + .toList().getFirst().getIdent(); assertThat(ident).isEqualTo(IDENT); assertThat(response.getHentPerson().getBostedsadresse()).hasSize(1); @@ -85,7 +74,7 @@ void shouldGetPdlPersoner() { var response = pdlProxyConsumer.getPdlPersoner(Collections.singletonList(IDENT)).getData(); var bolk = response.getHentPersonBolk(); - var ident = bolk.get(0).getIdent(); + var ident = bolk.getFirst().getIdent(); assertThat(ident).isEqualTo(IDENT); assertThat(bolk).hasSize(1); diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java index 0469281914c..a8d489e3625 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java @@ -13,16 +13,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import reactor.core.publisher.Mono; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -30,9 +28,6 @@ @AutoConfigureWireMock(port = 0) class PensjonTestdataFacadeConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -59,7 +54,7 @@ void shouldOpprettPerson() { var response = pensjonConsumer.opprettPerson(PERSON); assertThat(response.getStatus()).hasSize(1); - assertThat(response.getStatus().get(0).getMiljo()).isEqualTo("q2"); + assertThat(response.getStatus().getFirst().getMiljo()).isEqualTo("q2"); } private void stubOpprettPerson() { @@ -90,7 +85,7 @@ void shouldOpprettInntetk() { var response = pensjonConsumer.opprettInntekt(INNTEKT); assertThat(response.getStatus()).hasSize(1); - assertThat(response.getStatus().get(0).getMiljo()).isEqualTo("q2"); + assertThat(response.getStatus().getFirst().getMiljo()).isEqualTo("q2"); } private void stubOpprettInntekt() { diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java index 6c751b0220b..051f2a48f00 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java @@ -4,6 +4,7 @@ import no.nav.testnav.libs.dto.personsearchservice.v1.search.PersonSearch; import no.nav.testnav.libs.securitycore.domain.AccessToken; import no.nav.testnav.libs.securitycore.domain.ServerProperties; +import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -12,18 +13,16 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; -import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; import reactor.core.publisher.Mono; import java.util.Arrays; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.mockito.Mockito.when; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -31,9 +30,6 @@ @AutoConfigureWireMock(port = 0) class PersonSearchConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -67,7 +63,7 @@ void shouldGetSearchResult() { var response = personSearchConsumer.search(REQUEST); assertThat(response.getItems()).hasSize(1); assertThat(response.getNumberOfItems()).isEqualTo(1); - assertThat(response.getItems().get(0).getIdent()).isEqualTo("11866800000"); + assertThat(response.getItems().getFirst().getIdent()).isEqualTo("11866800000"); } private void stubPostPersonSearch() { diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java index fe0a771cac3..878296f25fd 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java @@ -11,17 +11,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import reactor.core.publisher.Mono; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; - +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -29,9 +26,6 @@ @AutoConfigureWireMock(port = 0) class SyntVedtakshistorikkConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -50,7 +44,7 @@ void shouldGetVedtakshistorikk(){ assertThat(response).hasSize(2); - var historikk1 = response.get(0); + var historikk1 = response.getFirst(); assertThat(historikk1.getAap115()).hasSize(1); assertThat(historikk1.getAap()).hasSize(5); assertThat(historikk1.getAlleVedtak()).hasSize(6); diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java deleted file mode 100644 index 0114dc57053..00000000000 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package no.nav.registre.sdforvalter; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.jwt.JwtDecoder; - -@Configuration -@Slf4j -public class JwtDecoderConfig { - - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - - @Bean - public JwtDecoder jwtDecoder() { - log.info("Using a mocked JwtDecoder"); - return jwtDecoder; - } - -} diff --git a/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java b/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java index e4e96cffc49..7027714d06b 100644 --- a/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java +++ b/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java @@ -2,8 +2,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -12,12 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void loadAppContext() { assertThat(true).isTrue(); } diff --git a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java index 3a823bfb95b..261b6a62b8e 100644 --- a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java +++ b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java @@ -9,9 +9,7 @@ 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.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; @@ -24,9 +22,6 @@ @ActiveProfiles("test") class VarslingerControllerTest { - @MockBean - public JwtDecoder jwtDecoder; - @Autowired private MockMvc mvc; diff --git a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java index 67839a20d53..6664136d0be 100644 --- a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java +++ b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java @@ -12,14 +12,12 @@ import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedId; import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedToken; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; 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.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.web.servlet.MockMvc; @@ -35,9 +33,6 @@ @ActiveProfiles("test") class VarslingerPersonControllerTest { - @MockBean - public JwtDecoder jwtDecoder; - @MockBean public GetAuthenticatedToken getAuthenticatedToken; @@ -59,13 +54,6 @@ class VarslingerPersonControllerTest { @Autowired private ObjectMapper objectMapper; - @BeforeEach - public void beforeEach() { - mottattVarslingRepository.deleteAll(); - brukerRepository.deleteAll(); - varslingRepository.deleteAll(); - } - @AfterEach public void afterEach() { mottattVarslingRepository.deleteAll();