diff options
author | MichaelMorris <michael.morris@est.tech> | 2021-02-05 16:18:52 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-02-21 07:55:36 +0000 |
commit | 8cc03e2c78639be5500ab50f3ebaaf7d64404775 (patch) | |
tree | 1c4d82ba477c4de058f8817b717deaa2f3f4e877 /catalog-be/src/test/java | |
parent | 751ac4b93e575c56e29cdbbcf95e0aa899d914a2 (diff) |
Update node and data types for SOL001 3.3.1 + CNF enhancements
Types in 2.7.1 folder are types valid for v3.3.1 that have not changed from v2.7.1
Types in 4.1.1 folder are the CNF enhancements which it is assumed will be in v4.1.1
Includes some changes in functionality to support:
1. Deployment of both existing (2.5.1) versions of types and new versions of types through sdc-BE-init
2. Selection of the correct node type definition version at onboarding of an ETSI SOL004 VNF/CNF csar,
based on the declared version supported in the csar (i.e. when a 3.3.1 csar is imported, the node type
definitions valid for 3.3.1 are used (rather than current logic which always selects the latest version)
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3470
Change-Id: Iff835d230b173b9d44349caa6b0b11d783e8f8d3
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index 18dc67f752..622027df30 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import fj.data.Either; import java.io.IOException; @@ -55,9 +57,13 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction; import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; +import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; @@ -66,6 +72,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.UploadResourceInfo; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation; import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; @@ -102,7 +109,7 @@ public class ResourceImportManagerTest { importManager.setResponseFormatManager(responseFormatManager); importManager.setResourceBusinessLogic(resourceBusinessLogic); importManager.setToscaOperationFacade(toscaOperationFacade); - + String appConfigDir = "src/test/resources/config/catalog-be"; ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); final ConfigurationManager configurationManager = new ConfigurationManager(configurationSource); @@ -115,6 +122,8 @@ public class ResourceImportManagerTest { @Before public void beforeTest() { Mockito.reset(auditingManager, responseFormatManager, resourceBusinessLogic, userAdmin); + Either<Component, StorageOperationStatus> notFound = Either.right(StorageOperationStatus.NOT_FOUND); + when(toscaOperationFacade.getComponentByNameAndVendorRelease(any(ComponentTypeEnum.class), anyString(), anyString(), any(JsonParseFlagEnum.class))).thenReturn(notFound); } @Test @@ -273,10 +282,38 @@ public class ResourceImportManagerTest { interfaceDefinition.setOperations(operations ); interfaceTypes.put("tosca.interfaces.node.lifecycle.standard", interfaceDefinition); when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes)); - + ImmutablePair<Resource, ActionStatus> createResource = importManager.importNormativeResource(jsonContent, resourceMD, user, true, true); assertNull(createResource.left.getInterfaces()); } + + @Test + public void testResourceCreationFailedVendorReleaseAlreadyExists() throws IOException { + UploadResourceInfo resourceMD = createDummyResourceMD(); + + User user = new User(); + user.setUserId(resourceMD.getContactId()); + user.setRole("ADMIN"); + user.setFirstName("Jhon"); + user.setLastName("Doh"); + when(userAdmin.getUser(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(user); + + setResourceBusinessLogicMock(); + + Either<Component, StorageOperationStatus> notFound = Either.left(Mockito.mock(Resource.class)); + when(toscaOperationFacade.getComponentByNameAndVendorRelease(any(ComponentTypeEnum.class), anyString(), anyString(), any(JsonParseFlagEnum.class))).thenReturn(notFound); + + String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-blockStorage.yml"); + + ComponentException errorInfoFromTest = null; + try { + importManager.importNormativeResource(jsonContent, resourceMD, user, true, true); + }catch (ComponentException e){ + errorInfoFromTest = e; + } + assertNotNull(errorInfoFromTest); + assertEquals(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, errorInfoFromTest.getActionStatus()); + } private void setResourceBusinessLogicMock() { when(resourceBusinessLogic.getUserAdmin()).thenReturn(userAdmin); |