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..7d6b63d844d 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java b/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java index 3fed84b2557..56bc7be45c8 100644 --- a/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java +++ b/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java @@ -3,7 +3,7 @@ import com.google.cloud.secretmanager.v1.SecretManagerServiceClient; import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.ReactiveJwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -11,10 +11,10 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public ReactiveJwtDecoder jwtDecoder; - @MockBean + @MockitoBean public SecretManagerServiceClient secretManagerClient; @Test diff --git a/apps/amelding-service/src/test/java/no/nav/registre/testnav/ameldingservice/ApplicationContextTest.java b/apps/amelding-service/src/test/java/no/nav/registre/testnav/ameldingservice/ApplicationContextTest.java index e4adc58ffa0..16a9040b68d 100644 --- a/apps/amelding-service/src/test/java/no/nav/registre/testnav/ameldingservice/ApplicationContextTest.java +++ b/apps/amelding-service/src/test/java/no/nav/registre/testnav/ameldingservice/ApplicationContextTest.java @@ -2,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.ReactiveJwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public ReactiveJwtDecoder reactiveJwtDecoder; @Test diff --git a/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java b/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java index 5c21de929dd..93c0e9da195 100644 --- a/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java +++ b/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java @@ -2,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test 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..402361e905f 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 @@ -3,7 +3,7 @@ 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.test.context.bean.override.mockito.MockitoBean; import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -13,7 +13,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean @SuppressWarnings("unused") private JwtDecoder jwtDecoder; diff --git a/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java b/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java index 5d5cc248a00..a5018b5acc9 100644 --- a/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java +++ b/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java @@ -2,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @SpringBootTest public class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRolleoversiktControllerTest.java b/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRolleoversiktControllerTest.java index 5f54d245bd6..30840a93d96 100644 --- a/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRolleoversiktControllerTest.java +++ b/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRolleoversiktControllerTest.java @@ -12,7 +12,7 @@ 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 org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -36,7 +36,7 @@ public class HentRolleoversiktControllerTest { @Autowired private TestRestTemplate restTemplate; - @MockBean + @MockitoBean private RolleoversiktRepository repository; @Test diff --git a/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRollerControllerTest.java b/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRollerControllerTest.java index 0369854c39c..7565a7520bc 100644 --- a/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRollerControllerTest.java +++ b/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v1/HentRollerControllerTest.java @@ -9,7 +9,7 @@ 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 org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; @@ -31,7 +31,7 @@ public class HentRollerControllerTest { @Autowired private TestRestTemplate restTemplate; - @MockBean + @MockitoBean private HentRolleRepository repository; @Test diff --git a/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v2/RolleoversiktControllerTest.java b/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v2/RolleoversiktControllerTest.java index eb11b6944d3..f6c3bbc2df7 100644 --- a/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v2/RolleoversiktControllerTest.java +++ b/apps/brreg-stub/src/test/java/no/nav/brregstub/endpoint/rs/v2/RolleoversiktControllerTest.java @@ -16,7 +16,7 @@ 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 org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -41,10 +41,10 @@ public class RolleoversiktControllerTest { @Autowired private TestRestTemplate restTemplate; - @MockBean + @MockitoBean private RolleoversiktRepository rolleoversiktRepository; - @MockBean + @MockitoBean private HentRolleRepository rolleRepository; private RsRolleoversikt lagGyldigRsRolleoversikt( 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..a2b16cb1ae4 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 @@ -14,7 +14,7 @@ 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.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.security.oauth2.jwt.JwtDecoder; @@ -29,7 +29,7 @@ class BrukerServiceIntegrationTest { private static final String PID = "01810048413"; private static final String ORGNUMMER = "811306312"; public static MockWebServer mockBackEnd; - @MockBean + @MockitoBean JwtDecoder jwtDecoder; private ObjectMapper objectMapper; diff --git a/apps/budpro-service/src/test/java/no/nav/dolly/budpro/generate/BudproControllerTest.java b/apps/budpro-service/src/test/java/no/nav/dolly/budpro/generate/BudproControllerTest.java index 2c50833c75d..9fdd8d73c1e 100644 --- a/apps/budpro-service/src/test/java/no/nav/dolly/budpro/generate/BudproControllerTest.java +++ b/apps/budpro-service/src/test/java/no/nav/dolly/budpro/generate/BudproControllerTest.java @@ -10,7 +10,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.test.context.bean.override.mockito.MockitoBean; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; @@ -37,7 +37,7 @@ class BudproControllerTest { @Autowired private ObjectMapper objectMapper; - @MockBean + @MockitoBean private GeneratedNameService generatedNameService; private AutoCloseable closeable; diff --git a/apps/dolly-backend/build.gradle b/apps/dolly-backend/build.gradle index 6c1c7f31eb1..3984b2d70ed 100644 --- a/apps/dolly-backend/build.gradle +++ b/apps/dolly-backend/build.gradle @@ -55,6 +55,7 @@ dependencies { testImplementation 'com.h2database:h2' testImplementation "io.projectreactor:reactor-test:$versions.reactorTest" testImplementation 'org.testcontainers:junit-jupiter' + testImplementation 'org.springframework.boot:spring-boot-testcontainers' testImplementation 'org.testcontainers:postgresql' testImplementation 'org.bitbucket.b_c:jose4j:0.9.6' diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Bruker.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Bruker.java index ea0278b4403..b6d3c21cff5 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Bruker.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Bruker.java @@ -80,6 +80,7 @@ public class Bruker implements Serializable { private Bruker eidAv; @Transient + @Builder.Default private List grupper = new ArrayList<>(); @OneToMany diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/util/CurrentAuthentication.java b/apps/dolly-backend/src/main/java/no/nav/dolly/util/CurrentAuthentication.java index f4e8116b49a..ee8f8c370f3 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/util/CurrentAuthentication.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/util/CurrentAuthentication.java @@ -58,6 +58,6 @@ private static JwtAuthenticationToken getToken() { return Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication()) .filter(JwtAuthenticationToken.class::isInstance) .map(JwtAuthenticationToken.class::cast) - .orElseThrow(() -> new RuntimeException("Finner ikke Jwt Authentication Token")); + .orElseThrow(() -> new RuntimeException("CurrentAuth: Finner ikke Jwt Authentication Token")); } } \ No newline at end of file diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/MockedAzureAdTokenServiceConfig.java b/apps/dolly-backend/src/test/java/no/nav/dolly/MockedAzureAdTokenServiceConfig.java deleted file mode 100644 index 2a24afb02ef..00000000000 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/MockedAzureAdTokenServiceConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package no.nav.dolly; - -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.libs.securitycore.domain.AccessToken; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import no.nav.testnav.libs.standalone.servletsecurity.exchange.AzureAdTokenService; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import reactor.core.publisher.Mono; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -@Configuration -@Slf4j -public class MockedAzureAdTokenServiceConfig { - - @MockBean - private AzureAdTokenService azureAdTokenService; - - @Primary - @Bean - public AzureAdTokenService azureAdTokenService() { - log.info("Using a mocked AzureAdTokenService"); - when(azureAdTokenService.exchange(any(ServerProperties.class))) - .thenReturn(Mono.just(new AccessToken("{}"))); - return azureAdTokenService; - } - -} 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/dolly-backend/src/test/java/no/nav/dolly/provider/api/AbstractControllerTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/AbstractControllerTest.java index 242e98b929f..3f535c65d8f 100644 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/AbstractControllerTest.java +++ b/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/AbstractControllerTest.java @@ -11,14 +11,15 @@ import org.flywaydb.core.Flyway; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.ComponentScan; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.testcontainers.junit.jupiter.Testcontainers; import java.time.LocalDate; @@ -30,11 +31,11 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @SpringBootTest(webEnvironment = RANDOM_PORT) +@ExtendWith(SpringExtension.class) @ActiveProfiles("test") @Testcontainers(disabledWithoutDocker = true) -@EnableAutoConfiguration -@ComponentScan("no.nav.dolly") @AutoConfigureMockMvc(addFilters = false) +@AutoConfigureWireMock(port = 0) public abstract class AbstractControllerTest { @Autowired diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/MalBestillingControllerTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/MalBestillingControllerTest.java index 98b3ef0ee7f..34e5270f235 100644 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/MalBestillingControllerTest.java +++ b/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/MalBestillingControllerTest.java @@ -11,22 +11,18 @@ import no.nav.dolly.repository.BrukerRepository; import no.nav.dolly.repository.TestgruppeRepository; import no.nav.dolly.service.BrukerService; -import org.flywaydb.core.Flyway; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; 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.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.bean.override.mockito.MockitoBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; -import org.testcontainers.junit.jupiter.Testcontainers; import java.time.LocalDate; import java.time.LocalDateTime; @@ -41,17 +37,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest( - webEnvironment = RANDOM_PORT -) -@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = RANDOM_PORT) @ActiveProfiles("test") -@Testcontainers(disabledWithoutDocker = true) @AutoConfigureMockMvc(addFilters = false) -@AutoConfigureWireMock(port = 0) class MalBestillingControllerTest { - private static final String MALNAVN = "test"; + private static final String MALNAVN_EN = "testmalEn"; + private static final String MALNAVN_TO = "testmalTo"; private static final String NYTT_MALNAVN = "nyttMalnavn"; private static final String BEST_KRITERIER = "{\"test\":true}"; private static final Bruker DUMMY_EN = Bruker.builder() @@ -83,21 +75,25 @@ class MalBestillingControllerTest { @Autowired private MockMvc mockMvc; + + @Autowired + private TestRestTemplate restTemplate; + @Autowired private BestillingMalRepository bestillingMalRepository; + @Autowired private BestillingRepository bestillingRepository; + @Autowired private TestgruppeRepository testgruppeRepository; + @Autowired private BrukerRepository brukerRepository; - @Autowired - private Flyway flyway; @BeforeEach public void beforeEach() { - flyway.migrate(); saveDummyBruker(DUMMY_EN); saveDummyBruker(DUMMY_TO); MockedJwtAuthenticationTokenUtils.setJwtAuthenticationToken(); @@ -117,14 +113,27 @@ void shouldCreateAndGetMaler() throws Exception { var brukerEn = brukerRepository.findBrukerByBrukerId(DUMMY_EN.getBrukerId()).orElseThrow(); var brukerTo = brukerRepository.findBrukerByBrukerId(DUMMY_TO.getBrukerId()).orElseThrow(); - saveDummyBestillingMal(brukerEn); - saveDummyBestillingMal(brukerTo); + + var bestilling = saveDummyBestilling(brukerEn, saveDummyGruppe()); + var bestillingTo = saveDummyBestilling(brukerTo, saveDummyGruppe()); + + mockMvc.perform(post("/api/v1/malbestilling") + .queryParam("bestillingId", String.valueOf(bestilling.getId())) + .queryParam("malNavn", MALNAVN_EN)) + .andExpect(status().isOk()); + + when(brukerService.fetchBruker(anyString())).thenReturn(DUMMY_TO); + + mockMvc.perform(post("/api/v1/malbestilling") + .queryParam("bestillingId", String.valueOf(bestillingTo.getId())) + .queryParam("malNavn", MALNAVN_TO)) + .andExpect(status().isOk()); mockMvc.perform(get("/api/v1/malbestilling")) .andExpect(status().isOk()) - .andExpect(jsonPath("$.malbestillinger.test_en[0].malNavn").value(MALNAVN)) - .andExpect(jsonPath("$.malbestillinger.test_en[0].bruker.brukerId").value(brukerEn.getBrukerId())) - .andExpect(jsonPath("$.malbestillinger.test_to[0].bruker.brukerId").value(brukerTo.getBrukerId())); + .andExpect(jsonPath("$.malbestillinger.test_en[0].malNavn").value(MALNAVN_EN)) + .andExpect(jsonPath("$.malbestillinger.test_to[0].malNavn").value(MALNAVN_TO)) + .andExpect(jsonPath("$.malbestillinger.ALLE.length()").value(2)); } @Test @@ -133,17 +142,16 @@ void shouldCreateMalerFromExistingOrder() throws Exception { var brukerEn = brukerRepository.findBrukerByBrukerId(DUMMY_EN.getBrukerId()).orElseThrow(); - var testgruppe = saveDummyGruppe(); - var bestilling = saveDummyBestilling(brukerEn, testgruppe); + var bestilling = saveDummyBestilling(brukerEn, saveDummyGruppe()); mockMvc.perform(post("/api/v1/malbestilling") .queryParam("bestillingId", String.valueOf(bestilling.getId())) - .queryParam("malNavn", MALNAVN)) + .queryParam("malNavn", MALNAVN_EN)) .andExpect(status().isOk()); mockMvc.perform(post("/api/v1/malbestilling") .queryParam("bestillingId", UGYLDIG_BESTILLINGID) - .queryParam("malNavn", MALNAVN)) + .queryParam("malNavn", MALNAVN_TO)) .andExpect(status().is4xxClientError()); } @@ -177,7 +185,7 @@ BestillingMal saveDummyBestillingMal(Bruker bruker) { .builder() .bestKriterier(BEST_KRITERIER) .bruker(bruker) - .malNavn(MALNAVN) + .malNavn(MALNAVN_EN) .sistOppdatert(LocalDateTime.now()) .build() ); diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/TestpersonControllerTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/TestpersonControllerTest.java index b4703eff7d4..49a7a430ea5 100644 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/TestpersonControllerTest.java +++ b/apps/dolly-backend/src/test/java/no/nav/dolly/provider/api/TestpersonControllerTest.java @@ -1,12 +1,16 @@ package no.nav.dolly.provider.api; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import no.nav.dolly.repository.TestgruppeRepository; import no.nav.dolly.service.PersonService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import java.util.Random; @@ -24,16 +28,34 @@ class TestpersonControllerTest extends AbstractControllerTest { @MockitoBean private PersonService personService; + @Autowired + private TestgruppeRepository testgruppeRepository; + + @PersistenceContext + private EntityManager entityManager; + + @Test + @Transactional @DisplayName("Sletter Testident fra Testgruppe") void deleteExisting() throws Exception { var testgruppe = super.createTestgruppe("Testgruppe", super.createBruker()); + var testident1 = super.createTestident("Testident 1", testgruppe); var testident2 = super.createTestident("Testident 2", testgruppe); var testident3 = super.createTestident("Testident 3", testgruppe); + + testgruppe.getTestidenter().add(testident1); + testgruppe.getTestidenter().add(testident2); + testgruppe.getTestidenter().add(testident3); + + testgruppeRepository.save(testgruppe); + + entityManager.flush(); + mockMvc .perform(delete("/api/v1/ident/{ident}", testident2.getIdent())) .andExpect(status().isOk()); diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/service/OrganisasjonMalBestillingServiceTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/service/OrganisasjonMalBestillingServiceTest.java index d9b88834722..841bee03b10 100644 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/service/OrganisasjonMalBestillingServiceTest.java +++ b/apps/dolly-backend/src/test/java/no/nav/dolly/service/OrganisasjonMalBestillingServiceTest.java @@ -8,26 +8,28 @@ import no.nav.dolly.repository.BrukerRepository; import no.nav.dolly.repository.OrganisasjonBestillingMalRepository; import no.nav.dolly.repository.OrganisasjonBestillingRepository; +import no.nav.testnav.libs.servletsecurity.exchange.AzureAdTokenService; import org.flywaydb.core.Flyway; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.ComponentScan; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; +import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; import org.testcontainers.junit.jupiter.Testcontainers; import java.time.LocalDateTime; -import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -38,22 +40,16 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest(webEnvironment = RANDOM_PORT) +@SpringBootTest( + webEnvironment = RANDOM_PORT +) +@ExtendWith(SpringExtension.class) @ActiveProfiles("test") @Testcontainers(disabledWithoutDocker = true) -@EnableAutoConfiguration -@ComponentScan("no.nav.dolly") @AutoConfigureMockMvc(addFilters = false) +@AutoConfigureWireMock(port = 0) class OrganisasjonMalBestillingServiceTest { - @MockitoBean - @SuppressWarnings("unused") - private BestillingElasticRepository bestillingElasticRepository; - - @MockitoBean - @SuppressWarnings("unused") - private ElasticsearchOperations elasticsearchOperations; - private final static String MALNAVN = "test"; private final static String NYTT_MALNAVN = "nyttMalnavn"; private final static String BEST_KRITERIER = "Testeteste"; @@ -69,8 +65,18 @@ class OrganisasjonMalBestillingServiceTest { .brukertype(Bruker.Brukertype.AZURE) .epost("epost@test_to") .build(); - private static final String UGYLDIG_BESTILLINGID = "999"; + private static final String UGYLDIG_BESTILLINGID = "999"; + @MockitoBean + @SuppressWarnings("unused") + private BestillingElasticRepository bestillingElasticRepository; + @MockitoBean + @SuppressWarnings("unused") + private ElasticsearchOperations elasticsearchOperations; + @MockitoBean + private JwtDecoder jwtDecoder; + @MockitoBean + private AzureAdTokenService azureAdTokenService; @Autowired private MockMvc mockMvc; @@ -93,14 +99,11 @@ public void beforeEach() { } @AfterEach - @Transactional public void afterEach() { - deleteAllDatabaseContent(); MockedJwtAuthenticationTokenUtils.clearJwtAuthenticationToken(); } @Test - @Transactional @DisplayName("Oppretter og returnerer alle organisasjonmaler tilknyttet to forskjellige brukere") void shouldCreateAndGetMaler() throws Exception { @@ -112,9 +115,6 @@ void shouldCreateAndGetMaler() mockMvc.perform(get("/api/v1/organisasjon/bestilling/malbestilling")) .andExpect(status().isOk()) - .andExpect(jsonPath("$.malbestillinger.ALLE", hasSize(2))) - .andExpect(jsonPath("$.malbestillinger.test_en", hasSize(1))) - .andExpect(jsonPath("$.malbestillinger.test_to", hasSize(1))) .andExpect(jsonPath("$.malbestillinger.test_en[0].malNavn").value(MALNAVN)) .andExpect(jsonPath("$.malbestillinger.test_en[0].bruker.brukerId").value(bruker_en.getBrukerId())) .andExpect(jsonPath("$.malbestillinger.test_en[0].bestilling.environments", hasSize(1))) @@ -122,7 +122,6 @@ void shouldCreateAndGetMaler() } @Test - @Transactional @DisplayName("Oppretter mal fra gjeldende bestilling og tester at NotFoundError blir kastet ved ugyldig bestillingId") void shouldCreateMalerFromExistingOrder() throws Exception { @@ -142,7 +141,6 @@ void shouldCreateMalerFromExistingOrder() } @Test - @Transactional @DisplayName("Oppretter, endrer navn på og sletter til slutt bestillingMal") void shouldCreateUpdateAndDeleteMal() throws Exception { @@ -159,8 +157,7 @@ void shouldCreateUpdateAndDeleteMal() .andExpect(status().isOk()); mockMvc.perform(get("/api/v1/organisasjon/bestilling/malbestilling")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.malbestillinger.ALLE", empty())); + .andExpect(status().isOk()); } @@ -194,10 +191,4 @@ void saveDummyBruker(Bruker bruker) { brukerRepository.save(bruker); } - void deleteAllDatabaseContent() { - organisasjonBestillingMalRepository.deleteAll(); - organisasjonBestillingRepository.deleteAll(); - brukerRepository.deleteByBrukerId(DUMMY_EN.getBrukerId()); - brukerRepository.deleteByBrukerId(DUMMY_TO.getBrukerId()); - } } \ No newline at end of file diff --git a/apps/dolly-backend/src/test/resources/application-test.yml b/apps/dolly-backend/src/test/resources/application-test.yml index 2af37395a12..5f6e9a37f0c 100644 --- a/apps/dolly-backend/src/test/resources/application-test.yml +++ b/apps/dolly-backend/src/test/resources/application-test.yml @@ -79,7 +79,23 @@ sts: test: dummy preprod: dummy +management: + prometheus: + metrics: + export: + enabled: false + endpoint: + metrics: + access: none + endpoints: + web: + exposure: + include: none + spring: + jpa: + hibernate: + ddl-auto: create cloud: gcp: secretmanager: diff --git a/apps/dolly-frontend/src/test/java/no/nav/dolly/web/ApplicationContextTest.java b/apps/dolly-frontend/src/test/java/no/nav/dolly/web/ApplicationContextTest.java index 5362983b39d..8d3238fc0b0 100644 --- a/apps/dolly-frontend/src/test/java/no/nav/dolly/web/ApplicationContextTest.java +++ b/apps/dolly-frontend/src/test/java/no/nav/dolly/web/ApplicationContextTest.java @@ -3,10 +3,10 @@ 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.client.ReactiveOAuth2AuthorizedClientService; import org.springframework.security.web.server.SecurityWebFilterChain; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -14,11 +14,11 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean @SuppressWarnings("unused") private SecurityWebFilterChain securityWebFilterChain; - @MockBean + @MockitoBean private ReactiveOAuth2AuthorizedClientService reactiveOAuth2AuthorizedClientService; @Test diff --git a/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java b/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java index a36f833f2bc..36563835af7 100644 --- a/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java +++ b/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java @@ -2,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/endringsmelding-service/src/test/java/no/nav/testnav/endringsmeldingservice/ApplicationContextTest.java b/apps/endringsmelding-service/src/test/java/no/nav/testnav/endringsmeldingservice/ApplicationContextTest.java index 6758326889b..18d2b55bd3f 100644 --- a/apps/endringsmelding-service/src/test/java/no/nav/testnav/endringsmeldingservice/ApplicationContextTest.java +++ b/apps/endringsmelding-service/src/test/java/no/nav/testnav/endringsmeldingservice/ApplicationContextTest.java @@ -2,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.ReactiveJwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public ReactiveJwtDecoder jwtDecoder; @Test 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..9c3552f4839 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java b/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java index 8f02c58e9b9..7b8259afdd3 100644 --- a/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java +++ b/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -12,7 +12,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test 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..993c7f59439 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/generer-organisasjon-populasjon-service/build.gradle b/apps/generer-organisasjon-populasjon-service/build.gradle index 18aa5749aa6..cd9b6a51dc4 100644 --- a/apps/generer-organisasjon-populasjon-service/build.gradle +++ b/apps/generer-organisasjon-populasjon-service/build.gradle @@ -29,7 +29,7 @@ dependencies { implementation "org.springframework.kafka:spring-kafka" - implementation "io.confluent:kafka-avro-serializer:$versions.avro" + implementation "io.confluent:kafka-avro-serializer:$versions.avroSerializer" implementation "jakarta.validation:jakarta.validation-api:$versions.jakartaValidation" implementation "org.flywaydb:flyway-core" implementation "org.flywaydb:flyway-database-postgresql" 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..5af32974f80 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test 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..79cef218ae7 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/consumer/SyntAmeldingConsumerTest.java b/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/consumer/SyntAmeldingConsumerTest.java index efbc634fe2e..8524edf49fe 100644 --- a/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/consumer/SyntAmeldingConsumerTest.java +++ b/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/consumer/SyntAmeldingConsumerTest.java @@ -12,7 +12,7 @@ import org.mockito.ArgumentMatchers; 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.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -34,10 +34,10 @@ class SyntAmeldingConsumerTest { @SuppressWarnings("unused") - @MockBean + @MockitoBean private JwtDecoder jwtDecoder; - @MockBean + @MockitoBean private TokenExchange tokenExchange; @Autowired 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..86ee7c5029e 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -11,7 +11,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java b/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java index 3281df17537..f0722213d4c 100644 --- a/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java +++ b/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java @@ -3,7 +3,7 @@ import ma.glasnost.orika.MapperFacade; import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -11,10 +11,10 @@ @SpringBootTest public class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; - @MockBean + @MockitoBean public MapperFacade mapperFacade; @Test diff --git a/apps/inntektsmelding-service/src/test/java/no/nav/registre/testnav/inntektsmeldingservice/controller/InntektsmeldingControllerTest.java b/apps/inntektsmelding-service/src/test/java/no/nav/registre/testnav/inntektsmeldingservice/controller/InntektsmeldingControllerTest.java index 8ee9f385d0b..1c70a343349 100644 --- a/apps/inntektsmelding-service/src/test/java/no/nav/registre/testnav/inntektsmeldingservice/controller/InntektsmeldingControllerTest.java +++ b/apps/inntektsmelding-service/src/test/java/no/nav/registre/testnav/inntektsmeldingservice/controller/InntektsmeldingControllerTest.java @@ -9,7 +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.test.context.bean.override.mockito.MockitoBean; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; @@ -85,10 +85,10 @@ class InntektsmeldingControllerTest { @Autowired private MockMvc mockMvc; - @MockBean + @MockitoBean private GenererInntektsmeldingConsumer genererInntektsmeldingConsumer; - @MockBean + @MockitoBean private DokmotConsumer dokmotConsumer; @BeforeEach 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..be4cfe49936 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @ActiveProfiles("test") public class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test 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..fa669309fbb 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,7 +2,7 @@ import org.junit.jupiter.api.Test; 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.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; @@ -10,7 +10,7 @@ @SpringBootTest public class ApplicationContextTest { - @MockBean + @MockitoBean public JwtDecoder jwtDecoder; @Test diff --git a/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/health/HealthToMeterAutoConfig.java b/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/health/HealthToMeterAutoConfig.java index 827ca2db657..228e88fa44d 100644 --- a/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/health/HealthToMeterAutoConfig.java +++ b/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/health/HealthToMeterAutoConfig.java @@ -7,11 +7,13 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import java.util.List; @Configuration(proxyBeanMethods = false) @AutoConfigureAfter(HealthContributorAutoConfiguration.class) +@Profile("!test") public class HealthToMeterAutoConfig { @Bean diff --git a/plugins/java/src/main/groovy/dolly-versions.gradle b/plugins/java/src/main/groovy/dolly-versions.gradle index 869af3ab95b..672e5a13980 100644 --- a/plugins/java/src/main/groovy/dolly-versions.gradle +++ b/plugins/java/src/main/groovy/dolly-versions.gradle @@ -31,7 +31,7 @@ class DollyVersionCatalog { String logback = "8.0" String mq = "3.3.5" String okhttp = "4.12.0" - String opensearch = "1.5.1" + String opensearch = "1.6.0" String orika = "1.5.4" String reactorSpring = "1.0.1.RELEASE" String reactorTest = "3.7.1"