From c8dc961a21b7a30ae91d53948a93be3551cae9a9 Mon Sep 17 00:00:00 2001 From: "r.bogacki" Date: Tue, 26 Mar 2019 11:48:13 +0100 Subject: JUnit tests for VnfResource Increased junit tests coverage according to Sonar analyses. Change-Id: I3fd923d5342b08e2f21ff5988c85f2abe46b76f5 Issue-ID: SO-1692 Signed-off-by: Robert Bogacki --- .../onap/so/bpmn/core/domain/VnfResourceTest.java | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'bpmn/MSOCoreBPMN/src/test/java') 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 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 moduleResources = vnf.getAllVfModuleObjects(); + assertEquals(1, moduleResources.size()); + + vnf.addVfModule(moduleresource); + moduleResources = vnf.getAllVfModuleObjects(); + assertEquals(2, moduleResources.size()); + + assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson()); + + } + } -- cgit 1.2.3-korg