diff options
author | vasraz <vasyl.razinkov@est.tech> | 2021-05-11 18:05:30 +0100 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-05-15 06:21:37 +0000 |
commit | 1073da9c4dacfc87982eecf1667eb0177540acf6 (patch) | |
tree | 1b2c3edc5f5d3826247e2dfd69919c097233f405 /catalog-be/src/test | |
parent | 2152a9a43767cdd486fd8c93894f66a05083f53c (diff) |
Improve test coverage
Change-Id: I2b02d85d9d395d9092d43bd54e21179aff29df91
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3584
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java | 88 |
1 files changed, 30 insertions, 58 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java index 55c2e8972f..202cf014fd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -76,6 +76,7 @@ import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.exception.ToscaExportException; import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; import org.openecomp.sdc.be.model.Component; @@ -715,6 +716,15 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { componentInstancesAttributes.put("uuid", componentInstanceAttributes); component.setComponentInstancesAttributes(componentInstancesAttributes); + ComponentInstanceProperty cip = new ComponentInstanceProperty(); + cip.setInstanceUniqueId("id"); + + List<ComponentInstanceProperty> list = new ArrayList<>(); + list.add(cip); + + componentInstancesProperties.put("id", list); + component.setComponentInstancesProperties(componentInstancesProperties); + when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component)); when(capabilityRequirementConverter .convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class))) @@ -769,7 +779,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { final ComponentInstance instance = new ComponentInstance(); instance.setUniqueId("id"); instance.setComponentUid("uid"); - instance.setOriginType(OriginTypeEnum.ServiceProxy); + instance.setOriginType(OriginTypeEnum.VFC); final List<GroupInstance> groupInstances = new ArrayList<>(); final GroupInstance groupInst = new GroupInstance(); final List<String> artifacts = new ArrayList<>(); @@ -782,6 +792,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { final List<PropertyDefinition> properties = new ArrayList<>(); properties.add(new PropertyDefinition()); instance.setProperties(properties); + component.setProperties(properties); instance.setUniqueId("uuid"); instance.setDescription("desc"); @@ -826,6 +837,18 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { component.setArtifacts(artifactList); component.setToscaArtifacts(artifactList); + final List<AttributeDefinition> attributes = new ArrayList<>(); + final var attribute = new AttributeDefinition(); + attribute.setName("mock"); + attributes.add(attribute); + component.setAttributes(attributes); + + List<ComponentInstanceInput> componentInstanceInputs = new ArrayList<>(); + componentInstanceInputs.add(new ComponentInstanceInput()); + + componentInstancesInputs.put("id", componentInstanceInputs); + component.setComponentInstancesInputs(componentInstancesInputs); + when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component)); when(capabilityRequirementConverter .convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class))) @@ -935,6 +958,12 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { component.setUUID("uuid"); component.setDescription("desc"); + final List<AttributeDefinition> attributes = new ArrayList<>(); + final var attribute = new AttributeDefinition(); + attribute.setName("mock"); + attributes.add(attribute); + component.setAttributes(attributes); + componentCache.put("uid", component); when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false)); @@ -1006,63 +1035,6 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { } @Test - public void testAddComponentInstanceInputs() throws Exception { - - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>(); - ComponentInstance componentInstance = new ComponentInstance(); - String instanceUniqueId = "id"; - Map<String, Object> props = new HashMap<>(); - - List<ComponentInstanceInput> componentInstanceInputs = new ArrayList<>(); - componentInstanceInputs.add(new ComponentInstanceInput()); - - componentInstancesInputs.put(instanceUniqueId, componentInstanceInputs); - - // default test - Deencapsulation.invoke(testSubject, "addComponentInstanceInputs", dataTypes, componentInstancesInputs, - instanceUniqueId, props); - } - - @Test - public void testAddPropertiesOfComponentInstance() throws Exception { - Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>(); - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - ComponentInstance componentInstance = new ComponentInstance(); - String instanceUniqueId = "id"; - Map<String, Object> props = new HashMap<>(); - - ComponentInstanceProperty cip = new ComponentInstanceProperty(); - cip.setInstanceUniqueId("id"); - - List<ComponentInstanceProperty> list = new ArrayList<>(); - list.add(cip); - - componentInstancesProperties.put("id", list); - - // default test - Deencapsulation.invoke(testSubject, "addPropertiesOfComponentInstance", componentInstancesProperties, dataTypes, - instanceUniqueId, props); - } - - @Test - public void testAddPropertiesOfParentComponent() throws Exception { - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - ComponentInstance componentInstance = new ComponentInstance(); - Component componentOfInstance = new Resource(); - Map<String, Object> props = new HashMap<>(); - - List<PropertyDefinition> properties = new ArrayList<>(); - properties.add(new PropertyDefinition()); - - ((Resource) componentOfInstance).setProperties(properties); - - // default test - Deencapsulation.invoke(testSubject, "addPropertiesOfParentComponent", dataTypes, - componentOfInstance, props); - } - - @Test public void testCreateNodeType() throws Exception { Component component = new Resource(); |