Enhanced Service decomposition to handle gruop 98/86398/9
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>
Fri, 26 Apr 2019 11:38:40 +0000 (17:08 +0530)
committersubhash kumar singh <subhash.kumar.singh@huawei.com>
Sat, 27 Apr 2019 07:21:43 +0000 (12:51 +0530)
Enhanced Service decomposition to handle gruop and vnfcs

Issue-ID: SO-1393
Change-Id: If28416e4776f2ff645abdd0d1059d28c9ca6e52f
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java [new file with mode: 0644]
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java [new file with mode: 0644]
bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java
bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json [new file with mode: 0644]

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 (file)
index 0000000..d194f27
--- /dev/null
@@ -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<VnfcResource> vnfcs;
+
+    public GroupResource() {
+        resourceType = ResourceType.GROUP;
+        setResourceId(UUID.randomUUID().toString());
+    }
+
+    public List<VnfcResource> getVnfcs() {
+        return vnfcs;
+    }
+
+    public void setVnfcs(List<VnfcResource> vnfcs) {
+        this.vnfcs = vnfcs;
+    }
+}
index a30d0df..0e17d4c 100644 (file)
@@ -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.
 }
index a69a49b..0804cbb 100644 (file)
@@ -51,6 +51,10 @@ public class VnfResource extends Resource {
      */
     @JsonProperty("vfModules")
     private List<ModuleResource> vfModules;
+
+    @JsonProperty("groups")
+    private List<GroupResource> groups;
+
     private String vnfHostname;
     private String vnfType;
     private String nfFunction;
@@ -151,6 +155,14 @@ public class VnfResource extends Resource {
         this.resourceInput = resourceInput;
     }
 
+    public List<GroupResource> getGroups() {
+        return groups;
+    }
+
+    public void setGroups(List<GroupResource> 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 (file)
index 0000000..5fced9a
--- /dev/null
@@ -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());
+    }
+}
index 5db2776..7ef7dee 100644 (file)
@@ -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
index b23633b..de7b21e 100644 (file)
  */
 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 (file)
index 0000000..9d0326e
--- /dev/null
@@ -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