From bbfe4152ca2876a07a9c37a7e4eda41a867ba90b Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Fri, 15 Dec 2023 17:30:45 +0200 Subject: [PATCH 1/7] Fixed ResourceOrderIntegrationTest -> testResourceOrderCreate, ResourcePoolIntegrationTest -> testResourcePoolCreateAndUpdate --- src/test/java/org/etsi/osl/services/api/JsonUtils.java | 2 ++ .../etsi/osl/services/api/ResourceOrderIntegrationTest.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/etsi/osl/services/api/JsonUtils.java b/src/test/java/org/etsi/osl/services/api/JsonUtils.java index 404d704..8103a53 100644 --- a/src/test/java/org/etsi/osl/services/api/JsonUtils.java +++ b/src/test/java/org/etsi/osl/services/api/JsonUtils.java @@ -5,6 +5,7 @@ import java.io.InputStream; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; /** * @author ctranoris @@ -27,6 +28,7 @@ public class JsonUtils { static T toJsonObj(String content, Class valueType) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); return mapper.readValue(content, valueType); } 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 5c52908..249fced 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java @@ -78,7 +78,7 @@ public class ResourceOrderIntegrationTest { public void testResourceOrderCreate() throws UnsupportedEncodingException, IOException, Exception { - File sspec = new File("src/main/resources/resourceSpecifications/OSMTenantResourceSpecification.json"); + File sspec = new File("src/main/resources/resourceSpecifications/osm-tenant.openslice.io.json"); InputStream in = new FileInputStream(sspec); String sspectext = IOUtils.toString(in, "UTF-8"); @@ -162,7 +162,7 @@ public class ResourceOrderIntegrationTest { assertThat( responseRO.getRequestedCompletionDate()).isNotNull(); assertThat( responseRO.getOrderItem().stream().findFirst().get() ).isNotNull(); assertThat( responseRO.getOrderItem().stream().findFirst().get().getResource().getId() ).isNotNull(); - assertThat( responseRO.getOrderItem().stream().findFirst().get().getResource().getName() ).isEqualTo( "OSM Tenant" ) ; + assertThat( responseRO.getOrderItem().stream().findFirst().get().getResource().getName() ).isEqualTo( "osm-tenant.openslice.io" ) ; } private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception { -- GitLab From 2bf1912a0480365baca4b5074f57fbdf4c2bb4a2 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 18 Dec 2023 12:36:08 +0200 Subject: [PATCH 2/7] Refactored json utlis. No more seperate utils for tests and main --- src/main/java/org/etsi/osl/tmf/JsonUtils.java | 11 +++-- .../api/AlarmManagementIntegrationTest.java | 3 ++ .../services/api/CustomerIntegrationTest.java | 3 ++ .../org/etsi/osl/services/api/JsonUtils.java | 41 ------------------- .../services/api/LCMRulesIntegrationTest.java | 3 ++ .../api/PartyManagementIntegrationTest.java | 3 ++ .../api/ProductCatalogIntegrationTest.java | 3 ++ .../api/ResourceCatalogIntegrationTest.java | 3 ++ .../api/ResourceInventoryIntegrationTest.java | 3 ++ .../api/ResourceOrderIntegrationTest.java | 3 ++ .../api/ResourcePoolIntegrationTest.java | 3 ++ .../api/ServiceCatalogIntegrationTest.java | 3 ++ .../api/ServiceInventoryIntegrationTest.java | 3 ++ .../api/ServiceOrderIntegrationTest.java | 3 ++ .../ServiceTestManagementIntegrationTest.java | 3 ++ 15 files changed, 47 insertions(+), 44 deletions(-) delete mode 100644 src/test/java/org/etsi/osl/services/api/JsonUtils.java diff --git a/src/main/java/org/etsi/osl/tmf/JsonUtils.java b/src/main/java/org/etsi/osl/tmf/JsonUtils.java index 92689cb..ff2221e 100644 --- a/src/main/java/org/etsi/osl/tmf/JsonUtils.java +++ b/src/main/java/org/etsi/osl/tmf/JsonUtils.java @@ -5,6 +5,7 @@ import java.io.InputStream; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; /** * @author ctranoris @@ -12,27 +13,31 @@ import com.fasterxml.jackson.databind.ObjectMapper; */ public class JsonUtils { - static byte[] toJson(Object object) throws IOException { + public static byte[] toJson(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); return mapper.writeValueAsBytes(object); } - static String toJsonString(Object object) throws IOException { + public static String toJsonString(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); return mapper.writeValueAsString(object); } public static T toJsonObj(String content, Class valueType) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); return mapper.readValue(content, valueType); } - static T toJsonObj(InputStream content, Class valueType) throws IOException { + public static T toJsonObj(InputStream content, Class valueType) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); return mapper.readValue(content, valueType); } diff --git a/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java index 8b60016..df10383 100644 --- a/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import org.apache.camel.ProducerTemplate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.am642.model.AffectedService; import org.etsi.osl.tmf.am642.model.Alarm; @@ -46,6 +47,8 @@ import org.etsi.osl.tmf.am642.model.Comment; import org.etsi.osl.tmf.am642.model.PerceivedSeverityType; import org.etsi.osl.tmf.am642.model.ProbableCauseType; import org.etsi.osl.tmf.am642.reposervices.AlarmRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java index c710490..48d79bb 100644 --- a/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java @@ -31,6 +31,7 @@ import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.cm629.model.Customer; import org.etsi.osl.tmf.cm629.model.CustomerCreate; @@ -39,6 +40,8 @@ import org.etsi.osl.tmf.cm629.service.CustomerRepoService; import org.etsi.osl.tmf.pm632.model.ContactMedium; import org.etsi.osl.tmf.pm632.model.MediumCharacteristic; import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/test/java/org/etsi/osl/services/api/JsonUtils.java b/src/test/java/org/etsi/osl/services/api/JsonUtils.java deleted file mode 100644 index 8103a53..0000000 --- a/src/test/java/org/etsi/osl/services/api/JsonUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.etsi.osl.services.api; - -import java.io.IOException; -import java.io.InputStream; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; - -/** - * @author ctranoris - * - */ -public class JsonUtils { - - static byte[] toJson(Object object) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - return mapper.writeValueAsBytes(object); - } - - static String toJsonString(Object object) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - return mapper.writeValueAsString(object); - } - - static T toJsonObj(String content, Class valueType) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.registerModule(new JavaTimeModule()); - return mapper.readValue(content, valueType); - } - - static T toJsonObj(InputStream content, Class valueType) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - return mapper.readValue(content, valueType); - } - -} diff --git a/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java index 12a1205..760adbe 100644 --- a/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java @@ -12,6 +12,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; import org.etsi.osl.tmf.lcm.model.ELCMRulePhase; @@ -19,6 +20,8 @@ import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationCreate; import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationUpdate; import org.etsi.osl.tmf.lcm.reposervices.LCMRuleSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java index 7f00241..a328d44 100644 --- a/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; + import org.etsi.osl.tmf.pm632.model.Characteristic; import org.etsi.osl.tmf.pm632.model.ContactMedium; import org.etsi.osl.tmf.pm632.model.Individual; @@ -44,6 +45,8 @@ import org.etsi.osl.tmf.pm632.model.Organization; import org.etsi.osl.tmf.pm632.model.OrganizationCreate; import org.etsi.osl.tmf.pm632.reposervices.IndividualRepoService; import org.etsi.osl.tmf.pm632.reposervices.OrganizationRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java index de3915c..fc2b66e 100644 --- a/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java @@ -34,6 +34,7 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.pcm620.model.BundledProductOffering; import org.etsi.osl.tmf.pcm620.model.Catalog; @@ -61,6 +62,8 @@ import org.etsi.osl.tmf.pcm620.reposervices.ProductCategoryRepoService; import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingPriceRepoService; import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingRepoService; import org.etsi.osl.tmf.pcm620.reposervices.ProductSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java index 039a619..9a402d7 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java @@ -38,6 +38,7 @@ import java.net.URI; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.Attachment; @@ -69,6 +70,8 @@ import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService; import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService; import org.etsi.osl.tmf.rcm634.reposervices.ResourceCategoryRepoService; import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java index 2720c73..06f4601 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java @@ -39,6 +39,7 @@ import java.util.ArrayList; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.UserPartRoleType; @@ -63,6 +64,8 @@ import org.etsi.osl.tmf.ri639.model.ResourceOperationalStateType; import org.etsi.osl.tmf.ri639.model.ResourceRelationship; import org.etsi.osl.tmf.ri639.model.ResourceUpdate; import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; 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 249fced..592b6e4 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java @@ -18,6 +18,7 @@ import java.util.Set; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; @@ -36,6 +37,8 @@ import org.etsi.osl.tmf.ro652.model.ExternalId; import org.etsi.osl.tmf.ro652.model.ResourceOrder; import org.etsi.osl.tmf.ro652.model.ResourceOrderCreate; import org.etsi.osl.tmf.ro652.model.ResourceOrderItem; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java index 66f3738..a9763dd 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java @@ -40,6 +40,7 @@ import java.util.Set; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.service.ResourceRef; import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; @@ -65,6 +66,8 @@ import org.etsi.osl.tmf.rpm685.model.ResourcePoolCreate; import org.etsi.osl.tmf.rpm685.model.ResourcePoolRef; import org.etsi.osl.tmf.rpm685.model.ResourcePoolUpdate; import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; 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 f5da7aa..415b9c9 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -42,6 +42,7 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.BootstrapRepository; import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; @@ -76,6 +77,8 @@ import org.etsi.osl.tmf.scm633.reposervices.CandidateRepoService; import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java index c8e7164..d31dd72 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java @@ -38,6 +38,7 @@ import java.time.ZoneOffset; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.UserPartRoleType; @@ -59,6 +60,8 @@ import org.etsi.osl.tmf.sim638.model.ServiceActionQueueAction; import org.etsi.osl.tmf.sim638.model.ServiceCreate; import org.etsi.osl.tmf.sim638.model.ServiceUpdate; import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java index f0ae5a5..71849ba 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java @@ -40,6 +40,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.UserPartRoleType; @@ -67,6 +68,8 @@ import org.etsi.osl.tmf.so641.model.ServiceOrderStateType; import org.etsi.osl.tmf.so641.model.ServiceOrderUpdate; import org.etsi.osl.tmf.so641.model.ServiceRestriction; import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java index a3acefa..dc212c3 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java @@ -35,12 +35,15 @@ import java.io.UnsupportedEncodingException; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.sim638.service.ServiceRepoService; import org.etsi.osl.tmf.stm653.model.ServiceTestCreate; import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreate; import org.etsi.osl.tmf.stm653.reposervices.ServiceTestRepoService; import org.etsi.osl.tmf.stm653.reposervices.ServiceTestSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -- GitLab From f399dae16770b7f747e72015733f55d64319813e Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 18 Dec 2023 13:22:01 +0200 Subject: [PATCH 3/7] fixed ResourceInventoryIntegrationTest --- .../osl/services/api/ResourceInventoryIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java index 06f4601..ee4d7a4 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java @@ -294,7 +294,7 @@ public class ResourceInventoryIntegrationTest { assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); assertThat( responseRes2.getEndOperatingDate() ).isNotNull(); - assertThat( responseRes2.getNote().size() ).isEqualTo( 3 ); + assertThat( responseRes2.getNote().size() ).isEqualTo( 4 ); assertThat( responseRes2.getResourceCharacteristic().size() ).isEqualTo( 2 ); assertThat( responseRes2.getResourceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; assertThat( responseRes2.getResourceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "007a008" ) ; @@ -320,7 +320,7 @@ public class ResourceInventoryIntegrationTest { assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); assertThat( responseRes2.getEndOperatingDate() ).isNotNull(); - assertThat( responseRes2.getNote().size() ).isEqualTo( 3 ); + assertThat( responseRes2.getNote().size() ).isEqualTo( 4 ); assertThat( responseRes2.getResourceCharacteristic().size() ).isEqualTo( 2 ); assertThat( responseRes2.getResourceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; assertThat( responseRes2.getResourceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "007a008" ) ; @@ -347,7 +347,7 @@ public class ResourceInventoryIntegrationTest { assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); assertThat( responseRes2.getEndOperatingDate() ).isNotNull(); - assertThat( responseRes2.getNote().size() ).isEqualTo( 4 ); + assertThat( responseRes2.getNote().size() ).isEqualTo( 5 ); assertThat( responseRes2.getResourceCharacteristic().size() ).isEqualTo( 2 ); assertThat( responseRes2.getResourceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; assertThat( responseRes2.getResourceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "007a008" ) ; -- GitLab From e684c9c22f1be41308e668ef2b98a4c6e77e5d78 Mon Sep 17 00:00:00 2001 From: Kyriakoulis Date: Mon, 18 Dec 2023 14:12:49 +0200 Subject: [PATCH 4/7] Fixed ResourceCatalogIntegrationTest --- .../api/ResourceCatalogIntegrationTest.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java index 039a619..4459423 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java @@ -102,10 +102,11 @@ public class ResourceCatalogIntegrationTest { private static final transient Log logger = LogFactory.getLog( ResourceCatalogIntegrationTest.class.getName()); - private static final int FIXED_BOOTSTRAPS_SPECS = 3; - private static final int FIXED_BOOTSTRAPS_CATEGORIES = 2; + private static final int FIXED_BOOTSTRAPS_SPECS = 7; + private static final int FIXED_BOOTSTRAPS_CATEGORIES = 3; private static final int FIXED_BOOTSTRAPS_PHYSICAL_SPECS = 1; - private static final int FIXED_BOOTSTRAPS_LOGICAL_SPECS = 2; + private static final int FIXED_BOOTSTRAPS_NETWORK_SPECS = 3; + private static final int FIXED_BOOTSTRAPS_LOGICAL_SPECS = 6; @Autowired private MockMvc mvc; @@ -137,9 +138,8 @@ public class ResourceCatalogIntegrationTest { @Test public void _countDefaultProperties() { - assertThat( catalogRepoService.findAll().size() ).isEqualTo( 1 ); - assertThat( categRepoService.findAll().size() ).isEqualTo( 2 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES ); assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); @@ -148,7 +148,7 @@ public class ResourceCatalogIntegrationTest { assertThat( categRepoService.findByName( "Network Resources" ) ).isNotNull() ; ResourceCategory categ = categRepoService.findByName( "Network Resources" ); - assertThat( categ.getResourceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + assertThat( categ.getResourceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_NETWORK_SPECS ); } @@ -376,12 +376,11 @@ public class ResourceCatalogIntegrationTest { assertThat( parentRootCategory.getCategoryRefs().get(0).getId() ).isEqualTo( child1Subcategory.getId() ); /** - * add to a resource catalog and delete the service catalog, to chech that categories are still there + * add to a resource catalog and delete the service catalog, to check that categories are still there * */ - - ResourceCatalog catalog = catalogRepoService.findByName( "Catalog" ); - assertThat( catalog.getCategoryRefs().size() ).isEqualTo( 2 ); + ResourceCatalog catalog = catalogRepoService.findByName( "Catalog" ); + assertThat( catalog.getCategoryRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES ); ResourceCatalogUpdate scu = new ResourceCatalogUpdate(); scu.setName( catalog.getName() ); for (ResourceCategoryRef iref : catalog.getCategoryRefs()) { @@ -392,7 +391,7 @@ public class ResourceCatalogIntegrationTest { scu.addCategoryItem( categoryItem ); catalog = catalogRepoService.updateCatalog( catalog.getId(), scu); - assertThat( catalog.getCategoryRefs().size() ).isEqualTo( 3 ); + assertThat( catalog.getCategoryRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 1 ); assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 2 ); assertThat( catalogRepoService.findAll().size() ).isEqualTo( 1 ); catalogRepoService.deleteById( catalog.getId() );//delete @@ -841,7 +840,7 @@ public class ResourceCatalogIntegrationTest { String physsspectext = IOUtils.toString(in, "UTF-8"); PhysicalResourceSpecificationCreate physspeccr2 = JsonUtils.toJsonObj( physsspectext, PhysicalResourceSpecificationCreate.class); phyresponsesSpec1 = (PhysicalResourceSpecification) createResourceSpec( physspeccr2); - + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 3 ); assertThat( specRepoService.findAllPhysical().size() ).isEqualTo( FIXED_BOOTSTRAPS_PHYSICAL_SPECS + 2 ); -- GitLab From 2acb76ce7e88dd843b15192cbe536c422e2f81bb Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 18 Dec 2023 15:04:16 +0200 Subject: [PATCH 5/7] fixed testSpecAttribute test in ServiceCatalogIntegrationTest --- .../osl/services/api/ServiceCatalogIntegrationTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 415b9c9..0b9fda8 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -522,9 +522,9 @@ public class ServiceCatalogIntegrationTest { val.setValueType( EValueType.ARRAY.toString()); val.setValue( new Any("1" ,"a second value") ); responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharacteristicValue().add(val); - ServiceSpecCharRelationship scrObj = responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().toArray( new ServiceSpecCharRelationship[0])[0]; - ServiceSpecCharRelationship scrObj2 = responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().toArray( new ServiceSpecCharRelationship[0])[1]; - ServiceSpecCharRelationship scrObj3 = responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().toArray( new ServiceSpecCharRelationship[0])[2]; + ServiceSpecCharRelationship scrObj = responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().toArray( new ServiceSpecCharRelationship[3])[0]; + ServiceSpecCharRelationship scrObj2 = responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().toArray( new ServiceSpecCharRelationship[3])[1]; + ServiceSpecCharRelationship scrObj3 = responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().toArray( new ServiceSpecCharRelationship[3])[2]; scrObj3.setName("FORTESTING"); String preid = scrObj3.getId(); responsesSpecUpd.getServiceSpecCharacteristic().get(0).getServiceSpecCharRelationship().remove(scrObj); @@ -795,7 +795,7 @@ public class ServiceCatalogIntegrationTest { assertThat( clonedSpec.findSpecCharacteristicByName("Coverage") ).isNotNull(); assertThat( clonedSpec.findSpecCharacteristicByName("Coverage").getUuid() ).isNotNull(); assertThat( clonedSpec.findSpecCharacteristicByName("Coverage").getUuid() ).isNotEqualTo( responsesSpec3.findSpecCharacteristicByName("Coverage").getUuid() ); - + assertThat(clonedSpec.getServiceSpecCharacteristic().size()).isEqualTo(responsesSpec3.getServiceSpecCharacteristic().size()); assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 4 ); -- GitLab From 4467abb83c00829338e356a10703ef0ca1fa3f8b Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Tue, 19 Dec 2023 11:07:57 +0200 Subject: [PATCH 6/7] typo ri6398 -> ri639 --- .../etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java b/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java index 15a45d9..55db128 100644 --- a/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java @@ -416,7 +416,7 @@ public class ResourceRepoService { if (resourceCharacteristicChanged) { Note n = new Note(); n.setText("Resource characteristics changed : " + charsChanged); - n.setAuthor( "RI6398-API" ); + n.setAuthor( "RI639-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); resource.addNoteItem( n ); @@ -425,7 +425,7 @@ public class ResourceRepoService { if (resourceStateChanged) { Note n = new Note(); n.setText("Resource resourceStateChanged changed to " + resource.getResourceStatus().toString() ); - n.setAuthor( "RI6398-API" ); + n.setAuthor( "RI639-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); resource.addNoteItem( n ); -- GitLab From 54d21043fbb33f43ca01aee68dacb91aedd78e29 Mon Sep 17 00:00:00 2001 From: Kyriakoulis Date: Wed, 20 Dec 2023 12:42:40 +0200 Subject: [PATCH 7/7] Fixed testCloneSpec in ResourceCatalogIntegrationTest --- .../services/api/ServiceCatalogIntegrationTest.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 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 415b9c9..cff253d 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -812,7 +812,7 @@ public class ServiceCatalogIntegrationTest { assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 5 ); - + String responseSpecClonedVINNI = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/cloneVINNI?serviceName=aVINNIService") .contentType(MediaType.APPLICATION_JSON) .param("addServiceTopology", "true") @@ -830,20 +830,19 @@ public class ServiceCatalogIntegrationTest { .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn().getResponse().getContentAsString(); - clonedSpec = JsonUtils.toJsonObj( responseSpecClonedVINNI, ServiceSpecification.class); - assertThat( clonedSpec.getName() ).isEqualTo( "aVINNIService" ); + assertThat( clonedSpec.getName() ).isEqualTo( "aVINNIService" ); assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 16 ); - + /** * the bundle service characteristics must be same with the total of characteristics of each service in the bundle * */ - - assertThat( clonedSpec.getServiceSpecCharacteristic().size() ).isEqualTo( 70 ); - + + assertThat( clonedSpec.getServiceSpecCharacteristic().size() ).isEqualTo( 71 ); + String responseSpecClonedVINNI2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/cloneVINNI?serviceName=aVINNIService") .contentType(MediaType.APPLICATION_JSON) -- GitLab