From 5378abb698d527fa2003fced27e67d00f7cb2673 Mon Sep 17 00:00:00 2001 From: "Sindhuri.A" Date: Wed, 31 Oct 2018 14:17:42 +0530 Subject: UT-enhance NodeTemplateOperationTest3 UT for catalog model NodeTemplateOperation class Issue-ID: SDC-1775 Change-Id: Id40b90421b1fb4698a03707b245ccd5ce79721c4 Signed-off-by: Sindhuri.A --- .../operations/NodeTemplateOperationTest.java | 49 +++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java index 49d0f9bf8d..febf1297cc 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java @@ -272,7 +272,7 @@ public class NodeTemplateOperationTest extends ModelTestBase { @Test - public void testPrepareCalculatedCapabiltyForNodeType() throws Exception { + public void testPrepareCalculatedCapabiltyForNodeType() { NodeTemplateOperation testSubject; Map capabilities = new HashMap<>(); ListCapabilityDataDefinition listCapDataDefinition = new ListCapabilityDataDefinition(); @@ -282,11 +282,7 @@ public class NodeTemplateOperationTest extends ModelTestBase { listToscaDataDefinition.add(capabilityDataDefinition); listCapDataDefinition.setListToscaDataDefinition(listToscaDataDefinition); capabilities.put("1", listCapDataDefinition); - ComponentInstanceDataDefinition componentInstance = new ComponentInstance(); - String id = "id"; - componentInstance.setComponentUid(id); - componentInstance.setUniqueId(id); - componentInstance.setName(id); + ComponentInstance componentInstance = createCompInstance(); MapListCapabilityDataDefinition result; // test 1 @@ -295,22 +291,27 @@ public class NodeTemplateOperationTest extends ModelTestBase { Assert.assertEquals(1, result.getMapToscaDataDefinition().size()); } - - @Test - public void testPrepareCalculatedRequirementForNodeType() throws Exception { - NodeTemplateOperation testSubject; - Map requirements = null; - ComponentInstanceDataDefinition componentInstance = null; - MapListRequirementDataDefinition result; - // test 1 - testSubject = createTestSubject(); - requirements = null; - result = testSubject.prepareCalculatedRequirementForNodeType(requirements, componentInstance); - Assert.assertEquals(null, result); - } + @Test + public void testPrepareCalculatedReqForNodeType() { + NodeTemplateOperation testSubject; + Map requirements = new HashMap<>(); + ListRequirementDataDefinition listReqDataDef = new ListRequirementDataDefinition(); + List listToscaDataDefinition = new ArrayList<>(); + RequirementDataDefinition reqDataDefinition = new RequirementDataDefinition(); + reqDataDefinition.setMaxOccurrences("1"); + listToscaDataDefinition.add(reqDataDefinition); + listReqDataDef.setListToscaDataDefinition(listToscaDataDefinition); + requirements.put("1", listReqDataDef); + ComponentInstance componentInstance = createCompInstance(); + MapListRequirementDataDefinition result; + + // test 1 + testSubject = createTestSubject(); + result = testSubject.prepareCalculatedRequirementForNodeType(requirements, componentInstance); + Assert.assertEquals(1, result.getMapToscaDataDefinition().size()); + } - @Test public void testAddGroupInstancesToComponentInstance() throws Exception { NodeTemplateOperation testSubject; @@ -343,4 +344,12 @@ public class NodeTemplateOperationTest extends ModelTestBase { Assert.assertEquals(StorageOperationStatus.OK, result); } + private ComponentInstance createCompInstance() { + ComponentInstance componentInstance = new ComponentInstance(); + String id = "id"; + componentInstance.setComponentUid(id); + componentInstance.setUniqueId(id); + componentInstance.setName(id); + return componentInstance; + } } -- cgit 1.2.3-korg