From 43823766a949c73fe4aa727df42736e7fc41bcc3 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Wed, 30 Oct 2024 17:50:28 +0200 Subject: [PATCH] Added @AutoConfigureTestDatabase to isolate each test suite's bootstrapped resources --- .../etsi/osl/services/api/ResourceOrderIntegrationTest.java | 1 - .../etsi/osl/services/api/ServiceCatalogIntegrationTest.java | 4 +++- .../api/scm633/ServiceSpecificationApiControllerTest.java | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java index 592b6e4..2a60d58 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java @@ -148,7 +148,6 @@ public class ResourceOrderIntegrationTest { .post("/resourceOrderingManagement/v4/resourceOrder") .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) .content(JsonUtils.toJson( resorder ))) - .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn() diff --git a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java index 511e46c..807e356 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -83,6 +83,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -103,7 +104,7 @@ import net.minidev.json.JSONObject; @RunWith(SpringRunner.class) @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") //@TestPropertySource( @@ -965,6 +966,7 @@ public class ServiceCatalogIntegrationTest { } assertThat(userPartyRoleOwnerexists ).isTrue() ; + List allSpecs = specRepoService.findAll(); assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); assertThat( specRepoService.findAll( null, new HashMap<>()).size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); //this is somehow wrong in Testing ONLY diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java index e5aa51e..dea6f82 100644 --- a/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpHeaders; @@ -48,6 +49,7 @@ import org.springframework.web.context.WebApplicationContext; @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc +@AutoConfigureTestDatabase @ActiveProfiles("testing") public class ServiceSpecificationApiControllerTest { -- GitLab