diff options
author | Sindhuri.A <arcot.sindhuri@huawei.com> | 2018-10-31 14:17:42 +0530 |
---|---|---|
committer | Tal Gitelman <tal.gitelman@att.com> | 2018-11-01 10:24:22 +0000 |
commit | 5378abb698d527fa2003fced27e67d00f7cb2673 (patch) | |
tree | 8561b8c37787c56c5d0ca945aa09aee2cb4894bd /catalog-model/src/test/java | |
parent | ae3a86d73ed732c0d3a3c46e98445c40a79582c0 (diff) |
UT-enhance NodeTemplateOperationTest3
UT for catalog model NodeTemplateOperation class
Issue-ID: SDC-1775
Change-Id: Id40b90421b1fb4698a03707b245ccd5ce79721c4
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-model/src/test/java')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java | 49 |
1 files 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<String, ListCapabilityDataDefinition> 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<String, ListRequirementDataDefinition> 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<String, ListRequirementDataDefinition> requirements = new HashMap<>(); + ListRequirementDataDefinition listReqDataDef = new ListRequirementDataDefinition(); + List<RequirementDataDefinition> 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; + } } |