From e98c9cbc978ceb3bcb4a8f946bfec4cbd7b22511 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 26 Apr 2019 17:08:40 +0530 Subject: Enhanced Service decomposition to handle gruop Enhanced Service decomposition to handle gruop and vnfcs Issue-ID: SO-1393 Change-Id: If28416e4776f2ff645abdd0d1059d28c9ca6e52f Signed-off-by: subhash kumar singh --- .../onap/so/bpmn/core/domain/GroupResource.java | 44 ++++++++++++++++ .../org/onap/so/bpmn/core/domain/ResourceType.java | 2 +- .../org/onap/so/bpmn/core/domain/VnfResource.java | 12 +++++ .../org/onap/so/bpmn/core/domain/VnfcResource.java | 31 ++++++++++++ .../bpmn/core/domain/ServiceDecompositionTest.java | 16 ++++++ .../onap/so/bpmn/core/domain/VnfResourceTest.java | 7 +-- .../json-examples/ServiceWithGroupandVnfc.json | 58 ++++++++++++++++++++++ 7 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json (limited to 'bpmn') diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java new file mode 100644 index 0000000000..d194f2750a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.core.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.UUID; + +public class GroupResource extends Resource { + private static final long serialVersionUID = 1L; + + @JsonProperty("vnfcs") + private List vnfcs; + + public GroupResource() { + resourceType = ResourceType.GROUP; + setResourceId(UUID.randomUUID().toString()); + } + + public List getVnfcs() { + return vnfcs; + } + + public void setVnfcs(List vnfcs) { + this.vnfcs = vnfcs; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java index a30d0df825..0e17d4c826 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java @@ -22,5 +22,5 @@ package org.onap.so.bpmn.core.domain; public enum ResourceType { - VNF, NETWORK, MODULE, ALLOTTED_RESOURCE, CONFIGURATION // etc. + VNF, NETWORK, MODULE, ALLOTTED_RESOURCE, CONFIGURATION, GROUP, VNFC // etc. } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java index a69a49b89a..0804cbb11b 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java @@ -51,6 +51,10 @@ public class VnfResource extends Resource { */ @JsonProperty("vfModules") private List vfModules; + + @JsonProperty("groups") + private List groups; + private String vnfHostname; private String vnfType; private String nfFunction; @@ -151,6 +155,14 @@ public class VnfResource extends Resource { this.resourceInput = resourceInput; } + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + /** * Returns a list of all VfModule objects. Base module is first entry in the list * diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java new file mode 100644 index 0000000000..5fced9a8ab --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.core.domain; + +import java.util.UUID; + +public class VnfcResource extends Resource { + private static final long serialVersionUID = 1L; + + public VnfcResource() { + resourceType = ResourceType.VNFC; + setResourceId(UUID.randomUUID().toString()); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java index 5db277628e..7ef7deea30 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java @@ -52,6 +52,22 @@ public class ServiceDecompositionTest { configResource.setResourceId("configResourceId"); } + + @Test + public void serviceDecompositionWithGroupandVnfc() throws IOException { + String sericeStr = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceWithGroupandVnfc.json"))); + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(sericeStr); + + assertEquals(1, serviceDecomposition.getVnfResources().size()); + assertEquals(1, serviceDecomposition.getVnfResources().get(0).getGroups().size()); + assertEquals(1, serviceDecomposition.getVnfResources().get(0).getGroups().get(0).getVnfcs().size()); + + VnfcResource vnfcResource = serviceDecomposition.getVnfResources().get(0).getGroups().get(0).getVnfcs().get(0); + + assertEquals("xfs", vnfcResource.getModelInfo().getModelName()); + assertEquals("22", vnfcResource.getModelInfo().getModelUuid()); + } + @Test public void serviceDecompositionTest() throws JsonProcessingException, IOException { // covering methods not covered by openpojo test diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java index b23633b4d8..de7b21ed73 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java @@ -14,12 +14,13 @@ */ package org.onap.so.bpmn.core.domain; -import static org.junit.Assert.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class VnfResourceTest { diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json new file mode 100644 index 0000000000..9d0326e66a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json @@ -0,0 +1,58 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "NSService", + "modelUuid": "0bad8c92-7d22-49f0-b092-b64e6ca564a7", + "modelInvariantUuid": "69161960-515b-4bf3-91f1-313b813f5e1d", + "modelVersion": "1.0" + }, + "serviceType": "", + "serviceRole": "", + "environmentContext": "General_Revenue-Bearing", + "resourceOrder": "NF", + "workloadContext": "Production", + "serviceVnfs": [ + { + "modelInfo": { + "modelName": "", + "modelUuid": "123", + "modelInvariantUuid": "", + "modelVersion": "", + "modelCustomizationUuid": "1234", + "modelInstanceName": "test" + }, + "toscaNodeType": "", + "nfFunction": "", + "nfType": "", + "nfRole": "", + "nfNamingCode": "", + "multiStageDesign": "", + "resourceInput": "", + "vfModules": [], + "groups": [ + { + "modelInfo": { + "modelName": "test", + "modelUuid": "11", + "modelInvariantUuid": "11", + "modelVersion": "2" + }, + "vnfcs": [ + { + "modelInfo": { + "modelName": "xfs", + "modelUuid": "22", + "modelInvariantUuid": "2222", + "modelVersion": "22222", + "modelCustomizationUuid": "2222" + } + } + ] + } + ] + } + ], + "serviceNetworks": [], + "serviceAllottedResources": [] + } +} \ No newline at end of file -- cgit 1.2.3-korg