aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorr.bogacki <r.bogacki@samsung.com>2019-03-26 11:48:13 +0100
committerRobert Bogacki <r.bogacki@samsung.com>2019-03-27 12:32:17 +0000
commitc8dc961a21b7a30ae91d53948a93be3551cae9a9 (patch)
tree3ab7e595aba6610f9dc94b3c9655592a85f9a0da
parentd3f349b01202b3cbd7219d1232949979e9e3fca5 (diff)
JUnit tests for VnfResource
Increased junit tests coverage according to Sonar analyses. Change-Id: I3fd923d5342b08e2f21ff5988c85f2abe46b76f5 Issue-ID: SO-1692 Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java36
1 files changed, 35 insertions, 1 deletions
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 a83337fc5b..5271bb3c53 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
@@ -22,13 +22,17 @@ package org.onap.so.bpmn.core.domain;
import static org.junit.Assert.*;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
public class VnfResourceTest {
-
+
+ private final static String ALL_VF_MODULES_JSON =
+ "{\"ArrayList\":[{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0},{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0}]}";
+
private VnfResource vnf= new VnfResource();
List<ModuleResource> moduleResources;
@@ -63,4 +67,34 @@ public class VnfResourceTest {
assertTrue(vnfResource != null);
}
+ @Test
+ public void testVfModules() {
+
+ moduleResources = new ArrayList<>();
+
+ ModuleResource moduleresource = new ModuleResource();
+ moduleresource.setVfModuleName("vfModuleName");
+ moduleresource.setHeatStackId("heatStackId");
+ moduleresource.setIsBase(true);
+ moduleresource.setVfModuleLabel("vfModuleLabel");
+ moduleresource.setInitialCount(0);
+ moduleresource.setVfModuleType("vfModuleType");
+ moduleresource.setHasVolumeGroup(true);
+
+ moduleResources.add(moduleresource);
+
+ vnf.setModules(moduleResources);
+ assertEquals(vnf.getVfModules(), moduleResources);
+
+ List<ModuleResource> moduleResources = vnf.getAllVfModuleObjects();
+ assertEquals(1, moduleResources.size());
+
+ vnf.addVfModule(moduleresource);
+ moduleResources = vnf.getAllVfModuleObjects();
+ assertEquals(2, moduleResources.size());
+
+ assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson());
+
+ }
+
}