diff options
author | 2020-06-23 09:15:48 +0100 | |
---|---|---|
committer | 2020-09-04 14:42:04 +0000 | |
commit | 032525a375681fb18cc498d8daed9d73faa21ec3 (patch) | |
tree | 20cf4c17f406b8d30c29ce904fe1f19ea4a2c989 /catalog-model/src/test/java/org/openecomp | |
parent | c16117e08b97da93da61be841c22f5759cdadd37 (diff) |
Support for Nested/Hierarchical Services
Change-Id: I478cf2e1f9cf96443a3e35bf22ac2c9d72bca8f1
Issue-ID: SDC-3145
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'catalog-model/src/test/java/org/openecomp')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java index caf1805b83..1c730e5718 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java @@ -106,6 +106,7 @@ public class ToscaOperationFacadeTest { private static final String ICON_NAME = "icon"; private static final String SERVICE_MODEL_NAME = "Test_Service"; private static final String SERVICE_PROXY_INSTANCE0_NAME = "testservice_proxy0"; + private static final String SERVICE_SUBSTITUTION_INSTANCE0_NAME = "testservice0"; @InjectMocks private ToscaOperationFacade testInstance; @@ -637,7 +638,7 @@ public class ToscaOperationFacadeTest { } @Test - public void testAddComponentInstanceToTopologyTemplate() { + public void testAddComponentInstanceToTopologyTemplate_ServiceProxy() { Component containerComponent = new Service(); Component originalComponent = new Service(); ComponentInstance componentInstance = new ComponentInstance(); @@ -677,6 +678,45 @@ public class ToscaOperationFacadeTest { verify(nodeTemplateOperationMock, times(1)) .addComponentInstanceToTopologyTemplate(any(), any(), eq("1"), eq(componentInstance), eq(false), eq(user)); } + @Test + public void testAddComponentInstanceToTopologyTemplate_ServiceSubstitution() { + Component containerComponent = new Service(); + Component originalComponent = new Service(); + ComponentInstance componentInstance = new ComponentInstance(); + ComponentInstance existingComponentInstance = new ComponentInstance(); + User user = new User(); + + containerComponent.setComponentType(ComponentTypeEnum.SERVICE); + + originalComponent.setComponentType(ComponentTypeEnum.SERVICE); + originalComponent.setIcon(ICON_NAME); + + componentInstance.setOriginType(OriginTypeEnum.ServiceSubstitution); + componentInstance.setSourceModelName(SERVICE_MODEL_NAME); + + List<ComponentInstance> existingInstances = new ArrayList<>(); + existingComponentInstance.setNormalizedName(SERVICE_SUBSTITUTION_INSTANCE0_NAME); + existingInstances.add(existingComponentInstance); + containerComponent.setComponentInstances(existingInstances); + + when(nodeTemplateOperationMock + .addComponentInstanceToTopologyTemplate(any(), any(), eq("1"), eq(componentInstance), eq(false), eq(user))) + .thenReturn(Either.left(new ImmutablePair<>(new TopologyTemplate(), COMPONENT_ID))); + TopologyTemplate topologyTemplate = new TopologyTemplate(); + topologyTemplate.setMetadataValue(JsonPresentationFields.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); + when(topologyTemplateOperationMock.getToscaElement(containerComponent.getUniqueId())) + .thenReturn(Either.left(topologyTemplate)); + + Either<ImmutablePair<Component, String>, StorageOperationStatus> result = + testInstance.addComponentInstanceToTopologyTemplate( + containerComponent, originalComponent, componentInstance, false, user); + + assertTrue(result.isLeft()); + assertEquals(ICON_NAME, componentInstance.getIcon()); + assertEquals(COMPONENT_ID, result.left().value().getRight()); + verify(nodeTemplateOperationMock, times(1)) + .addComponentInstanceToTopologyTemplate(any(), any(), eq("1"), eq(componentInstance), eq(false), eq(user)); + } private Either<PolicyDefinition, StorageOperationStatus> associatePolicyToComponentWithStatus(StorageOperationStatus status) { PolicyDefinition policy = new PolicyDefinition(); |