From 782556b524b40f2e81a8bd11f049a414b2e56e80 Mon Sep 17 00:00:00 2001 From: Nikolaos Kyriakoulis Date: Fri, 21 Jun 2024 12:58:20 +0300 Subject: [PATCH 1/2] Fixed number of expected bootstrap items that caused tests to fail in ServiceSpecificationApiControllerTest and ServiceCatalogIntegrationTest --- .../services/api/ServiceCatalogIntegrationTest.java | 12 +++++++----- .../ServiceSpecificationApiControllerTest.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) 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..3dca282 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -113,8 +113,10 @@ public class ServiceCatalogIntegrationTest { private static final transient Log logger = LogFactory.getLog( ServiceCatalogIntegrationTest.class.getName()); - private static final int FIXED_BOOTSTRAPS_SPECS = 1; - + private static final int FIXED_BOOTSTRAPS_SPECS = 3; + + private static final int FIXED_BOOTSTRAPS_REFS = 1; + @Autowired private MockMvc mvc; @@ -161,10 +163,10 @@ public class ServiceCatalogIntegrationTest { assertThat( categRepoService.findByName( "Generic Services" ) ).isNotNull() ; ServiceCategory categ = categRepoService.findByName( "Generic Services" ); - assertThat( categ.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + assertThat( categ.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_REFS ); ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); - assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_REFS ); boolean vinnisbFound = false; boolean gstFound = false; @@ -1013,7 +1015,7 @@ public class ServiceCatalogIntegrationTest { ServiceCategory categ = categRepoService.findByName( "Generic Services" ); ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); - assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_REFS ); ServiceSpecification spec = this.specRepoService.findByNameAndVersion("A GST(NEST) Service Example", "5.0.0" ); assertThat( spec ).isNotNull(); 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..7b62ea9 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 @@ -51,7 +51,7 @@ import org.springframework.web.context.WebApplicationContext; @ActiveProfiles("testing") public class ServiceSpecificationApiControllerTest { - private static final int FIXED_BOOTSTRAPS_SPECS = 1; + private static final int FIXED_BOOTSTRAPS_SPECS = 3; @Autowired private MockMvc mvc; -- GitLab From 3807c1ae1efb456f460f6e24c48e4068dadbc019 Mon Sep 17 00:00:00 2001 From: Nikolaos Kyriakoulis Date: Fri, 21 Jun 2024 15:50:07 +0300 Subject: [PATCH 2/2] Added @AutoConfigureTestDatabase annotation in ServiceCatalogIntegrationTest and ServiceSpecificationApiControllerTest --- .../services/api/ServiceCatalogIntegrationTest.java | 13 ++++++------- .../ServiceSpecificationApiControllerTest.java | 4 +++- 2 files changed, 9 insertions(+), 8 deletions(-) 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 3dca282..657eb28 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( @@ -113,9 +114,7 @@ public class ServiceCatalogIntegrationTest { private static final transient Log logger = LogFactory.getLog( ServiceCatalogIntegrationTest.class.getName()); - private static final int FIXED_BOOTSTRAPS_SPECS = 3; - - private static final int FIXED_BOOTSTRAPS_REFS = 1; + private static final int FIXED_BOOTSTRAPS_SPECS = 1; @Autowired private MockMvc mvc; @@ -163,10 +162,10 @@ public class ServiceCatalogIntegrationTest { assertThat( categRepoService.findByName( "Generic Services" ) ).isNotNull() ; ServiceCategory categ = categRepoService.findByName( "Generic Services" ); - assertThat( categ.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_REFS ); + assertThat( categ.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); - assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_REFS ); + assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); boolean vinnisbFound = false; boolean gstFound = false; @@ -1015,7 +1014,7 @@ public class ServiceCatalogIntegrationTest { ServiceCategory categ = categRepoService.findByName( "Generic Services" ); ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); - assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_REFS ); + assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); ServiceSpecification spec = this.specRepoService.findByNameAndVersion("A GST(NEST) Service Example", "5.0.0" ); assertThat( spec ).isNotNull(); 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 7b62ea9..d4ceeff 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; @@ -47,11 +48,12 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringRunner.class) @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") public class ServiceSpecificationApiControllerTest { - private static final int FIXED_BOOTSTRAPS_SPECS = 3; + private static final int FIXED_BOOTSTRAPS_SPECS = 1; @Autowired private MockMvc mvc; -- GitLab