aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java1890
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java1078
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportManagerTest.java95
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java2152
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/CreateServiceFromYamlParameterTest.java51
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java219
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractResourceInfoTest.java41
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractTemplateInfoTest.java40
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/CopyServiceInfoTest.java42
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ReplaceVNFInfoTest.java41
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceUploadServletTest.java25
-rw-r--r--catalog-be/src/test/resources/normativeTypes/service_import_template.yml334
14 files changed, 6017 insertions, 3 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
new file mode 100644
index 0000000000..02e145ec65
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -0,0 +1,1890 @@
+/*
+
+ * Copyright (c) 2018 AT&T Intellectual Property.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
+
+package org.openecomp.sdc.be.components.impl;
+
+
+import fj.data.Either;
+import io.cucumber.java.hu.Ha;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
+import org.openecomp.sdc.be.components.csar.CsarInfo;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.externalapi.servlet.ArtifactExternalServlet;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
+import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
+import org.openecomp.sdc.be.tosca.CsarUtils;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
+ private final static String DEFAULT_ICON = "defaulticon";
+
+ @InjectMocks
+ static ServiceImportBusinessLogic serviceImportBusinessLogic;
+ @Mock
+ private ServiceBusinessLogic serviceBusinessLogic;
+ @Mock
+ private CsarBusinessLogic csarBusinessLogic;
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+ @Mock
+ private ServiceImportParseLogic serviceImportParseLogic;
+ @Mock
+ ArtifactDefinition artifactDefinition =new ArtifactDefinition();
+
+ private static UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
+ private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ private static ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+ private static ServletUtils servletUtils = mock(ServletUtils.class);
+ private static ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
+ private static ArtifactsBusinessLogic artifactsBusinessLogic = mock(ArtifactsBusinessLogic.class);
+
+ private static AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic,
+ componentInstanceBusinessLogic, componentsUtils, servletUtils, resourceImportManager, artifactsBusinessLogic);
+
+ @Before
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ when(artifactDefinition.getMandatory()).thenReturn(true);
+ when(artifactDefinition.getArtifactName()).thenReturn("creatorFullName");
+ when(artifactDefinition.getArtifactType()).thenReturn("TOSCA_CSAR");
+
+ sIB1.setServiceBusinessLogic(serviceBusinessLogic);
+ sIB1.setCsarBusinessLogic(csarBusinessLogic);
+ sIB1.setServiceImportParseLogic(serviceImportParseLogic);
+ sIB1.setToscaOperationFacade(toscaOperationFacade);
+
+ }
+
+ @Test
+ public void testGetComponentsUtils() {
+ ComponentsUtils result;
+ result = serviceImportBusinessLogic.getComponentsUtils();
+ }
+
+ @Test
+ public void testSetComponentsUtils() {
+ ComponentsUtils componentsUtils = null;
+
+ serviceImportBusinessLogic.setComponentsUtils(componentsUtils);
+ }
+
+ @Test
+ public void testCreateService() {
+ Service oldService = createServiceObject(false);
+ String payloadName = "valid_vf";
+ Map<String, byte[]> payload = crateCsarFromPayload();
+ Service newService = createServiceObject(true);
+ try {
+ when(serviceBusinessLogic.validateServiceBeforeCreate(newService,user,AuditingActionEnum.CREATE_RESOURCE))
+ .thenReturn(Either.left(newService));
+ when(toscaOperationFacade.validateCsarUuidUniqueness(payloadName)).thenReturn(StorageOperationStatus.OK);
+ sIB1.createService(oldService, AuditingActionEnum.CREATE_RESOURCE, user, payload, payloadName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateServiceFromCsar(){
+ Service oldService = createServiceObject(false);
+ String csarUUID = "valid_vf";
+ Map<String, byte[]> payload = crateCsarFromPayload();
+ try {
+ sIB1.createServiceFromCsar(oldService, user, payload, csarUUID);
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateServiceFromYaml(){
+ Service oldService = createServiceObject(false);
+ String topologyTemplateYaml = getMainTemplateContent("service_import_template.yml");;
+ String yamlName = "group.yml";
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashedMap();
+ CsarInfo csarInfo =getCsarInfo();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ try {
+ sIB1.createServiceFromYaml(oldService,topologyTemplateYaml,yamlName,nodeTypesInfo,
+ csarInfo,nodeTypesArtifactsToCreate,true,true,nodeName);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateServiceAndRIsFromYaml(){
+ Service oldService = createServiceObject(false);
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
+ CreateServiceFromYamlParameter csfyp = getCsfyp();
+ try {
+ sIB1.createServiceAndRIsFromYaml(oldService,false,nodeTypesArtifactsToCreate,true,true,csfyp);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateOrUpdateArtifacts(){
+ ArtifactsBusinessLogic.ArtifactOperationEnum operation = ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE;
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ String yamlFileName = "group.yml";
+ CsarInfo csarInfo =getCsarInfo();
+ Resource preparedResource = createParseResourceObject(false);
+ preparedResource.setResourceType(ResourceTypeEnum.VF);
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle= new HashMap<>();
+ EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap =
+ new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
+ List<ArtifactDefinition> artifactDefinitions = new ArrayList<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactName");
+ artifactDefinitions.add(artifactDefinition);
+ enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE,
+ artifactDefinitions);
+ nodeTypesArtifactsToHandle.put(nodeName,enumListEnumMap);
+ NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName,nodeTypesArtifactsToHandle);
+ nodeTypeInfoToUpdateArtifacts.setNodeName(nodeName);
+ nodeTypeInfoToUpdateArtifacts.setNodeTypesArtifactsToHandle(nodeTypesArtifactsToHandle);
+
+ try {
+ sIB1.createOrUpdateArtifacts(operation,createdArtifacts,yamlFileName,csarInfo,
+ preparedResource,nodeTypeInfoToUpdateArtifacts,true,true);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleVfCsarArtifacts(){
+ Resource resource = createParseResourceObject(false);
+ CsarInfo csarInfo = getCsarInfo();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
+ try {
+ sIB1.handleVfCsarArtifacts(resource,csarInfo,createdArtifacts,artifactOperation,true,true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateOrUpdateSingleNonMetaArtifactToComstants(){
+ Resource resource = createParseResourceObject(false);
+ CsarInfo csarInfo = getCsarInfo();
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactDefinition");
+ deploymentArtifacts.put("deploymentArtifacts",artifactDefinition);
+ resource.setDeploymentArtifacts(deploymentArtifacts);
+ try {
+ sIB1.createOrUpdateSingleNonMetaArtifactToComstants(resource,csarInfo,artifactOperation,true,true);
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @Test
+ public void testCreateOrUpdateNonMetaArtifacts(){
+ CsarInfo csarInfo = getCsarInfo();
+ Resource resource = createParseResourceObject(false);
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
+
+ Either<Resource, ResponseFormat> result = sIB1.createOrUpdateNonMetaArtifacts(csarInfo, resource,
+ createdArtifacts, true, true, artifactOperation);
+ assertEquals(result.left().value(),resource);
+ }
+
+ @Test
+ public void testFindVfCsarArtifactsToHandle(){
+ Resource resource = createParseResourceObject(false);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactDefinition");
+ deploymentArtifacts.put("deploymentArtifacts",artifactDefinition);
+ Map<String, ArtifactDefinition> artifacts = new HashMap<>();
+ artifacts.put("artifacts",artifactDefinition);
+ List<GroupDefinition> groups = new ArrayList<>();
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groupDefinition.setUniqueId("groupDefinitionUniqueId");
+ groupDefinition.setName("groupDefinition");
+ groups.add(groupDefinition);
+ resource.setDeploymentArtifacts(deploymentArtifacts);
+ resource.setArtifacts(artifacts);
+ resource.setGroups(groups);
+ List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
+
+ Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>,
+ ResponseFormat> result = sIB1.findVfCsarArtifactsToHandle(resource,artifactPathAndNameList,user);
+ assertNotNull(result.left().value());
+ }
+
+
+ @Test
+ public void testIsNonMetaArtifact() {
+ ArtifactDefinition artifactDefinition =new ArtifactDefinition();
+ artifactDefinition.setMandatory(false);
+ artifactDefinition.setArtifactName("creatorFullName");
+ artifactDefinition.setArtifactType("TOSCA_CSAR");
+
+ boolean nonMetaArtifact = sIB1.isNonMetaArtifact(artifactDefinition);
+ assertTrue(nonMetaArtifact);
+
+ }
+
+ @Test
+ public void testOrganizeVfCsarArtifactsByArtifactOperation(){
+ List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
+ artifactPathAndNameList.add(getNonMetaArtifactInfo());
+ List<ArtifactDefinition> existingArtifactsToHandle = new ArrayList<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactName");
+ artifactDefinition.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL.name());
+ artifactDefinition.setArtifactChecksum("artifactChecksum");
+ existingArtifactsToHandle.add(artifactDefinition);
+ Resource resource = createParseResourceObject(false);
+
+ Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat>
+ enumMapResponseFormatEither = sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, resource, user);
+ assertNotNull(enumMapResponseFormatEither.left().value());
+ }
+
+ @Test
+ public void testProcessCsarArtifacts(){
+ CsarInfo csarInfo = getCsarInfo();
+ Resource resource = createParseResourceObject(false);
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Either<Resource, ResponseFormat> resStatus = null;
+ List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
+ artifactPathAndNameList.add(getNonMetaArtifactInfo());
+ EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle = new
+ EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
+ vfCsarArtifactsToHandle.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE,artifactPathAndNameList);
+ Either<Resource, ResponseFormat> rrfe = sIB1.processCsarArtifacts(csarInfo,
+ resource, createdArtifacts, true, true, resStatus, vfCsarArtifactsToHandle);
+ assertNull(rrfe);
+ }
+
+ @Test
+ public void testCreateOrUpdateSingleNonMetaArtifact(){
+ Resource resource = createParseResourceObject(false);
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, byte[]> csar = csarInfo.getCsar();
+ String rootPath = System.getProperty("user.dir");
+ Path path;
+ byte[] data = new byte[0];
+ path = Paths.get(rootPath + "/src/test/resources/valid_vf.csar");
+ try {
+ data = Files.readAllBytes(path);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ csar.put("valid_vf.csar",data);
+ String artifactPath = "valid_vf.csar", artifactFileName = "", artifactType = "";
+ ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.TOSCA;
+ String artifactLabel = "", artifactDisplayName = "", artifactDescription = "", artifactId = "artifactId";
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ try {
+ sIB1.createOrUpdateSingleNonMetaArtifact(resource, csarInfo, artifactPath, artifactFileName, artifactType, artifactGroupType,
+ artifactLabel, artifactDisplayName, artifactDescription, artifactId, artifactOperation, createdArtifacts,
+ true, true, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleNodeTypeArtifacts(){
+ Resource nodeTypeResource = createParseResourceObject(false);
+ ResourceMetadataDataDefinition componentMetadataDataDefinition = new ResourceMetadataDataDefinition();
+ componentMetadataDataDefinition.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
+ ComponentMetadataDefinition componentMetadataDefinition = new ComponentMetadataDefinition(componentMetadataDataDefinition);
+ nodeTypeResource.setComponentMetadataDefinition(componentMetadataDefinition);
+ Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> artifactDefinitions = new ArrayList<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactName");
+ artifactDefinitions.add(artifactDefinition);
+ nodeTypeArtifactsToHandle.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE,
+ artifactDefinitions);
+
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ try {
+ sIB1.handleNodeTypeArtifacts(nodeTypeResource, nodeTypeArtifactsToHandle,
+ createdArtifacts, user, true, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @Test
+ public void testCreateOrUpdateServiceArtifacts(){
+ ArtifactsBusinessLogic.ArtifactOperationEnum operation = ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE;
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ String yamlFileName = "group.yml";
+ CsarInfo csarInfo =getCsarInfo();
+ Service preparedService = createServiceObject(false);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactDefinition");
+ deploymentArtifacts.put("deploymentArtifacts",artifactDefinition);
+ preparedService.setDeploymentArtifacts(deploymentArtifacts);
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle= new HashMap<>();
+ NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName,nodeTypesArtifactsToHandle);
+
+ try {
+ sIB1.createOrUpdateArtifacts(operation,createdArtifacts,yamlFileName,csarInfo,
+ preparedService,nodeTypeInfoToUpdateArtifacts,true,true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleVfCsarServiceArtifacts(){
+ Service service = createServiceObject(true);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName(Constants.VENDOR_LICENSE_MODEL);
+ artifactDefinition.setUniqueId("uniqueId");
+ deploymentArtifacts.put("deploymentArtifacts",artifactDefinition);
+ service.setDeploymentArtifacts(deploymentArtifacts);
+ CsarInfo csarInfo = getCsarInfo();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE);
+ try {
+ sIB1.handleVfCsarArtifacts(service,csarInfo,createdArtifacts,artifactOperation,true,true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateOrUpdateNonMetaServiceArtifacts(){
+ CsarInfo csarInfo = getCsarInfo();
+ Service service = createServiceObject(true);
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE);
+
+ Either<Service, ResponseFormat> result = sIB1.createOrUpdateNonMetaArtifacts(csarInfo,
+ service, createdArtifacts, true, true, artifactOperation);
+ assertEquals(result.left().value(),service);
+ }
+
+ @Test
+ public void testFindServiceCsarArtifactsToHandle(){
+ Service service = createServiceObject(true);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactDefinition");
+ deploymentArtifacts.put("deploymentArtifacts",artifactDefinition);
+ Map<String, ArtifactDefinition> artifacts = new HashMap<>();
+ artifacts.put("artifacts",artifactDefinition);
+ List<GroupDefinition> groups = new ArrayList<>();
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groupDefinition.setUniqueId("groupDefinitionUniqueId");
+ groupDefinition.setName("groupDefinition");
+ groups.add(groupDefinition);
+ service.setDeploymentArtifacts(deploymentArtifacts);
+ service.setArtifacts(artifacts);
+ service.setGroups(groups);
+ List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
+
+ Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>,
+ ResponseFormat> result = sIB1.findVfCsarArtifactsToHandle(service, artifactPathAndNameList, user);
+ assertNotNull(result.left().value());
+ }
+
+ @Test
+ public void testOrganizeVfCsarArtifactsByServiceArtifactOperation(){
+ List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
+ artifactPathAndNameList.add(getNonMetaArtifactInfo());
+ List<ArtifactDefinition> existingArtifactsToHandle = new ArrayList<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactName");
+ artifactDefinition.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL.name());
+ artifactDefinition.setArtifactChecksum("artifactChecksum");
+ existingArtifactsToHandle.add(artifactDefinition);
+ Service service = createServiceObject(true);
+
+ Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat>
+ enumMapResponseFormatEither = sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList,
+ existingArtifactsToHandle, service, user);
+ assertNotNull(enumMapResponseFormatEither.left().value());
+ }
+
+ @Test
+ public void testProcessServiceCsarArtifacts(){
+ CsarInfo csarInfo = getCsarInfo();
+ Service service = createServiceObject(true);
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Either<Service, ResponseFormat> resStatus = null;
+ EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle = new
+ EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
+ Either<Service, ResponseFormat> srfe = sIB1.processCsarArtifacts(csarInfo,
+ service, createdArtifacts, true, true, resStatus, vfCsarArtifactsToHandle);
+ assertNull(srfe);
+ }
+
+ @Test
+ public void testGetValidArtifactNames(){
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
+ Either<List<CsarUtils.NonMetaArtifactInfo>, String> result = sIB1.getValidArtifactNames(csarInfo, collectedWarningMessages);
+ System.out.println(result.left().value());
+ assertNotNull(result.left().value());
+ }
+
+ @Test
+ public void testCreateOrUpdateSingleNonMetaServiceArtifact(){
+ Service service = createServiceObject(true);
+ CsarInfo csarInfo = getCsarInfo();
+ String rootPath = System.getProperty("user.dir");
+ Path path = Paths.get(rootPath + "/src/test/resources/valid_vf.csar");
+ String artifactPath = path.toString(), artifactFileName = "", artifactType = "";
+ ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.TOSCA;
+ String artifactLabel = "", artifactDisplayName = "", artifactDescription = "", artifactId = "artifactId";
+ ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true,true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ try {
+ sIB1.createOrUpdateSingleNonMetaArtifact(service, csarInfo, artifactPath, artifactFileName, artifactType, artifactGroupType,
+ artifactLabel, artifactDisplayName, artifactDescription, artifactId, artifactOperation, createdArtifacts,
+ true, true, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateGroupsOnResource(){
+ Service service = createServiceObject(true);
+ Map<String, GroupDefinition> groups = getGroups();
+
+ try {
+ Either<Service, ResponseFormat> result = sIB1.createGroupsOnResource(service, groups);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUpdateGroupsMembersUsingResource(){
+ Service service = createServiceObject(true);
+ Map<String, GroupDefinition> groups = null;
+
+ List<GroupDefinition> groupDefinitions = sIB1.updateGroupsMembersUsingResource(groups, service);
+ for (GroupDefinition groupDefinition : groupDefinitions) {
+ assertNull(groupDefinition);
+ }
+ }
+
+ @Test
+ public void testCreateRIAndRelationsFromResourceYaml(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(true);
+ Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = new HashMap<>();
+ String topologyTemplateYaml = getMainTemplateContent();
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+
+ try {
+ sIB1.createRIAndRelationsFromYaml(yamlName,resource,uploadComponentInstanceInfoMap,topologyTemplateYaml,nodeTypesNewCreatedArtifacts,
+ nodeTypesInfo,csarInfo,nodeTypesArtifactsToCreate,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @Test
+ public void testCreateResourceInstancesRelations(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(true);
+ resource.setComponentInstances(creatComponentInstances());
+ resource.setResourceType(ResourceTypeEnum.VF);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ uploadResInstancesMap.put("uploadResInstancesMap",getuploadComponentInstanceInfo());
+
+ try {
+ sIB1.createResourceInstancesRelations(user,yamlName,resource,uploadResInstancesMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testProcessComponentInstance1(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(true);
+ Resource originResource = createParseResourceObject(false);
+ List<ComponentInstance> componentInstancesList = creatComponentInstances();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null;
+ Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
+ Map<String, List< AttributeDataDefinition >> instAttributes = new HashMap<>();
+ Map<String, Resource> originCompMap = new HashMap<>();
+ originCompMap.put("componentUid",originResource);
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
+
+ try {
+ sIB1.processComponentInstance(yamlName, resource, componentInstancesList,allDataTypes,instProperties,instCapabilties,instRequirements,
+ instDeploymentArtifacts,instArtifacts,instAttributes,originCompMap,instInputs,uploadComponentInstanceInfo);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddInputsValuesToRi(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ Map<String, List<UploadPropInfo>> properties = new HashMap<>();
+ List<UploadPropInfo> uploadPropInfoList = new ArrayList<>();
+ UploadPropInfo uploadPropInfo = new UploadPropInfo();
+ uploadPropInfo.setName("uploadPropInfo");
+ uploadPropInfoList.add(uploadPropInfo);
+ uploadPropInfoList.add(uploadPropInfo);
+ properties.put("propertiesMap",uploadPropInfoList);
+ uploadComponentInstanceInfo.setProperties(properties);
+ Resource resource = createParseResourceObject(true);
+ Resource originResource =createParseResourceObject(false);
+ List<InputDefinition> inputs = new ArrayList<>();
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setUniqueId("uniqueId");
+ inputs.add(inputDefinition);
+ originResource.setInputs(inputs);
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+
+ try {
+ sIB1.addInputsValuesToRi(uploadComponentInstanceInfo,resource,originResource,
+ currentCompInstance,instInputs,allDataTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testProcessProperty(){
+ Resource resource = createParseResourceObject(true);
+ List<InputDefinition> inputs = new ArrayList<>();
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setUniqueId("uniqueId");
+ inputs.add(inputDefinition);
+ resource.setInputs(inputs);
+ ComponentInstance currentCompInstance = null;
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+ Map<String, InputDefinition> currPropertiesMap = new HashMap<>();
+ inputDefinition.setType("inputDefinitionType");
+ currPropertiesMap.put("propertyInfoName",inputDefinition);
+ List<ComponentInstanceInput> instPropList = new ArrayList<>();
+ List<UploadPropInfo> propertyList = getPropertyList();
+
+ try {
+ sIB1.processProperty(resource, currentCompInstance, allDataTypes,
+ currPropertiesMap, instPropList, propertyList);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleSubstitutionMappings(){
+ Resource resource = createParseResourceObject(true);
+ resource.setResourceType(ResourceTypeEnum.VF);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+
+ try {
+ sIB1.handleSubstitutionMappings(resource, uploadResInstancesMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateResourceInstances(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(true);
+ Resource originResource = createParseResourceObject(false);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ UploadComponentInstanceInfo nodesInfoValue = new UploadComponentInstanceInfo();
+ nodesInfoValue.setName("zxjTestImportServiceAb");
+ nodesInfoValue.setRequirements(gerRequirements());
+ uploadResInstancesMap.put("uploadComponentInstanceInfo", nodesInfoValue);
+ Map<String, Resource> nodeNamespaceMap = new HashMap<>();
+ nodeNamespaceMap.put("resources",originResource);
+
+ try {
+ sIB1.createResourceInstances(yamlName,resource,uploadResInstancesMap,nodeNamespaceMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleNodeTypes(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(true);
+ String topologyTemplateYaml = getMainTemplateContent();
+ boolean needLock = true;
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ nodeTypeInfo.setNested(false);
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ nodeTypesInfo.put(nodeName,nodeTypeInfo);
+ CsarInfo csarInfo = getCsarInfo();
+
+ try {
+ sIB1.handleNodeTypes(yamlName,resource,topologyTemplateYaml,needLock,
+ nodeTypesArtifactsToHandle,nodeTypesNewCreatedArtifacts,nodeTypesInfo,
+ csarInfo,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleNestedVfc1(){
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ Resource resource = createParseResourceObject(false);
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ nodeTypeInfo.setTemplateFileName("groups.yml");
+ nodeTypeInfo.setMappedToscaTemplate(new HashMap<>());
+ nodesInfo.put(nodeName,nodeTypeInfo);
+ CsarInfo csarInfo = getCsarInfo();
+
+ try {
+ sIB1.handleNestedVfc(resource,nodeTypesArtifactsToHandle,createdArtifacts,
+ nodesInfo,csarInfo,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleComplexVfc1(){
+ Resource resource = createParseResourceObject(true);
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ String yamlName = "group.yml";
+
+ try {
+ sIB1.handleComplexVfc(resource,nodeTypesArtifactsToHandle,createdArtifacts,
+ nodesInfo,csarInfo,nodeName,yamlName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateResourcesFromYamlNodeTypesList1(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(false);
+ Map<String, Object> mappedToscaTemplate = new HashMap<>();
+ boolean needLock = true;
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+
+ try {
+ sIB1.createResourcesFromYamlNodeTypesList(yamlName,resource,mappedToscaTemplate,
+ needLock, nodeTypesArtifactsToHandle,nodeTypesNewCreatedArtifacts,
+ nodeTypesInfo,csarInfo);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateNodeTypes1(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(false);
+ boolean needLock = true;
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap =
+ new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
+ List<ArtifactDefinition> artifactDefinitions = new ArrayList<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactName");
+ artifactDefinitions.add(artifactDefinition);
+ enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE,
+ artifactDefinitions);
+ nodeTypesArtifactsToHandle.put("nodeTyp",enumListEnumMap);
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ nodeTypesInfo.put("nodeTyp",nodeTypeInfo);
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, Object> mapToConvert =new HashMap<>();
+ Map<String, Object> nodeTypes =new HashMap<>();
+ nodeTypes.put("nodeTyp",nodeTypeInfo);
+
+ try {
+ sIB1.createNodeTypes(yamlName, resource, needLock, nodeTypesArtifactsToHandle,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, mapToConvert,
+ nodeTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateNodeTypeResourceFromYaml(){
+ String yamlName = "group.yml";
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ Map<String,Object> nodeMap = new HashMap<>();
+ nodeMap.put(nodeName,getGroupsYaml());
+ Map.Entry<String, Object> nodeNameValue = nodeMap.entrySet().iterator().next();
+ Map<String, Object> mapToConvert = new HashedMap();
+ Resource resourceVf = createParseResourceObject(false);
+ boolean needLock = true;
+ Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ boolean forceCertificationAllowed = true;
+ CsarInfo csarInfo = getCsarInfo();
+ boolean isNested = true;
+
+ try {
+ sIB1.createNodeTypeResourceFromYaml(yamlName,nodeNameValue,user,mapToConvert,resourceVf,
+ needLock,nodeTypeArtifactsToHandle,nodeTypesNewCreatedArtifacts,
+ forceCertificationAllowed,csarInfo,isNested);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateRIAndRelationsFromYaml(){
+ String yamlName = "group.yml";
+ Service service = createServiceObject(true);
+ Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = new HashMap<>();
+ String topologyTemplateYaml = getMainTemplateContent("service_import_template.yml");;
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ try {
+ sIB1.createRIAndRelationsFromYaml(yamlName,service,uploadComponentInstanceInfoMap,topologyTemplateYaml,nodeTypesNewCreatedArtifacts,
+ nodeTypesInfo,csarInfo,nodeTypesArtifactsToCreate,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateServiceInstancesRelations(){
+ String yamlName = "group.yml";
+ Service service = createServiceObject(true);
+ service.setComponentInstances(creatComponentInstances());
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ uploadResInstancesMap.put("uploadResInstancesMap",getuploadComponentInstanceInfo());
+
+ try {
+ sIB1.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testProcessComponentInstance(){
+ String yamlName = "group.yml";
+ Service service = createServiceObject(true);
+ Resource originResource = createParseResourceObject(false);
+ List<ComponentInstance> componentInstancesList = creatComponentInstances();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null;
+ Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
+ Map<String, List< AttributeDataDefinition >> instAttributes = new HashMap<>();
+ Map<String, Resource> originCompMap = new HashMap<>();
+ originCompMap.put("componentUid",originResource);
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
+
+ try {
+ sIB1.processComponentInstance(yamlName, service, componentInstancesList,allDataTypes,instProperties,instCapabilties,instRequirements,
+ instDeploymentArtifacts,instArtifacts,instAttributes,originCompMap,instInputs,uploadComponentInstanceInfo);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddInputsValuesToRi2(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ Map<String, List<UploadPropInfo>> properties = new HashMap<>();
+ List<UploadPropInfo> uploadPropInfoList = new ArrayList<>();
+ UploadPropInfo uploadPropInfo = new UploadPropInfo();
+ uploadPropInfo.setName("uploadPropInfo");
+ uploadPropInfoList.add(uploadPropInfo);
+ uploadPropInfoList.add(uploadPropInfo);
+ properties.put("propertiesMap",uploadPropInfoList);
+ uploadComponentInstanceInfo.setProperties(properties);
+ Service resource = createServiceObject(true);
+ Resource originResource =createParseResourceObject(false);
+ List<InputDefinition> inputs = new ArrayList<>();
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setUniqueId("uniqueId");
+ inputs.add(inputDefinition);
+ originResource.setInputs(inputs);
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+
+ try {
+ sIB1.addInputsValuesToRi(uploadComponentInstanceInfo,resource,originResource,
+ currentCompInstance,instInputs,allDataTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testProcessProperty2(){
+ Service resource = createServiceObject(true);
+ ComponentInstance currentCompInstance = null;
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+ Map<String, InputDefinition> currPropertiesMap = new HashMap<>();
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setType("inputDefinitionType");
+ currPropertiesMap.put("propertyInfoName",inputDefinition);
+ List<ComponentInstanceInput> instPropList = new ArrayList<>();
+ List<UploadPropInfo> propertyList = new ArrayList<>();
+ List<GetInputValueDataDefinition> get_input = new ArrayList<>();
+ GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ getInputValueDataDefinition.setPropName("getInputValueDataDefinitionName");
+ get_input.add(getInputValueDataDefinition);
+ UploadPropInfo propertyInfo = new UploadPropInfo();
+ propertyInfo.setValue("value");
+ propertyInfo.setGet_input(get_input);
+ propertyInfo.setName("propertyInfoName");
+ propertyList.add(propertyInfo);
+
+ try {
+ sIB1.processProperty(resource, currentCompInstance, allDataTypes,
+ currPropertiesMap, instPropList, propertyList);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testProcessGetInput(){
+ List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
+ List<InputDefinition> inputs = new ArrayList<>();
+ GetInputValueDataDefinition getInputIndex = new GetInputValueDataDefinition();
+
+ try {
+ sIB1.processGetInput(getInputValues,inputs,getInputIndex);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddPropertyValuesToRi(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setProperties(getUploadPropInfoProperties());
+ Resource resource = createParseResourceObject(true);
+ Resource originResource = createParseResourceObject(false);
+ originResource.setProperties(getProperties());
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+ try {
+ sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance,
+ instProperties, allDataTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddPropertyValuesToRi2(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setProperties(getUploadPropInfoProperties());
+ Service service = createServiceObject(false);
+ Resource originResource = createParseResourceObject(false);
+ originResource.setProperties(getProperties());
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+
+ try {
+ sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, service, originResource, currentCompInstance,
+ instProperties, allDataTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testProcessComponentInstanceCapabilities(){
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null;
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>();
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setProperties(getUploadPropInfoProperties()); Map<String, List<UploadPropInfo>> properties = new HashMap<>();
+ uploadComponentInstanceInfo.setProperties(properties);
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Resource originResource = createParseResourceObject(false);
+
+ sIB1.processComponentInstanceCapabilities(allDataTypes, instCapabilties, uploadComponentInstanceInfo,
+ currentCompInstance, originResource);
+ }
+
+ @Test
+ public void testUpdateCapabilityPropertiesValues(){
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null;
+ Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
+
+ sIB1.updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ }
+
+ @Test
+ public void testUpdatePropertyValues(){
+ List<ComponentInstanceProperty> properties = new ArrayList<>();
+ Map<String, UploadPropInfo> newProperties = new HashMap<>();
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+
+ sIB1.updatePropertyValues(properties,newProperties,allDataTypes);
+ }
+
+ @Test
+ public void testUpdatePropertyValue(){
+ ComponentInstanceProperty property = new ComponentInstanceProperty();
+ property.setType("services");
+ UploadPropInfo propertyInfo = new UploadPropInfo();
+ propertyInfo.setValue("value");
+ Map<String, DataTypeDefinition> allDataTypes = new HashMap<>();
+
+ try {
+ sIB1.updatePropertyValue(property,propertyInfo,allDataTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetOriginResource(){
+ String yamlName = "group.yml";
+ Map<String, Resource> originCompMap = new HashMap<>();
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ currentCompInstance.setComponentUid("currentCompInstance");
+
+ try {
+ sIB1.getOriginResource(yamlName,originCompMap,currentCompInstance);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleSubstitutionMappings2(){
+ Service service = createServiceObject(false);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+
+ sIB1.handleSubstitutionMappings(service, uploadResInstancesMap);
+ }
+
+ @Test
+ public void testUpdateCalculatedCapReqWithSubstitutionMappings(){
+ Resource resource = createParseResourceObject(false);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+
+ when(toscaOperationFacade.deleteAllCalculatedCapabilitiesRequirements(any())).thenReturn(StorageOperationStatus.OK);
+
+ try {
+ sIB1.updateCalculatedCapReqWithSubstitutionMappings(resource,uploadResInstancesMap);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testFillUpdatedInstCapabilitiesRequirements(){
+ List<ComponentInstance> componentInstances = creatComponentInstances();
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = getUploadResInstancesMap();
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirement = new HashMap<>();
+
+ sIB1.fillUpdatedInstCapabilitiesRequirements(componentInstances,uploadResInstancesMap,
+ updatedInstCapabilities,updatedInstRequirement);
+ }
+
+ @Test
+ public void testFillUpdatedInstCapabilities(){
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilties = new HashMap<>();
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setName("mme_ipu_vdu.feature");
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilities.put("tosca.capabilities.Node",capabilityDefinitionList);
+ ComponentInstance instance = new ComponentInstance();
+ instance.setCapabilities(capabilities);
+ Map<String, String> capabilitiesNamesToUpdate = new HashMap<>();
+ capabilitiesNamesToUpdate.put("mme_ipu_vdu.feature","capabilitiesNamesToUpdate");
+
+ sIB1.fillUpdatedInstCapabilities(updatedInstCapabilties,instance,capabilitiesNamesToUpdate);
+ }
+
+ @Test
+ public void testFillUpdatedInstRequirements(){
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements = new
+ HashMap<>();
+ ComponentInstance instance = new ComponentInstance();
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ List<RequirementDefinition> requirementDefinitionList = new ArrayList<>();
+ RequirementDefinition requirementDefinition = new RequirementDefinition();
+ requirementDefinition.setName("zxjtestimportserviceab0.mme_ipu_vdu.dependency.test");
+ requirementDefinitionList.add(requirementDefinition);
+ requirements.put("tosca.capabilities.Node",requirementDefinitionList);
+ instance.setRequirements(requirements);
+ Map<String, String> requirementsNamesToUpdate = new HashMap<>();
+ requirementsNamesToUpdate.put("zxjtestimportserviceab0.mme_ipu_vdu.dependency.test",
+ "requirementsNamesToUpdate");
+
+
+ sIB1.fillUpdatedInstRequirements(updatedInstRequirements,instance,requirementsNamesToUpdate);
+ }
+
+ @Test
+ public void testAddRelationsToRI(){
+ String yamlName = "group.yml";
+ Service service = createServiceObject(false);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ UploadComponentInstanceInfo nodesInfoValue = getuploadComponentInstanceInfo();
+ uploadResInstancesMap.put("uploadComponentInstanceInfo", nodesInfoValue);
+ List<ComponentInstance> componentInstancesList = creatComponentInstances();
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+
+ try {
+ sIB1.addRelationsToRI(yamlName,service,uploadResInstancesMap,componentInstancesList,
+ relations);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddRelationToRI(){
+ String yamlName = "group.yml";
+ Service service = createServiceObject(false);
+ service.setComponentInstances(creatComponentInstances());
+
+ UploadComponentInstanceInfo nodesInfoValue = getuploadComponentInstanceInfo();
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+
+ try {
+ sIB1.addRelationToRI(yamlName,service,nodesInfoValue,relations);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetResourceAfterCreateRelations(){
+ Service service = createServiceObject(false);
+ ComponentParametersView componentParametersView = createComponentParametersView();
+ when(serviceImportParseLogic.getComponentFilterAfterCreateRelations()).thenReturn(componentParametersView);
+ try {
+ sIB1.getResourceAfterCreateRelations(service);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateServiceInstances(){
+ String yamlName = "group.yml";
+ Service service = createServiceObject(false);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ UploadComponentInstanceInfo nodesInfoValue = getuploadComponentInstanceInfo();
+ uploadResInstancesMap.put("uploadResInstancesMap",nodesInfoValue);
+ Map<String, Resource> nodeNamespaceMap = new HashMap<>();
+ Resource resource = createParseResourceObject(true);
+ resource.setToscaResourceName("toscaResourceName");
+ nodeNamespaceMap.put("nodeNamespaceMap",resource);
+
+ try {
+ sIB1.createServiceInstances(yamlName,service,uploadResInstancesMap,nodeNamespaceMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateAndAddResourceInstance(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo();
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(false);
+ Resource originResource = createParseResourceObject(true);
+ originResource.setResourceType(ResourceTypeEnum.VF);
+ Map<String, Resource> nodeNamespaceMap = new HashMap<>();
+ nodeNamespaceMap.put("resources",originResource);
+ Map<String, Resource> existingnodeTypeMap = new HashMap<>();
+ Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>();
+
+ try {
+ sIB1.createAndAddResourceInstance(uploadComponentInstanceInfo,yamlName,resource,nodeNamespaceMap,
+ existingnodeTypeMap,resourcesInstancesMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateAndAddResourceInstances(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo();
+ String yamlName = "group.yml";
+ Service service = createServiceObject(false);
+ service.setServiceType("services");
+ Resource originResource = createParseResourceObject(true);
+ originResource.setResourceType(ResourceTypeEnum.VF);
+ Map<String, Resource> nodeNamespaceMap = new HashMap<>();
+ nodeNamespaceMap.put("resources", originResource);
+ Map<String, Resource> existingnodeTypeMap = new HashMap<>();
+ Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>();
+
+ try {
+ sIB1.createAndAddResourceInstance(uploadComponentInstanceInfo, yamlName, service, nodeNamespaceMap,
+ existingnodeTypeMap, resourcesInstancesMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateResourceInstanceBeforeCreate(){
+ String yamlName = "group.yml";
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo();
+ Resource originResource = createParseResourceObject(true);
+ originResource.setResourceType(ResourceTypeEnum.VF);
+ Map<String, Resource> nodeNamespaceMap = new HashMap<>();
+ nodeNamespaceMap.put("resources", originResource);
+
+ try {
+ sIB1.validateResourceInstanceBeforeCreate(yamlName,uploadComponentInstanceInfo,nodeNamespaceMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleServiceNodeTypes(){
+ String yamlName = "group.yml";
+ Service service =createServiceObject(false);
+ String topologyTemplateYaml = getMainTemplateContent("service_import_template.yml");;
+ boolean needLock = true;
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = getNodeTypesInfo();
+ CsarInfo csarInfo = getCsarInfo();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+
+ try {
+ sIB1.handleServiceNodeTypes(yamlName,service,topologyTemplateYaml,needLock,
+ nodeTypesArtifactsToHandle,nodeTypesNewCreatedArtifacts,nodeTypesInfo,
+ csarInfo,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateResourceNotExisted(){
+ String type = "org.openecomp.resource.vf";
+ boolean b = false;
+ try {
+ b = sIB1.validateResourceNotExisted(type);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleNestedVF(){
+ Service service =createServiceObject(false);
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodesInfo = getNodeTypesInfo();
+ CsarInfo csarInfo = getCsarInfo();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+
+ try {
+ sIB1.handleNestedVF(service,nodeTypesArtifactsToHandle,createdArtifacts,
+ nodesInfo,csarInfo,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleNestedVfc(){
+ Service service =createServiceObject(false);
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+
+ try {
+ sIB1.handleNestedVfc(service,nodeTypesArtifactsToHandle,createdArtifacts,
+ nodesInfo,csarInfo,nodeName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleComplexVfc(){
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ String yamlName = "group.yml";
+
+ try {
+ sIB1.handleComplexVfc(nodeTypesArtifactsToHandle,createdArtifacts,
+ nodesInfo,csarInfo,nodeName,yamlName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @Test
+ public void testHandleComplexVfc2(){
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodesInfo = getNodeTypesInfo();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ String yamlName = "group.yml";
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, byte[]> csar = new HashMap<>();
+ csar.put(yamlName,yamlName.getBytes());
+ csarInfo.setCsar(csar);
+ Resource oldComplexVfc = createParseResourceObject(false);
+ Resource newComplexVfc = createParseResourceObject(true);
+
+ try {
+ sIB1.handleComplexVfc(nodeTypesArtifactsToHandle,createdArtifacts,nodesInfo,
+ csarInfo,nodeName,yamlName,oldComplexVfc,newComplexVfc);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUpdateResourceFromYaml(){
+ Resource oldRresource = createParseResourceObject(false);
+ Resource newRresource = createParseResourceObject(true);
+ AuditingActionEnum actionEnum = AuditingActionEnum.CREATE_RESOURCE;
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ String yamlFileName = "group.yml";
+ String yamlFileContent = getYamlFileContent();
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ boolean isNested = true;
+
+ try {
+ sIB1.updateResourceFromYaml(oldRresource,newRresource,actionEnum,createdArtifacts,yamlFileName,yamlFileContent,
+ csarInfo,nodeTypesInfo,nodeTypesArtifactsToHandle,nodeName,isNested);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testCreateResourceFromYaml(){
+ Resource resource = createParseResourceObject(true);
+ String topologyTemplateYaml = getMainTemplateContent();
+ String yamlName = "group.yml";
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
+ boolean shouldLock = true;
+ boolean inTransaction =true;
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+
+ try {
+ sIB1.createResourceFromYaml(resource,topologyTemplateYaml,yamlName,nodeTypesInfo,csarInfo,
+ nodeTypesArtifactsToCreate,shouldLock,inTransaction,nodeName);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testCreateResourceAndRIsFromYaml(){
+ String yamlName = "group.yml";
+ Resource resource = createParseResourceObject(false);
+ ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
+ AuditingActionEnum actionEnum = AuditingActionEnum.CREATE_RESOURCE;
+ boolean isNormative = true;
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ String topologyTemplateYaml = getMainTemplateContent();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
+ boolean shouldLock = true;
+ boolean inTransaction = true;
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+
+ try {
+ sIB1.createResourceAndRIsFromYaml(yamlName,resource,parsedToscaYamlInfo,actionEnum,
+ isNormative,createdArtifacts,topologyTemplateYaml,nodeTypesInfo,csarInfo,
+ nodeTypesArtifactsToCreate,shouldLock,inTransaction,nodeName);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testCreateGroupsOnResource2(){
+ Resource resource = createParseResourceObject(false);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+
+ Either<Resource, ResponseFormat> result = sIB1.createGroupsOnResource(resource, groups);
+ assertEquals(result.left().value(),resource);
+ }
+
+ @Test
+ public void testUpdateGroupsMembersUsingResource2(){
+ Resource resource = createParseResourceObject(true);
+ Map<String, GroupDefinition> groups = null;
+
+ List<GroupDefinition> groupDefinitions = sIB1.updateGroupsMembersUsingResource(groups,resource);
+ for (GroupDefinition groupDefinition : groupDefinitions) {
+ assertNull(groupDefinition);
+ }
+ }
+
+ @Test
+ public void testUpdateGroupMembers(){
+ Map<String, GroupDefinition> groups = new HashMap<>();
+ GroupDefinition updatedGroupDefinition = new GroupDefinition();
+ Resource component = createParseResourceObject(true);
+ List<ComponentInstance> componentInstances = creatComponentInstances();
+ String groupName = "tosca_simple_yaml_1_1";
+ Map<String, String> members = new HashMap<>();
+ members.put("zxjTestImportServiceAb",getGroupsYaml());
+
+ try {
+ sIB1.updateGroupMembers(groups,updatedGroupDefinition,component,componentInstances,
+ groupName,members);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void setCreateResourceTransaction(){
+ Resource resource = createParseResourceObject(false);
+ resource.setComponentType(ComponentTypeEnum.RESOURCE);
+ boolean isNormative = true;
+
+ try {
+ sIB1.createResourceTransaction(resource,user,isNormative);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUpdateExistingResourceByImport(){
+ Resource newResource = createParseResourceObject(false);
+ Resource oldResource = createParseResourceObject(true);
+
+ try {
+ sIB1.updateExistingResourceByImport(newResource,oldResource,user,
+ true,true,true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateResourcesFromYamlNodeTypesList(){
+ String yamlName = "group.yml";
+ Service service =createServiceObject(false);
+ Map<String, Object> mappedToscaTemplate = new HashMap<>();
+ boolean needLock = true;
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ CsarInfo csarInfo = getCsarInfo();
+
+ try {
+ sIB1.createResourcesFromYamlNodeTypesList(yamlName,service,mappedToscaTemplate,needLock,
+ nodeTypesArtifactsToHandle,nodeTypesNewCreatedArtifacts,nodeTypesInfo,csarInfo);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateNodeTypes(){
+ String yamlName = "group.yml";
+ Service service =createServiceObject(false);
+ boolean needLock = true;
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap =
+ new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
+ List<ArtifactDefinition> artifactDefinitions = new ArrayList<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactName("artifactName");
+ artifactDefinitions.add(artifactDefinition);
+ enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE,
+ artifactDefinitions);
+ nodeTypesArtifactsToHandle.put("nodeTyp",enumListEnumMap); List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = getNodeTypesInfo();
+ CsarInfo csarInfo = getCsarInfo();
+ Map<String, Object> mapToConvert =new HashMap<>();
+ Map<String, Object> nodeTypes =new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ nodeTypesInfo.put("nodeTyp",nodeTypeInfo);
+ nodeTypes.put("org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test",
+ nodeTypeInfo);
+
+ try {
+ sIB1.createNodeTypes(yamlName, service, needLock, nodeTypesArtifactsToHandle,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, mapToConvert,
+ nodeTypes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected List<UploadPropInfo> getPropertyList() {
+ List<UploadPropInfo> propertyList = new ArrayList<>();
+ UploadPropInfo uploadPropInfo = new UploadPropInfo();
+ List<GetInputValueDataDefinition> get_input = new ArrayList<>();
+ GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ getInputValueDataDefinition.setPropName("getInputValueDataDefinitionName");
+ get_input.add(getInputValueDataDefinition);
+ uploadPropInfo.setName("propertiesName");
+ uploadPropInfo.setValue("value");
+ uploadPropInfo.setGet_input(get_input);
+ propertyList.add(uploadPropInfo);
+ return propertyList;
+ }
+
+ protected Map<String, GroupDefinition> getGroups() {
+ Map<String, GroupDefinition> groups = new HashMap<>();
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groupDefinition.setName("groupDefinitionName");
+ groups.put("groupsMap",groupDefinition);
+ return groups;
+ }
+
+ protected Map<String, NodeTypeInfo> getNodeTypesInfo(){
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ Map<String, Object> mappedToscaTemplate = new HashMap<>();
+ nodeTypeInfo.setTemplateFileName("templateFileName");
+ nodeTypeInfo.setMappedToscaTemplate(mappedToscaTemplate);
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ nodeTypesInfo.put(nodeName,nodeTypeInfo);
+ return nodeTypesInfo;
+ }
+
+ protected Map<String, UploadComponentInstanceInfo> getUploadResInstancesMap(){
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo();
+ Map<String, String> capabilitiesNamesToUpdate = new HashMap<>();
+ capabilitiesNamesToUpdate.put("mme_ipu_vdu.feature","capabilitiesNamesToUpdate");
+ Map<String, String> requirementsNamesToUpdate = new HashMap<>();
+ requirementsNamesToUpdate.put("mme_ipu_vdu.feature","capabilitiesNamesToUpdate");
+ uploadResInstancesMap.put("zxjTestImportServiceAb",uploadComponentInstanceInfo);
+ return uploadResInstancesMap;
+ }
+
+ protected Map<String, List<UploadPropInfo>> getUploadPropInfoProperties(){
+ Map<String, List<UploadPropInfo>> properties = new HashMap<>();
+ List<UploadPropInfo> uploadPropInfoList = new ArrayList<>();
+ UploadPropInfo uploadPropInfo = new UploadPropInfo();
+ List<GetInputValueDataDefinition> get_input = new ArrayList<>();
+ GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ getInputValueDataDefinition.setPropName("getInputValueDataDefinitionName");
+ get_input.add(getInputValueDataDefinition);
+ uploadPropInfo.setName("propertiesName");
+ uploadPropInfo.setValue("value");
+ uploadPropInfo.setGet_input(get_input);
+ uploadPropInfoList.add(uploadPropInfo);
+ properties.put("uploadComponentInstanceInfo",uploadPropInfoList);
+ return properties;
+ }
+
+ protected List<PropertyDefinition> getProperties(){
+ List<PropertyDefinition> properties = new ArrayList<>();
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setName("propertiesName");
+ properties.add(propertyDefinition);
+ return properties;
+ }
+
+ protected UploadComponentInstanceInfo getuploadComponentInstanceInfo(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setType("resources");
+ Collection<String> directives = new Collection<String>() {
+ @Override
+ public int size() {
+ return 0;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return false;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return false;
+ }
+
+ @Override
+ public Iterator<String> iterator() {
+ return null;
+ }
+
+ @Override
+ public Object[] toArray() {
+ return new Object[0];
+ }
+
+ @Override
+ public <T> T[] toArray(T[] ts) {
+ return null;
+ }
+
+ @Override
+ public boolean add(String s) {
+ return false;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return false;
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> collection) {
+ return false;
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends String> collection) {
+ return false;
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> collection) {
+ return false;
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> collection) {
+ return false;
+ }
+
+ @Override
+ public void clear() {
+
+ }
+ };
+ uploadComponentInstanceInfo.setDirectives(directives);
+ UploadNodeFilterInfo uploadNodeFilterInfo = new UploadNodeFilterInfo();
+ Map<String, List<UploadReqInfo>> requirements = new HashMap<>();
+ List<UploadReqInfo> uploadReqInfoList = new ArrayList<>();
+ UploadReqInfo uploadReqInfo = new UploadReqInfo();
+ uploadReqInfo.setName("uploadReqInfo");
+ uploadReqInfo.setCapabilityName("tosca.capabilities.Node");
+ uploadReqInfoList.add(uploadReqInfo);
+ requirements.put("requirements",uploadReqInfoList);
+ uploadNodeFilterInfo.setName("mme_ipu_vdu.virtualbinding");
+ uploadComponentInstanceInfo.setCapabilities(getCapabilities());
+ uploadComponentInstanceInfo.setRequirements(requirements);
+ return uploadComponentInstanceInfo;
+ }
+
+ protected Map<String, List<UploadCapInfo>> getCapabilities(){
+ List<UploadCapInfo> uploadCapInfoList = new ArrayList<>();
+ UploadCapInfo uploadCapInfo = new UploadCapInfo();
+ uploadCapInfo.setNode("tosca.nodes.Root");
+ uploadCapInfo.setName("mme_ipu_vdu.dependency");
+ uploadCapInfoList.add(uploadCapInfo);
+ Map<String, List<UploadCapInfo>> uploadCapInfoMap = new HashMap<>();
+ uploadCapInfoMap.put("tosca.capabilities.Node",uploadCapInfoList);
+ return uploadCapInfoMap;
+ }
+
+ protected Map<String, List<UploadReqInfo>> gerRequirements(){
+ Map<String, List<UploadReqInfo>> uploadReqInfoMap = new HashMap<>();
+ String requirementName = "tosca.capabilities.Node";
+ List<UploadReqInfo> uploadReqInfoList = new ArrayList<>();
+ UploadReqInfo uploadReqInfo = new UploadReqInfo();
+ uploadReqInfo.setCapabilityName("tosca.capabilities.Node");
+ uploadReqInfoMap.put(requirementName,uploadReqInfoList);
+ return uploadReqInfoMap;
+ }
+
+ protected ComponentParametersView createComponentParametersView() {
+ ComponentParametersView parametersView = new ComponentParametersView();
+ parametersView.disableAll();
+ parametersView.setIgnoreComponentInstances(false);
+ parametersView.setIgnoreComponentInstancesProperties(false);
+ parametersView.setIgnoreCapabilities(false);
+ parametersView.setIgnoreRequirements(false);
+ parametersView.setIgnoreGroups(false);
+ return parametersView;
+ }
+ protected Map<String, byte[]> crateCsarFromPayload() {
+ String payloadName = "valid_vf.csar";
+ String rootPath = System.getProperty("user.dir");
+ Path path;
+ byte[] data;
+ String payloadData;
+ Map<String, byte[]> returnValue = null;
+ try {
+ path = Paths.get(rootPath + "/src/test/resources/valid_vf.csar");
+ data = Files.readAllBytes(path);
+ payloadData = Base64.encodeBase64String(data);
+ UploadResourceInfo resourceInfo = new UploadResourceInfo();
+ resourceInfo.setPayloadName(payloadName);
+ resourceInfo.setPayloadData(payloadData);
+ Method privateMethod = null;
+ privateMethod = AbstractValidationsServlet.class.getDeclaredMethod("getCsarFromPayload", UploadResourceInfo.class);
+ privateMethod.setAccessible(true);
+ returnValue = (Map<String, byte[]>) privateMethod.invoke(servlet, resourceInfo);
+ } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ return returnValue;
+ }
+
+
+ protected List<ComponentInstance> creatComponentInstances(){
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance componentInstance = new ComponentInstance();
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setName("mme_ipu_vdu.feature");
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilities.put("tosca.capabilities.Node",capabilityDefinitionList);
+
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ List<RequirementDefinition> requirementDefinitionList = new ArrayList<>();
+ RequirementDefinition requirementDefinition = new RequirementDefinition();
+ requirementDefinition.setName("zxjtestimportserviceab0.mme_ipu_vdu.dependency.test");
+ requirementDefinitionList.add(requirementDefinition);
+ requirements.put("tosca.capabilities.Node",requirementDefinitionList);
+ componentInstance.setRequirements(requirements);
+ componentInstance.setCapabilities(capabilities);
+ componentInstance.setUniqueId("uniqueId");
+ componentInstance.setComponentUid("componentUid");
+ componentInstance.setName("zxjTestImportServiceAb");
+ componentInstances.add(componentInstance);
+ return componentInstances;
+ }
+
+ protected CreateServiceFromYamlParameter getCsfyp() {
+ CreateServiceFromYamlParameter csfyp = new CreateServiceFromYamlParameter();
+ List<ArtifactDefinition> createdArtifacts =new ArrayList<>();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashedMap();
+
+ csfyp.setNodeName("org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test");
+ csfyp.setTopologyTemplateYaml(getMainTemplateContent("service_import_template.yml"));
+ csfyp.setCreatedArtifacts(createdArtifacts);
+ csfyp.setInTransaction(true);
+ csfyp.setShouldLock(true);
+ csfyp.setCsarInfo(getCsarInfo());
+ csfyp.setParsedToscaYamlInfo(getParsedToscaYamlInfo());
+ csfyp.setNodeTypesInfo(nodeTypesInfo);
+ csfyp.setYamlName("group.yml");
+ return csfyp;
+ }
+
+ protected ParsedToscaYamlInfo getParsedToscaYamlInfo(){
+ ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
+ Map<String, InputDefinition> inputs = new HashMap<>();
+ Map<String, UploadComponentInstanceInfo> instances=new HashMap<>();
+ Map<String, GroupDefinition> groups=new HashMap<>();
+ Map<String, PolicyDefinition> policies=new HashMap<>();
+ parsedToscaYamlInfo.setGroups(groups);
+ parsedToscaYamlInfo.setInputs(inputs);
+ parsedToscaYamlInfo.setInstances(instances);
+ parsedToscaYamlInfo.setPolicies(policies);
+ return parsedToscaYamlInfo;
+ }
+
+ String getMainTemplateContent(String fileName){
+ String mainTemplateContent = null;
+ try {
+ mainTemplateContent = loadFileNameToJsonString(fileName);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return mainTemplateContent;
+ }
+
+ protected CsarInfo getCsarInfo ()
+ {
+ String csarUuid = "0010";
+ User user = new User();
+ Map<String, byte[]> csar = crateCsarFromPayload();
+ String vfReousrceName = "resouceName";
+ String mainTemplateName = "mainTemplateName";
+ String mainTemplateContent = getMainTemplateContent("service_import_template.yml");
+ CsarInfo csarInfo = new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
+ return csarInfo;
+ }
+
+ public static String loadFileNameToJsonString(String fileName) throws IOException {
+ String sourceDir = "src/test/resources/normativeTypes";
+ return loadFileNameToJsonString(sourceDir, fileName);
+ }
+
+ private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException {
+ java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName);
+ byte[] fileContent = Files.readAllBytes(filePath);
+ return new String(fileContent);
+ }
+
+
+ protected CsarUtils.NonMetaArtifactInfo getNonMetaArtifactInfo(){
+ String artifactName = "artifactName",path = "/src/test/resources/valid_vf.csar",artifactType = "AAI_SERVICE_MODEL";
+ ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.TOSCA;
+ String rootPath = System.getProperty("user.dir");
+ Path path2;
+ byte[] data = new byte[0];
+ path2 = Paths.get(rootPath + "/src/test/resources/valid_vf.csar");
+ try {
+ data = Files.readAllBytes(path2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ String artifactUniqueId = "artifactUniqueId";
+ boolean isFromCsar = true;
+ CsarUtils.NonMetaArtifactInfo nonMetaArtifactInfo = new CsarUtils.NonMetaArtifactInfo(artifactName,
+ path,artifactType,artifactGroupType,data,artifactUniqueId,isFromCsar);
+ return nonMetaArtifactInfo;
+
+ }
+
+ protected void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat actualResponse = e.getResponseFormat() != null ?
+ e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ assertParseResponse(actualResponse, expectedStatus, variables);
+ }
+
+ private void assertParseResponse(ResponseFormat actualResponse, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
+ assertThat(expectedResponse.getStatus()).isEqualTo(actualResponse.getStatus());
+ assertThat(expectedResponse.getFormattedMessage()).isEqualTo(actualResponse.getFormattedMessage());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
new file mode 100644
index 0000000000..15487d7ea0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
@@ -0,0 +1,1078 @@
+/*
+
+ * Copyright (c) 2018 AT&T Intellectual Property.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
+
+package org.openecomp.sdc.be.components.impl;
+
+import fj.data.Either;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.binary.Base64;
+import org.junit.Before;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.openecomp.sdc.ElementOperationMock;
+import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
+import org.openecomp.sdc.be.components.csar.CsarInfo;
+import org.openecomp.sdc.be.components.distribution.engine.DistributionEngine;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
+import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter;
+import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
+import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
+import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
+import org.openecomp.sdc.be.components.validation.UserValidations;
+import org.openecomp.sdc.be.components.validation.component.*;
+import org.openecomp.sdc.be.components.validation.service.*;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.externalapi.servlet.representation.*;
+import org.openecomp.sdc.be.facade.operations.CatalogOperation;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.WebAppContextWrapper;
+import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
+import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
+import org.openecomp.sdc.be.user.Role;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.api.UploadArtifactInfo;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.web.context.WebApplicationContext;
+
+import javax.servlet.ServletContext;
+import java.util.*;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.when;
+
+public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicMock {
+ protected ServiceImportBusinessLogic sIB1;
+ protected static final String SERVICE_CATEGORY = "Mobility";
+ protected static final String INSTANTIATION_TYPE = "A-la-carte";
+ protected final ServletContext servletContext = Mockito.mock(ServletContext.class);
+ protected UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
+ protected WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+ protected WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
+ protected ResponseFormatManager responseManager = null;
+ protected ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+ protected AuditCassandraDao auditingDao = Mockito.mock(AuditCassandraDao.class);
+ protected ArtifactsBusinessLogic artifactBl = Mockito.mock(ArtifactsBusinessLogic.class);
+ protected GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
+ protected JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class);
+ protected ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ protected CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class);
+ protected GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
+ protected UserValidations userValidations = Mockito.mock(UserValidations.class);
+ protected ResourceAdminEvent auditArchive1 = Mockito.mock(ResourceAdminEvent.class);
+ protected CatalogOperation catalogOperation = Mockito.mock(CatalogOperation.class);
+ protected ResourceAdminEvent auditArchive2 = Mockito.mock(ResourceAdminEvent.class);
+ protected ResourceAdminEvent auditRestore = Mockito.mock(ResourceAdminEvent.class);
+ protected ServiceImportParseLogic serviceImportParseLogic = Mockito.mock(ServiceImportParseLogic.class);
+ IElementOperation mockElementDao = new ElementOperationMock();
+ DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class);
+ ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
+ ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
+ UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
+ NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
+ NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
+ protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator(componentsUtils);
+ protected ServiceCategoryValidator serviceCategoryValidator = new ServiceCategoryValidator(componentsUtils, mockElementDao);
+ protected ServiceRoleValidator serviceRoleValidator = new ServiceRoleValidator(componentsUtils);
+ protected ServiceFunctionValidator serviceFunctionValidator = new ServiceFunctionValidator(componentsUtils);
+ protected ServiceInstantiationTypeValidator serviceInstantiationTypeValidator = new ServiceInstantiationTypeValidator(componentsUtils);
+ protected ComponentDescriptionValidator componentDescriptionValidator = new ComponentDescriptionValidator(componentsUtils);
+ protected ComponentProjectCodeValidator componentProjectCodeValidator = new ComponentProjectCodeValidator(componentsUtils);
+ protected ComponentIconValidator componentIconValidator = new ComponentIconValidator(componentsUtils);
+ protected ComponentContactIdValidator componentContactIdValidator = new ComponentContactIdValidator(componentsUtils);
+ protected ComponentTagsValidator componentTagsValidator = new ComponentTagsValidator(componentsUtils);
+ protected ComponentNameValidator componentNameValidator = new ComponentNameValidator(componentsUtils, toscaOperationFacade);
+ protected final ComponentValidator componentValidator = Mockito.mock(ComponentValidator.class);
+ protected ServiceValidator serviceValidator = createServiceValidator();
+
+ protected User user = null;
+ protected Resource genericService = null;
+
+ private static final String RESOURCE_NAME = "My-Resource_Name with space";
+ private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name";
+ private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
+ private static final String RESOURCE_SUBCATEGORY = "Router";
+ protected static final String CERTIFIED_VERSION = "1.0";
+ protected static final String UNCERTIFIED_VERSION = "0.2";
+ protected static final String COMPONNET_ID = "myUniqueId";
+ protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
+
+ protected static final String SERVICE_ROLE = JsonPresentationFields.SERVICE_ROLE.getPresentation();
+ protected static final String SERVICE_TYPE = JsonPresentationFields.SERVICE_TYPE.getPresentation();
+ protected static final String SERVICE_FUNCTION = JsonPresentationFields.SERVICE_FUNCTION.getPresentation();
+
+ public ServiceImportBussinessLogicBaseTestSetup() {
+
+ }
+
+ protected ServiceValidator createServiceValidator() {
+ List<ComponentFieldValidator> componentFieldValidators = Arrays.asList(componentContactIdValidator,
+ componentDescriptionValidator,
+ componentIconValidator, componentNameValidator,
+ new ComponentProjectCodeValidator(componentsUtils),
+ componentTagsValidator);
+
+ List<ServiceFieldValidator> serviceFieldValidators = Arrays.asList(serviceCategoryValidator, new ServiceEnvironmentContextValidator(),
+ serviceInstantiationTypeValidator, new ServiceNamingPolicyValidator(componentsUtils),
+ serviceRoleValidator, serviceTypeValidator);
+ return new ServiceValidator(componentsUtils, componentFieldValidators, serviceFieldValidators);
+ }
+
+ @Before
+ public void setup() {
+
+ // Elements
+ IElementOperation mockElementDao = new ElementOperationMock();
+
+ // User data and management
+ user = new User();
+ user.setUserId("jh0003");
+ user.setFirstName("Jimmi");
+ user.setLastName("Hendrix");
+ user.setRole(Role.ADMIN.name());
+
+ when(mockUserAdmin.getUser("jh0003", false)).thenReturn(user);
+ when(userValidations.validateUserExists(eq("jh0003"))).thenReturn(user);
+ when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(user);
+// when(userValidations.validateUserRole(user))
+ // Servlet Context attributes
+ when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
+// when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation());
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+ when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext);
+ when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao);
+ when(graphLockOperation.lockComponent(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Service))).thenReturn(StorageOperationStatus.OK);
+ when(graphLockOperation.lockComponentByName(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Service))).thenReturn(StorageOperationStatus.OK);
+ when(catalogOperation.updateCatalog(Mockito.any(), Mockito.any())).thenReturn(ActionStatus.OK);
+ // artifact bussinesslogic
+ ArtifactDefinition artifactDef = new ArtifactDefinition();
+ when(artifactBl.createArtifactPlaceHolderInfo(Mockito.any(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef);
+
+ // createService
+ Service serviceResponse = createServiceObject(true);
+ Either<Component, StorageOperationStatus> eitherCreate = Either.left(serviceResponse);
+ when(toscaOperationFacade.createToscaComponent(Mockito.any(Component.class))).thenReturn(eitherCreate);
+ when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherCreate);
+ Either<Boolean, StorageOperationStatus> eitherCount = Either.left(false);
+ when(toscaOperationFacade.validateComponentNameExists("Service", null, ComponentTypeEnum.SERVICE)).thenReturn(eitherCount);
+ Either<Boolean, StorageOperationStatus> eitherCountExist = Either.left(true);
+ when(toscaOperationFacade.validateComponentNameExists("alreadyExist", null, ComponentTypeEnum.SERVICE)).thenReturn(eitherCountExist);
+ when(userValidations.validateUserExists(user)).thenReturn(user);
+
+ // createResource
+ Resource resourceRsponse = createParseResourceObject(true);
+ Either<Component, StorageOperationStatus> eitherResourceCreate = Either.left(resourceRsponse);
+ when(toscaOperationFacade.createToscaComponent(Mockito.any(Component.class))).thenReturn(eitherResourceCreate);
+ Either<Component, StorageOperationStatus> eitherResourceRes = Either.left(resourceRsponse);
+ when(toscaOperationFacade.getToscaFullElement(Mockito.anyString())).thenReturn(eitherResourceRes);
+
+ Either<Boolean, StorageOperationStatus> eitherResourceCount = Either.left(false);
+ when(toscaOperationFacade.validateComponentNameExists("Resource", null, ComponentTypeEnum.RESOURCE)).thenReturn(eitherResourceCount);
+ Either<Boolean, StorageOperationStatus> eitherResourceCountExist = Either.left(true);
+ when(toscaOperationFacade.validateComponentNameExists("alreadyExist", null, ComponentTypeEnum.RESOURCE)).thenReturn(eitherResourceCountExist);
+
+ genericService = setupGenericServiceMock();
+ Either<Resource, StorageOperationStatus> findLatestGeneric = Either.left(genericService);
+ when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_SERVICE_NAME)).thenReturn(findLatestGeneric);
+
+ when(serviceImportParseLogic.isArtifactDeletionRequired(anyString(),any(),anyBoolean())).thenReturn(true);
+ Either<Boolean, ResponseFormat> validateCGD = Either.left(true);
+ when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())).thenReturn(validateCGD);
+
+ sIB1 = new ServiceImportBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
+ artifactBl, distributionEngine, componentInstanceBusinessLogic,
+ serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter, serviceFilterOperation,
+ serviceFilterValidator, artifactToscaOperation, componentContactIdValidator,
+ componentNameValidator, componentTagsValidator, componentValidator,
+ componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
+
+
+ mockAbstract();
+
+ responseManager = ResponseFormatManager.getInstance();
+ }
+
+ protected Service createServiceObject(boolean afterCreate) {
+ Service service = new Service();
+ service.setUniqueId("sid");
+ service.setName("Service");
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName(SERVICE_CATEGORY);
+ category.setIcons(Collections.singletonList("defaulticon"));
+ List<CategoryDefinition> categories = new ArrayList<>();
+ categories.add(category);
+ service.setCategories(categories);
+ service.setInstantiationType(INSTANTIATION_TYPE);
+
+ service.setDescription("description");
+ List<String> tgs = new ArrayList<>();
+ tgs.add(service.getName());
+ service.setTags(tgs);
+ // service.setVendorName("Motorola");
+ // service.setVendorRelease("1.0.0");
+ service.setIcon("defaulticon");
+ // service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ service.setContactId("aa1234");
+ service.setProjectCode("12345");
+ service.setEcompGeneratedNaming(true);
+
+ if (afterCreate) {
+ service.setVersion("0.1");
+ service.setUniqueId(service.getName() + ":" + service.getVersion());
+ service.setCreatorUserId(user.getUserId());
+ service.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
+ }
+ return service;
+ }
+
+ protected Resource createResourceObject(boolean afterCreate) {
+ Resource resource = new Resource();
+ resource.setUniqueId("sid");
+ resource.setName("Service");
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName(SERVICE_CATEGORY);
+ category.setIcons(Collections.singletonList("defaulticon"));
+ List<CategoryDefinition> categories = new ArrayList<>();
+ categories.add(category);
+ resource.setCategories(categories);
+
+
+ resource.setDescription("description");
+ List<String> tgs = new ArrayList<>();
+ tgs.add(resource.getName());
+ resource.setTags(tgs);
+ resource.setIcon("defaulticon");
+ resource.setContactId("aa1234");
+ resource.setProjectCode("12345");
+
+
+ if (afterCreate) {
+ resource.setVersion("0.1");
+ resource.setUniqueId(resource.getName() + ":" + resource.getVersion());
+ resource.setCreatorUserId(user.getUserId());
+ resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
+ }
+ return resource;
+ }
+
+protected Resource createParseResourceObject(boolean afterCreate) {
+ Resource resource = new Resource();
+ resource.setName(RESOURCE_NAME);
+ resource.setToscaResourceName(RESOURCE_TOSCA_NAME);
+ resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
+ resource.setDescription("My short description");
+ List<String> tgs = new ArrayList<>();
+ tgs.add("test");
+ tgs.add(resource.getName());
+ resource.setTags(tgs);
+ List<String> template = new ArrayList<>();
+ template.add("tosca.nodes.Root");
+ resource.setDerivedFrom(template);
+ resource.setVendorName("Motorola");
+ resource.setVendorRelease("1.0.0");
+ resource.setContactId("ya5467");
+ resource.setIcon("defaulticon");
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ List<RequirementDefinition> requirementDefinitionList= new ArrayList<>();
+ requirements.put("test", requirementDefinitionList);
+ resource.setRequirements(requirements);
+
+ if (afterCreate) {
+ resource.setName(resource.getName());
+ resource.setVersion("0.1");
+ resource.setUniqueId(resource.getName()
+ .toLowerCase() + ":" + resource.getVersion());
+ resource.setCreatorUserId(user.getUserId());
+ resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ }
+ return resource;
+ }
+ protected Resource setupGenericServiceMock() {
+ Resource genericService = new Resource();
+ genericService.setVersion("1.0");
+ genericService.setToscaResourceName(GENERIC_SERVICE_NAME);
+ return genericService;
+ }
+
+ protected UploadComponentInstanceInfo createUploadComponentInstanceInfo(){
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setName("UploadComponentInstanceInfo");
+ return uploadComponentInstanceInfo;
+ }
+
+ private void mockAbstract() {
+ checkCreateAbstract();
+ checkCreateOther();
+ checkCreateFile();
+ }
+
+ private void checkCreateAbstract(){
+ AbstractResourceInfo abstractResourceInfo = new AbstractResourceInfo();
+ List<RequirementCapabilityRelDef> componentInstancesRelations = new ArrayList<>();
+ abstractResourceInfo.setComponentInstancesRelations(componentInstancesRelations);
+ abstractResourceInfo.setAbstractResourceUniqueId("abstractResourceUniqueId");
+ abstractResourceInfo.setAbstractResourceName("abstractResourceName");
+ abstractResourceInfo.setAbstractResourceUUid("abstractResourceUUid");
+
+ AbstractResourceInfo getAbstractResourceInfo = new AbstractResourceInfo();
+ getAbstractResourceInfo.getAbstractResourceName();
+ getAbstractResourceInfo.getAbstractResourceUniqueId();
+ getAbstractResourceInfo.getAbstractResourceUUid();
+ getAbstractResourceInfo.getComponentInstancesRelations();
+
+ AbstractTemplateInfo createAbstractTemplateInfo = new AbstractTemplateInfo();
+ List<AbstractResourceInfo> abstractResourceInfoList = new ArrayList<>();
+ abstractResourceInfoList.add(abstractResourceInfo);
+ createAbstractTemplateInfo.setAbstractResourceInfoList(abstractResourceInfoList);
+ createAbstractTemplateInfo.setServiceUniqueId("serviceUniqueId");
+ createAbstractTemplateInfo.setIsAbstractTemplate(true);
+ createAbstractTemplateInfo.setServiceUUid("serviceUUid");
+
+ AbstractTemplateInfo getAbstractTemplateInfo = new AbstractTemplateInfo();
+ getAbstractTemplateInfo.getAbstractResourceInfoList();
+ getAbstractTemplateInfo.getIsAbstractTemplate();
+ getAbstractTemplateInfo.getServiceUniqueId();
+ getAbstractTemplateInfo.getServiceUUid();
+
+ CopyServiceInfo copyServiceInfo = new CopyServiceInfo();
+ copyServiceInfo.setNewServiceName("newServiceName");
+ copyServiceInfo.setNewServiceUUid("serviceUUid");
+ copyServiceInfo.setOldServiceUUid("oldServiceUUid");
+
+ CopyServiceInfo getCopyServiceInfo = new CopyServiceInfo();
+ getCopyServiceInfo.getNewServiceName();
+ getCopyServiceInfo.getNewServiceUUid();
+ getCopyServiceInfo.getOldServiceUUid();
+
+ ReplaceVNFInfo replaceVNFInfo = new ReplaceVNFInfo();
+ ComponentInstance realVNFComponentInstance = new ComponentInstance();
+ replaceVNFInfo.setAbstractResourceUniqueId("abstractResourceUniqueId");
+ replaceVNFInfo.setRealVNFComponentInstance(realVNFComponentInstance);
+ replaceVNFInfo.setServiceUniqueId("serviceUniqueId");
+
+ ReplaceVNFInfo getReplaceVNFInfo = new ReplaceVNFInfo();
+ getReplaceVNFInfo.getServiceUniqueId();
+ getReplaceVNFInfo.getAbstractResourceUniqueId();
+ getReplaceVNFInfo.getRealVNFComponentInstance();
+ }
+
+ private void checkCreateOther(){
+ ResourceInstanceMetadata resourceInstanceMetadata = new ResourceInstanceMetadata();
+ List<ArtifactMetadata> artifacts = new ArrayList<>();
+ resourceInstanceMetadata.setArtifacts(artifacts);
+ resourceInstanceMetadata.setResoucreType("resoucreType");
+ resourceInstanceMetadata.setResourceInstanceName("resourceInstanceName");
+ resourceInstanceMetadata.setResourceInvariantUUID("resourceInvariantUUID");
+ resourceInstanceMetadata.setResourceName("resourceName");
+ resourceInstanceMetadata.setResourceUUID("resourceUUID");
+ resourceInstanceMetadata.setResourceVersion("resourceVersion");
+
+ ResourceInstanceMetadata getResourceInstanceMetadata = new ResourceInstanceMetadata();
+ getResourceInstanceMetadata.getArtifacts();
+ getResourceInstanceMetadata.getResoucreType();
+ getResourceInstanceMetadata.getResourceInstanceName();
+ getResourceInstanceMetadata.getResourceInvariantUUID();
+ getResourceInstanceMetadata.getResourceName();
+ getResourceInstanceMetadata.getResourceUUID();
+ getResourceInstanceMetadata.getResourceVersion();
+
+ UploadServiceInfo uploadServiceInfo = new UploadServiceInfo();
+ List<String> tags = new ArrayList<>();
+ List<CategoryDefinition> categories = new ArrayList<>();
+ List<UploadArtifactInfo> artifactList = new ArrayList<>();
+ uploadServiceInfo.setProjectCode("projectCode");
+ uploadServiceInfo.setCategories(categories);
+ uploadServiceInfo.setServiceType("");
+ uploadServiceInfo.setServiceVendorModelNumber("serviceVendorModelNumber");
+ uploadServiceInfo.setVendorRelease("vendorRelease");
+ uploadServiceInfo.setVendorName("vendorName");
+ uploadServiceInfo.setServiceIconPath("serviceIconPath");
+ uploadServiceInfo.setName("uploadServiceInfo");
+ uploadServiceInfo.setContactId("contactId");
+ uploadServiceInfo.setIcon("icon");
+ uploadServiceInfo.setNamingPolicy("namingPolicy");
+ uploadServiceInfo.setEcompGeneratedNaming("ecompGeneratedNaming");
+ uploadServiceInfo.setServiceEcompNaming("serviceEcompNaming");
+ uploadServiceInfo.setServiceRole("serviceRole");
+ uploadServiceInfo.setSubcategory("subcategory");
+ uploadServiceInfo.setCategory("category");
+ uploadServiceInfo.setType("type");
+ uploadServiceInfo.setUUID("UUID");
+ uploadServiceInfo.setInvariantUUID("invariantUUID");
+ uploadServiceInfo.setResourceVendorRelease("resourceVendorRelease");
+ uploadServiceInfo.setResourceVendor("resourceVendor");
+ uploadServiceInfo.setDescription("description");
+ uploadServiceInfo.setTags(tags);
+ uploadServiceInfo.setArtifactList(artifactList);
+ uploadServiceInfo.setPayloadName("payloadName");
+ uploadServiceInfo.setPayloadData("payloadData");
+ }
+
+ protected void checkGetUploadServiceInfo(){
+ UploadServiceInfo uploadServiceInfo = new UploadServiceInfo();
+ List<String> tags = new ArrayList<>();
+ List<CategoryDefinition> categories = new ArrayList<>();
+ List<UploadArtifactInfo> artifactList = new ArrayList<>();
+ uploadServiceInfo.getProjectCode();
+ uploadServiceInfo.getCategories();
+ uploadServiceInfo.getServiceType();
+ uploadServiceInfo.getServiceVendorModelNumber();
+ uploadServiceInfo.getVendorRelease();
+ uploadServiceInfo.getVendorName();
+ uploadServiceInfo.getServiceIconPath();
+ uploadServiceInfo.getName();
+ uploadServiceInfo.getContactId();
+ uploadServiceInfo.getIcon();
+ uploadServiceInfo.getNamingPolicy();
+ uploadServiceInfo.getEcompGeneratedNaming();
+ uploadServiceInfo.getServiceEcompNaming();
+ uploadServiceInfo.getServiceRole();
+ uploadServiceInfo.getSubcategory();
+ uploadServiceInfo.getCategory();
+ uploadServiceInfo.getType();
+ uploadServiceInfo.getUUID();
+ uploadServiceInfo.getInvariantUUID();
+ uploadServiceInfo.getResourceVendorRelease();
+ uploadServiceInfo.getResourceVendor();
+ uploadServiceInfo.getDescription();
+ uploadServiceInfo.getTags();
+ uploadServiceInfo.getArtifactList();
+ uploadServiceInfo.getPayloadName();
+ uploadServiceInfo.getPayloadData();
+ }
+
+ private void checkCreateFile(){
+ CreateServiceFromYamlParameter csfp = new CreateServiceFromYamlParameter();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ CsarInfo csarInfo = getCsarInfo();
+ csfp.setYamlName("yamlName");
+ csfp.setNodeTypesInfo(nodeTypesInfo);
+ csfp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
+ csfp.setCsarInfo(csarInfo);
+ csfp.setCreatedArtifacts(createdArtifacts);
+ csfp.setYamlName("yamlName");
+ csfp.setShouldLock(true);
+ csfp.setInTransaction(true);
+ csfp.setNodeName("nodeName");
+
+ CreateServiceFromYamlParameter getCsfy = new CreateServiceFromYamlParameter();
+ getCsfy.getYamlName();
+ getCsfy.getNodeTypesInfo();
+ getCsfy.getParsedToscaYamlInfo();
+ getCsfy.getCsarInfo();
+ getCsfy.getCreatedArtifacts();
+ getCsfy.getYamlName();
+ getCsfy.isShouldLock();
+ getCsfy.isInTransaction();
+ getCsfy.getNodeName();
+ }
+
+ protected CsarInfo getCsarInfo ()
+ {
+ String csarUuid = "0010";
+ User user = new User();
+ Map<String, byte[]> csar = crateCsarFromPayload();
+ String vfReousrceName = "resouceName";
+ String mainTemplateName = "mainTemplateName";
+ String mainTemplateContent = getMainTemplateContent();
+ final Service service = createServiceObject(false);
+ CsarInfo csarInfo = new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
+ return csarInfo;
+ }
+
+ protected Map<String, byte[]> crateCsarFromPayload() {
+ String payloadName = "valid_vf.csar";
+ byte[] data = new byte[1024];
+ Map<String, byte[]> returnValue = new HashMap<>();
+ returnValue.put(payloadName,data);
+
+ return returnValue;
+ }
+
+ protected String getGroupsYaml(){
+ return "zxjTestImportServiceAb 0:\n" +
+ " type: org.openecomp.resource.vf.Zxjtestimportserviceab\n" +
+ " metadata:\n" +
+ " invariantUUID: 41474f7f-3195-443d-a0a2-eb6020a56279\n" +
+ " UUID: 92e32e49-55f8-46bf-984d-a98c924037ec\n" +
+ " customizationUUID: 40286158-96d0-408e-9f27-21d43817d37c\n" +
+ " version: '1.0'\n" +
+ " name: zxjTestImportServiceAb\n" +
+ " description: zxjTestImportServiceAbstract\n" +
+ " type: VF\n" +
+ " category: Generic\n" +
+ " subcategory: Abstract\n" +
+ " resourceVendor: zxjImportService\n" +
+ " resourceVendorRelease: '1.0'\n" +
+ " resourceVendorModelNumber: ''\n" +
+ " properties:\n" +
+ " skip_post_instantiation_configuration: true\n" +
+ " nf_naming:\n" +
+ " ecomp_generated_naming: true\n" +
+ " multi_stage_design: 'false'\n" +
+ " controller_actor: SO-REF-DATA\n" +
+ " availability_zone_max_count: 1\n" +
+ " requirements:\n" +
+ " - imagefile.dependency:\n" +
+ " capability: feature\n" +
+ " node: ext ZTE VL 0\n" +
+ " - mme_ipu_vdu.dependency:\n" +
+ " capability: feature\n" +
+ " node: ExtCP 0\n" +
+ " capabilities:\n" +
+ " mme_ipu_vdu.scalable:\n" +
+ " properties:\n" +
+ " max_instances: 1\n" +
+ " min_instances: 1\n" +
+ " mme_ipu_vdu.nfv_compute:\n" +
+ " properties:\n" +
+ " num_cpus: '2'\n" +
+ " flavor_extra_specs: {\n" +
+ " }\n" +
+ " mem_size: '8192'";
+ }
+
+ protected String getYamlFileContent(){
+ return "tosca_definitions_version: tosca_simple_yaml_1_1\n" +
+ "imports:\n" +
+ "- data.yml\n" +
+ "group_types:\n" +
+ " tosca.groups.Root:\n" +
+ " description: The TOSCA Group Type all other TOSCA Group Types derive from\n" +
+ " interfaces:\n" +
+ " Standard:\n" +
+ " type: tosca.interfaces.node.lifecycle.Standard\n" +
+ " org.openecomp.groups.heat.HeatStack:\n" +
+ " derived_from: tosca.groups.Root\n" +
+ " description: Grouped all heat resources which are in the same heat stack\n" +
+ " properties:\n" +
+ " heat_file:\n" +
+ " type: string\n" +
+ " description: Heat file which associate to this group/heat stack\n" +
+ " required: true\n" +
+ " status: supported\n" +
+ " description:\n" +
+ " type: string\n" +
+ " description: group description\n" +
+ " required: true\n" +
+ " status: supported\n" +
+ " org.openecomp.groups.VfModule:\n" +
+ " derived_from: tosca.groups.Root\n" +
+ " description: Grouped all heat resources which are in the same VF Module\n" +
+ " properties:\n" +
+ " isBase:\n" +
+ " type: boolean\n" +
+ " description: Whether this module should be deployed before other modules\n" +
+ " required: true\n" +
+ " default: false\n" +
+ " status: supported\n" +
+ " vf_module_label:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: |\n" +
+ " Alternate textual key used to reference this VF-Module model. Must be unique within the VNF model\n" +
+ " vf_module_description:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: |\n" +
+ " Description of the VF-modules contents and purpose (e.g. \"Front-End\" or \"Database Cluster\")\n" +
+ " min_vf_module_instances:\n" +
+ " type: integer\n" +
+ " required: true\n" +
+ " description: The minimum instances of this VF-Module\n" +
+ " max_vf_module_instances:\n" +
+ " type: integer\n" +
+ " required: false\n" +
+ " description: The maximum instances of this VF-Module\n" +
+ " initial_count:\n" +
+ " type: integer\n" +
+ " required: false\n" +
+ " description: |\n" +
+ " The initial count of instances of the VF-Module. The value must be in the range between min_vfmodule_instances and max_vfmodule_instances. If no value provided the initial count is the min_vfmodule_instances.\n" +
+ " vf_module_type:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " constraint:\n" +
+ " - valid_values:\n" +
+ " - Base\n" +
+ " - Expansion\n" +
+ " volume_group:\n" +
+ " type: boolean\n" +
+ " required: true\n" +
+ " default: false\n" +
+ " description: |\n" +
+ " \"true\" indicates that this VF Module model requires attachment to a Volume Group. VID operator must select the Volume Group instance to attach to a VF-Module at deployment time.\n" +
+ " availability_zone_count:\n" +
+ " type: integer\n" +
+ " required: false\n" +
+ " description: |\n" +
+ " Quantity of Availability Zones needed for this VF-Module (source: Extracted from VF-Module HEAT template)\n" +
+ " vfc_list:\n" +
+ " type: map\n" +
+ " entry_schema:\n" +
+ " description: <vfc_id>:<count>\n" +
+ " type: string\n" +
+ " required: false\n" +
+ " description: |\n" +
+ " Identifies the set of VM types and their count included in the VF-Module\n" +
+ " org.openecomp.groups.NetworkCollection:\n" +
+ " derived_from: tosca.groups.Root\n" +
+ " description: groups l3-networks in network collection\n" +
+ " properties:\n" +
+ " network_collection_function:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: network collection function\n" +
+ " network_collection_description:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: network collection description, free format text\n" +
+ " org.openecomp.groups.VfcInstanceGroup:\n" +
+ " derived_from: tosca.groups.Root\n" +
+ " description: groups VFCs with same parent port role\n" +
+ " properties:\n" +
+ " vfc_instance_group_function:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: function of this VFC group\n" +
+ " vfc_parent_port_role:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: common role of parent ports of VFCs in this group\n" +
+ " network_collection_function:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: network collection function assigned to this group\n" +
+ " subinterface_role:\n" +
+ " type: string\n" +
+ " required: true\n" +
+ " description: common role of subinterfaces of VFCs in this group, criteria the group is created\n" +
+ " capabilities:\n" +
+ " vlan_assignment:\n" +
+ " type: org.openecomp.capabilities.VLANAssignment\n" +
+ " properties:\n" +
+ " vfc_instance_group_reference:\n" +
+ " type: string\n" +
+ " tosca.groups.nfv.PlacementGroup:\n" +
+ " derived_from: tosca.groups.Root\n" +
+ " description: PlacementGroup is used for describing the affinity or anti-affinity relationship applicable between the virtualization containers to be created based on different VDUs, or between internal VLs to be created based on different VnfVirtualLinkDesc(s)\n" +
+ " properties:\n" +
+ " description:\n" +
+ " type: string\n" +
+ " description: Human readable description of the group\n" +
+ " required: true\n" +
+ " members:\n" +
+ " - tosca.nodes.nfv.Vdu.Compute\n" +
+ " - tosca.nodes.nfv.VnfVirtualLink";
+ }
+
+ public String getMainTemplateContent(){
+ return "tosca_definitions_version: tosca_simple_yaml_1_1\n"
+ + "metadata:\n"
+ + " invariantUUID: 6d17f281-683b-4198-a676-0faeecdc9025\n"
+ + " UUID: bfeab6b4-199b-4a2b-b724-de416c5e9811\n"
+ + " name: ser09080002\n"
+ + " description: ser09080002\n"
+ + " type: Service\n"
+ + " category: E2E Service\n"
+ + " serviceType: ''\n"
+ + " serviceRole: ''\n"
+ + " instantiationType: A-la-carte\n"
+ + " serviceEcompNaming: true\n"
+ + " ecompGeneratedNaming: true\n"
+ + " namingPolicy: ''\n"
+ + " environmentContext: General_Revenue-Bearing\n"
+ + " serviceFunction: ''\n"
+ + "imports:\n"
+ + "- nodes:\n"
+ + " file: nodes.yml\n"
+ + "- datatypes:\n"
+ + " file: data.yml\n"
+ + "- capabilities:\n"
+ + " file: capabilities.yml\n"
+ + "- relationships:\n"
+ + " file: relationships.yml\n"
+ + "- groups:\n"
+ + " file: groups.yml\n"
+ + "- policies:\n"
+ + " file: policies.yml\n"
+ + "- annotations:\n"
+ + " file: annotations.yml\n"
+ + "- service-ser09080002-interface:\n"
+ + " file: service-Ser09080002-template-interface.yml\n"
+ + "- resource-ExtCP:\n"
+ + " file: resource-Extcp-template.yml\n"
+ + "- resource-zxjTestImportServiceAb:\n"
+ + " file: resource-Zxjtestimportserviceab-template.yml\n"
+ + "- resource-zxjTestImportServiceAb-interface:\n"
+ + " file: resource-Zxjtestimportserviceab-template-interface.yml\n"
+ + "- resource-zxjTestServiceNotAbatract:\n"
+ + " file: resource-Zxjtestservicenotabatract-template.yml\n"
+ + "- resource-zxjTestServiceNotAbatract-interface:\n"
+ + " file: resource-Zxjtestservicenotabatract-template-interface.yml\n"
+ + "- resource-ext ZTE VL:\n"
+ + " file: resource-ExtZteVl-template.yml\n"
+ + "topology_template:\n"
+ + " inputs:\n"
+ + " skip_post_instantiation_configuration:\n"
+ + " default: true\n"
+ + " type: boolean\n"
+ + " required: false\n"
+ + " controller_actor:\n"
+ + " default: SO-REF-DATA\n"
+ + " type: string\n"
+ + " required: false\n"
+ + " cds_model_version:\n"
+ + " type: string\n"
+ + " required: false\n"
+ + " cds_model_name:\n"
+ + " type: string\n"
+ + " required: false\n"
+ + " node_templates:\n"
+ + " ext ZTE VL 0:\n"
+ + " type: tosca.nodes.nfv.ext.zte.VL\n"
+ + " metadata:\n"
+ + " invariantUUID: 27ab7610-1a97-4daa-938a-3b48e7afcfd0\n"
+ + " UUID: 9ea63e2c-4b8a-414f-93e3-5703ca5cee0d\n"
+ + " customizationUUID: e45e79b0-07ab-46b4-ac26-1e9f155ce53c\n"
+ + " version: '1.0'\n"
+ + " name: ext ZTE VL\n"
+ + " description: Ext ZTE VL\n"
+ + " type: VL\n"
+ + " category: Generic\n"
+ + " subcategory: Network Elements\n"
+ + " resourceVendor: ONAP (Tosca)\n"
+ + " resourceVendorRelease: 1.0.0.wd03\n"
+ + " resourceVendorModelNumber: ''\n"
+ + " zxjTestServiceNotAbatract 0:\n"
+ + " type: org.openecomp.resource.vf.Zxjtestservicenotabatract\n"
+ + " metadata:\n"
+ + " invariantUUID: ce39ce8d-6f97-4e89-8555-ae6789cdcf1c\n"
+ + " UUID: 4ac822be-f1ae-4ace-a4b8-bf6b5d977005\n"
+ + " customizationUUID: ee34e1e8-68e2-480f-8ba6-f257bbe90d6a\n"
+ + " version: '1.0'\n"
+ + " name: zxjTestServiceNotAbatract\n"
+ + " description: zxjTestServiceNotAbatract\n"
+ + " type: VF\n"
+ + " category: Network L4+\n"
+ + " subcategory: Common Network Resources\n"
+ + " resourceVendor: zxjImportService\n"
+ + " resourceVendorRelease: '1.0'\n"
+ + " resourceVendorModelNumber: ''\n"
+ + " properties:\n"
+ + " nf_naming:\n"
+ + " ecomp_generated_naming: true\n"
+ + " skip_post_instantiation_configuration: true\n"
+ + " multi_stage_design: 'false'\n"
+ + " controller_actor: SO-REF-DATA\n"
+ + " availability_zone_max_count: 1\n"
+ + " capabilities:\n"
+ + " mme_ipu_vdu.scalable:\n"
+ + " properties:\n"
+ + " max_instances: 1\n"
+ + " min_instances: 1\n"
+ + " mme_ipu_vdu.nfv_compute:\n"
+ + " properties:\n"
+ + " num_cpus: '2'\n"
+ + " flavor_extra_specs: {\n"
+ + " }\n"
+ + " mem_size: '8192'\n"
+ + " ExtCP 0:\n"
+ + " type: org.openecomp.resource.cp.extCP\n"
+ + " metadata:\n"
+ + " invariantUUID: 9b772728-93f5-424f-bb07-f4cae2783614\n"
+ + " UUID: 424ac220-4864-453e-b757-917fe4568ff8\n"
+ + " customizationUUID: 6e65d8a8-4379-4693-87aa-82f9e34b92fd\n"
+ + " version: '1.0'\n"
+ + " name: ExtCP\n"
+ + " description: The AT&T Connection Point base type all other CP derive from\n"
+ + " type: CP\n"
+ + " category: Generic\n"
+ + " subcategory: Network Elements\n"
+ + " resourceVendor: ONAP (Tosca)\n"
+ + " resourceVendorRelease: 1.0.0.wd03\n"
+ + " resourceVendorModelNumber: ''\n"
+ + " properties:\n"
+ + " mac_requirements:\n"
+ + " mac_count_required:\n"
+ + " is_required: false\n"
+ + " exCP_naming:\n"
+ + " ecomp_generated_naming: true\n"
+ + " zxjTestImportServiceAb 0:\n"
+ + " type: org.openecomp.resource.vf.Zxjtestimportserviceab\n"
+ + " metadata:\n"
+ + " invariantUUID: 41474f7f-3195-443d-a0a2-eb6020a56279\n"
+ + " UUID: 92e32e49-55f8-46bf-984d-a98c924037ec\n"
+ + " customizationUUID: 98c7a6c7-a867-45fb-8597-dd464f98e4aa\n"
+ + " version: '1.0'\n"
+ + " name: zxjTestImportServiceAb\n"
+ + " description: zxjTestImportServiceAbstract\n"
+ + " type: VF\n"
+ + " category: Generic\n"
+ + " subcategory: Abstract\n"
+ + " resourceVendor: zxjImportService\n"
+ + " resourceVendorRelease: '1.0'\n"
+ + " resourceVendorModelNumber: ''\n"
+ + " properties:\n"
+ + " nf_naming:\n"
+ + " ecomp_generated_naming: true\n"
+ + " skip_post_instantiation_configuration: true\n"
+ + " multi_stage_design: 'false'\n"
+ + " controller_actor: SO-REF-DATA\n"
+ + " availability_zone_max_count: 1\n"
+ + " requirements:\n"
+ + " - mme_ipu_vdu.dependency:\n"
+ + " capability: feature\n"
+ + " node: ExtCP 0\n"
+ + " - imagefile.dependency:\n"
+ + " capability: feature\n"
+ + " node: ext ZTE VL 0\n"
+ + " capabilities:\n"
+ + " mme_ipu_vdu.scalable:\n"
+ + " properties:\n"
+ + " max_instances: 1\n"
+ + " min_instances: 1\n"
+ + " mme_ipu_vdu.nfv_compute:\n"
+ + " properties:\n"
+ + " num_cpus: '2'\n"
+ + " flavor_extra_specs: {\n"
+ + " }\n"
+ + " mem_size: '8192'\n"
+ + " substitution_mappings:\n"
+ + " node_type: org.openecomp.service.Ser09080002\n"
+ + " capabilities:\n"
+ + " extcp0.feature:\n"
+ + " - ExtCP 0\n"
+ + " - feature\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.monitoring_parameter:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.monitoring_parameter\n"
+ + " zxjtestimportserviceab0.imagefile.guest_os:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - imagefile.guest_os\n"
+ + " zxjtestimportserviceab0.imagefile.feature:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - imagefile.feature\n"
+ + " zxjtestservicenotabatract0.imagefile.guest_os:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - imagefile.guest_os\n"
+ + " zxjtestimportserviceab0.ipu_cpd.feature:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - ipu_cpd.feature\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.virtualbinding:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.virtualbinding\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.feature:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.feature\n"
+ + " extztevl0.feature:\n"
+ + " - ext ZTE VL 0\n"
+ + " - feature\n"
+ + " zxjtestimportserviceab0.imagefile.image_fle:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - imagefile.image_fle\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.monitoring_parameter:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.monitoring_parameter\n"
+ + " zxjtestservicenotabatract0.ipu_cpd.feature:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - ipu_cpd.feature\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.nfv_compute:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.nfv_compute\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.scalable:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.scalable\n"
+ + " extcp0.internal_connectionPoint:\n"
+ + " - ExtCP 0\n"
+ + " - internal_connectionPoint\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.virtualbinding:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.virtualbinding\n"
+ + " zxjtestservicenotabatract0.imagefile.image_fle:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - imagefile.image_fle\n"
+ + " extztevl0.virtual_linkable:\n"
+ + " - ext ZTE VL 0\n"
+ + " - virtual_linkable\n"
+ + " zxjtestservicenotabatract0.imagefile.feature:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - imagefile.feature\n"
+ + " zxjtestimportserviceab0.localstorage.feature:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - localstorage.feature\n"
+ + " zxjtestservicenotabatract0.localstorage.local_attachment:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - localstorage.local_attachment\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.scalable:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.scalable\n"
+ + " zxjtestservicenotabatract0.localstorage.feature:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - localstorage.feature\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.nfv_compute:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.nfv_compute\n"
+ + " zxjtestimportserviceab0.localstorage.local_attachment:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - localstorage.local_attachment\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.feature:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.feature\n"
+ + " zxjtestimportserviceab0.ipu_cpd.forwarder:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - ipu_cpd.forwarder\n"
+ + " zxjtestservicenotabatract0.ipu_cpd.forwarder:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - ipu_cpd.forwarder\n"
+ + " requirements:\n"
+ + " zxjtestservicenotabatract0.imagefile.dependency:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - imagefile.dependency\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.local_storage:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.local_storage\n"
+ + " zxjtestservicenotabatract0.ipu_cpd.dependency:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - ipu_cpd.dependency\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.volume_storage:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.volume_storage\n"
+ + " zxjtestservicenotabatract0.ipu_cpd.virtualbinding:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - ipu_cpd.virtualbinding\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.dependency:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.dependency\n"
+ + " zxjtestservicenotabatract0.localstorage.dependency:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - localstorage.dependency\n"
+ + " zxjtestimportserviceab0.imagefile.dependency:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - imagefile.dependency\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.volume_storage:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.volume_storage\n"
+ + " zxjtestimportserviceab0.ipu_cpd.virtualbinding:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - ipu_cpd.virtualbinding\n"
+ + " extcp0.virtualLink:\n"
+ + " - ExtCP 0\n"
+ + " - virtualLink\n"
+ + " extcp0.virtualBinding:\n"
+ + " - ExtCP 0\n"
+ + " - virtualBinding\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.guest_os:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.guest_os\n"
+ + " extcp0.dependency:\n"
+ + " - ExtCP 0\n"
+ + " - dependency\n"
+ + " zxjtestimportserviceab0.localstorage.dependency:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - localstorage.dependency\n"
+ + " zxjtestservicenotabatract0.ipu_cpd.virtualLink:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - ipu_cpd.virtualLink\n"
+ + " extztevl0.dependency:\n"
+ + " - ext ZTE VL 0\n"
+ + " - dependency\n"
+ + " zxjtestimportserviceab0.ipu_cpd.dependency:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - ipu_cpd.dependency\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.dependency:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.dependency\n"
+ + " zxjtestimportserviceab0.mme_ipu_vdu.local_storage:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - mme_ipu_vdu.local_storage\n"
+ + " zxjtestimportserviceab0.ipu_cpd.virtualLink:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - ipu_cpd.virtualLink\n"
+ + " extcp0.external_virtualLink:\n"
+ + " - ExtCP 0\n"
+ + " - external_virtualLink\n"
+ + " zxjtestservicenotabatract0.mme_ipu_vdu.guest_os:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - mme_ipu_vdu.guest_os\n"
+ + " zxjtestimportserviceab0.ipu_cpd.forwarder:\n"
+ + " - zxjTestImportServiceAb 0\n"
+ + " - ipu_cpd.forwarder\n"
+ + " zxjtestservicenotabatract0.ipu_cpd.forwarder:\n"
+ + " - zxjTestServiceNotAbatract 0\n"
+ + " - ipu_cpd.forwarder\n";
+ }
+
+ protected void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat actualResponse = e.getResponseFormat() != null ?
+ e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ assertResponse(actualResponse, expectedStatus, variables);
+ }
+
+ protected void assertResponse(ResponseFormat actualResponse, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
+ assertEquals(expectedResponse.getStatus(), actualResponse.getStatus());
+ assertEquals("assert error description", expectedResponse.getFormattedMessage(), actualResponse.getFormattedMessage());
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportManagerTest.java
new file mode 100644
index 0000000000..16cc44f764
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportManagerTest.java
@@ -0,0 +1,95 @@
+/*
+
+ * Copyright (c) 2018 AT&T Intellectual Property.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
+
+package org.openecomp.sdc.be.components.impl;
+
+
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.UploadServiceInfo;
+
+
+
+public class ServiceImportManagerTest {
+ @InjectMocks
+ private ServiceImportManager serviceImportManager;
+
+ private ServiceImportManager createTestSubject() {
+ return new ServiceImportManager();
+ }
+
+ @Test
+ public void testGetServiceImportBusinessLogic() {
+ ServiceImportManager testSubject;
+ ServiceImportBusinessLogic result;
+
+ testSubject = createTestSubject();
+ result = testSubject.getServiceImportBusinessLogic();
+ }
+
+ @Test
+ public void testSetServiceImportBusinessLogic() {
+ ServiceImportManager testSubject;
+ ServiceImportBusinessLogic serviceImportBusinessLogic=null;
+
+ testSubject = createTestSubject();
+ testSubject.setServiceImportBusinessLogic(serviceImportBusinessLogic);
+ }
+
+
+ @Test
+ public void testGetServiceBusinessLogic() {
+ ServiceImportManager testSubject;
+ ServiceBusinessLogic result;
+
+ testSubject = createTestSubject();
+ result = testSubject.getServiceBusinessLogic();
+ }
+
+ @Test
+ public void testSetServiceBusinessLogic() {
+ ServiceImportManager testSubject;
+ ServiceBusinessLogic serviceBusinessLogic = null;
+
+ testSubject = createTestSubject();
+ testSubject.setServiceBusinessLogic(serviceBusinessLogic);
+ }
+
+ @Test
+ public void testPopulateServiceMetadata() {
+ UploadServiceInfo serviceMetaData = null;
+ Service service = null;
+ if (serviceMetaData != null || service != null) {
+ serviceImportManager.populateServiceMetadata(serviceMetaData, service);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
new file mode 100644
index 0000000000..18408dc913
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
@@ -0,0 +1,2152 @@
+/*
+ * Copyright (C) 2020 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.components.impl;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.RESOURCE_NAME;
+
+import fj.data.Either;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+
+import java.util.Map.Entry;
+import java.util.Set;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.MutablePair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.ElementOperationMock;
+import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.csar.CsarInfo;
+import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.UploadCapInfo;
+import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadPropInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
+import org.openecomp.sdc.be.model.UploadResourceInfo;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
+import org.openecomp.sdc.be.model.User;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.user.Role;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.util.ValidationUtils;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
+
+ ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+ ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
+ ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
+ IElementOperation elementDao = Mockito.mock(IElementOperation.class);
+ IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
+ InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
+
+ private static final String RESOURCE_NAME = "My-Resource_Name with space";
+ private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name";
+ private static final String GENERIC_ROOT_NAME = "tosca.nodes.Root";
+ private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
+ private static final String GENERIC_CR_NAME = "org.openecomp.resource.abstract.nodes.CR";
+ private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
+ private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
+ private static final String RESOURCE_SUBCATEGORY = "Router";
+
+ @InjectMocks
+ private ServiceImportParseLogic serviceImportParseLogic;
+ ResponseFormatManager responseManager = null;
+ User user = null;
+
+ private ServiceImportParseLogic createTestSubject() {
+ return new ServiceImportParseLogic();
+ }
+
+ ServiceImportParseLogic bl;
+
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ // Elements
+ mockElementDao = new ElementOperationMock();
+
+ // User data and management
+ user = new User();
+ user.setUserId("jh0003");
+ user.setFirstName("Jimmi");
+ user.setLastName("Hendrix");
+ user.setRole(Role.ADMIN.name());
+ responseManager = ResponseFormatManager.getInstance();
+
+ bl = new ServiceImportParseLogic();
+ bl.setComponentsUtils(componentsUtils);
+ bl.setToscaOperationFacade(toscaOperationFacade);
+ serviceBusinessLogic.setElementDao(elementDao);
+ bl.setServiceBusinessLogic(serviceBusinessLogic);
+ bl.setCapabilityTypeOperation(capabilityTypeOperation);
+ bl.setInterfaceTypeOperation(interfaceTypeOperation);
+ bl.setInputsBusinessLogic(inputsBusinessLogic);
+
+ }
+
+ @Test
+ public void testGetServiceBusinessLogic() {
+ ServiceImportParseLogic testSubject;
+ ServiceBusinessLogic result;
+
+ testSubject = createTestSubject();
+ result = testSubject.getServiceBusinessLogic();
+ }
+
+ @Test
+ public void testSetServiceBusinessLogic() {
+ ServiceImportParseLogic testSubject;
+ ServiceBusinessLogic serviceBusinessLogic = null;
+
+ testSubject = createTestSubject();
+ testSubject.setServiceBusinessLogic(serviceBusinessLogic);
+ }
+
+ @Test
+ public void testGetCapabilityTypeOperation() {
+ ServiceImportParseLogic testSubject;
+ ICapabilityTypeOperation result;
+
+ testSubject = createTestSubject();
+ result = testSubject.getCapabilityTypeOperation();
+ }
+
+ @Test
+ public void testSetCapabilityTypeOperation() {
+ ServiceImportParseLogic testSubject;
+ ICapabilityTypeOperation iCapabilityTypeOperation = null;
+
+ testSubject = createTestSubject();
+ testSubject.setCapabilityTypeOperation(iCapabilityTypeOperation);
+ }
+
+ private CsarInfo createCsarInfo() {
+ Map<String, byte[]> csar = new HashMap<>();
+ User user = new User();
+ CsarInfo csarInfo = new CsarInfo(user, "csar_UUID", csar, "vfResourceName", "mainTemplateName",
+ "mainTemplateContent", true);
+ csarInfo.setVfResourceName("vfResourceName");
+ csarInfo.setCsar(csar);
+ csarInfo.setCsarUUID("csarUUID");
+ csarInfo.setModifier(user);
+ csarInfo.setUpdate(true);
+ return csarInfo;
+ }
+
+ @Test
+ public void testFindNodeTypesArtifactsToHandle() {
+ ServiceImportParseLogic testSubject = createTestSubject();
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashedMap();
+ final Service service = createServiceObject(false);
+
+ bl.findNodeTypesArtifactsToHandle(
+ nodeTypesInfo, getCsarInfo(), service);
+ }
+
+ @Test
+ public void testBuildNodeTypeYaml() {
+ Map.Entry<String, Object> nodeNameValue = new Entry<String, Object>() {
+ @Override
+ public String getKey() {
+ return null;
+ }
+
+ @Override
+ public Object getValue() {
+ return null;
+ }
+
+ @Override
+ public Object setValue(Object value) {
+ return null;
+ }
+ };
+ Map<String, Object> mapToConvert = new HashMap<>();
+ String nodeResourceType = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX;
+
+ try {
+ bl.buildNodeTypeYaml(
+ nodeNameValue, mapToConvert, nodeResourceType, getCsarInfo());
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_TOSCA_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFindAddNodeTypeArtifactsToHandle() {
+
+ Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = new HashMap<>();
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ String namespace = "namespace";
+
+ ImmutablePair p1 = ImmutablePair.<String, String>of("s", "sd");
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashedMap();
+ final Service service = createServiceObject(false);
+ Resource resource = new Resource();
+ Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource);
+ when(toscaOperationFacade.getLatestByToscaResourceName(anyString()))
+ .thenReturn(getCompLatestResult);
+ try {
+ bl.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service,
+ extractedVfcsArtifacts, namespace, p1);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_TOSCA_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testHandleAndAddExtractedVfcsArtifacts() {
+
+ List<ArtifactDefinition> vfcArtifacts = new ArrayList<>();
+ List<ArtifactDefinition> artifactsToAdd = new ArrayList<>();
+ bl.handleAndAddExtractedVfcsArtifacts(vfcArtifacts, artifactsToAdd);
+ }
+
+ @Test
+ public void testFindNodeTypeArtifactsToHandle() {
+
+ Resource curNodeType = createParseResourceObject(true);
+ List<ArtifactDefinition> extractedArtifacts = new ArrayList<>();
+ bl.findNodeTypeArtifactsToHandle(curNodeType, extractedArtifacts);
+ }
+
+ @Test
+ public void testCollectExistingArtifacts() {
+
+ Resource curNodeType = createParseResourceObject(true);
+ bl.collectExistingArtifacts(curNodeType);
+ }
+
+ @Test
+ public void testPutFoundArtifacts() {
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ List<ArtifactDefinition> artifactsToUpload = new ArrayList<>();
+ artifactsToUpload.add(artifactDefinition);
+ List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
+ artifactsToUpdate.add(artifactDefinition);
+ List<ArtifactDefinition> artifactsToDelete = new ArrayList<>();
+ artifactsToDelete.add(artifactDefinition);
+ bl.putFoundArtifacts(artifactsToUpload, artifactsToUpdate, artifactsToDelete);
+ }
+
+ @Test
+ public void testProcessExistingNodeTypeArtifacts() {
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ List<ArtifactDefinition> extractedArtifacts = new ArrayList<>();
+ extractedArtifacts.add(artifactDefinition);
+ List<ArtifactDefinition> artifactsToUpload = new ArrayList<>();
+ artifactsToUpload.add(artifactDefinition);
+ List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
+ artifactsToUpdate.add(artifactDefinition);
+ List<ArtifactDefinition> artifactsToDelete = new ArrayList<>();
+ artifactsToDelete.add(artifactDefinition);
+ Map<String, ArtifactDefinition> existingArtifacts = new HashMap<>();
+ existingArtifacts.put("test", artifactDefinition);
+ try {
+ bl.processExistingNodeTypeArtifacts(extractedArtifacts, artifactsToUpload, artifactsToUpdate,
+ artifactsToDelete, existingArtifacts);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+
+ }
+
+ @Test
+ public void testProcessNodeTypeArtifact() {
+ List<ArtifactDefinition> artifactsToUpload = new ArrayList<>();
+ List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
+ Map<String, ArtifactDefinition> existingArtifacts = new HashMap<>();
+ ArtifactDefinition currNewArtifact = new ArtifactDefinition();
+ bl.processNodeTypeArtifact(artifactsToUpload, artifactsToUpdate, existingArtifacts, currNewArtifact);
+ }
+
+ @Test
+ public void testUpdateFoundArtifact() {
+ List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
+ ArtifactDefinition currNewArtifact = new ArtifactDefinition();
+ currNewArtifact.setArtifactChecksum("090909");
+ currNewArtifact.setPayloadData("data");
+ ArtifactDefinition foundArtifact = new ArtifactDefinition();
+ foundArtifact.setArtifactChecksum("08767");
+ bl.updateFoundArtifact(artifactsToUpdate, currNewArtifact, foundArtifact);
+ }
+
+ @Test
+ public void testIsArtifactDeletionRequired() {
+ String artifactId = "artifactId";
+ byte[] artifactFileBytes = new byte[100];
+ boolean isFromCsar = true;
+ bl.isArtifactDeletionRequired(artifactId, artifactFileBytes, isFromCsar);
+ }
+
+ @Test
+ public void testFillGroupsFinalFields() {
+ List<GroupDefinition> groupsAsList = new ArrayList<>();
+ bl.fillGroupsFinalFields(groupsAsList);
+ }
+
+ @Test
+ public void testGetComponentTypeForResponse() {
+ Resource resource = createParseResourceObject(true);
+ bl.getComponentTypeForResponse(resource);
+ }
+
+ @Test
+ public void testGetComponentTypeForResponseByService() {
+ Service service = createServiceObject(true);
+ bl.getComponentTypeForResponse(service);
+ }
+
+ @Test
+ public void testIsfillGroupMemebersRecursivlyStopCondition() {
+ String groupName = "groupName";
+ Map<String, GroupDefinition> allGroups = new HashMap<>();
+ Set<String> allGroupMembers = new HashSet<>();
+ bl.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers);
+ }
+
+ @Test
+ public void testIsfillGroupMemebersRecursivlyStopCondition2() {
+ String groupName = "groupName";
+ Map<String, GroupDefinition> allGroups = new HashMap<>();
+ GroupDefinition groupDefinition = new GroupDefinition();
+ Map<String, String> members = new HashMap<>();
+ members.put("members", "members");
+ groupDefinition.setMembers(members);
+ allGroups.put(groupName, groupDefinition);
+ Set<String> allGroupMembers = new HashSet<>();
+ bl.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers);
+ }
+
+ @Test
+ public void testBuildValidComplexVfc() {
+ Resource resource = createParseResourceObject(true);
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ List<String> derivedFrom = new ArrayList<>();
+ derivedFrom.add("derivedFrom");
+ nodeTypeInfo.setDerivedFrom(derivedFrom);
+ nodesInfo.put(nodeName, nodeTypeInfo);
+
+ try {
+ bl.buildValidComplexVfc(resource, getCsarInfo(), nodeName, nodesInfo);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateResourceBeforeCreate() {
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.getServiceBusinessLogic().setElementDao(elementDao);
+ bl.validateResourceBeforeCreate(resource, user, AuditingActionEnum.IMPORT_RESOURCE,false, getCsarInfo());
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+
+ }
+
+ @Test
+ public void testValidateResourceType() {
+ Resource resource = createParseResourceObject(true);
+ bl.validateResourceType( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ }
+
+ @Test
+ public void testValidateResourceTypeIsEmpty() {
+ Resource resource = new Resource();
+ resource.setResourceType(null);
+ bl.validateResourceType(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ }
+
+ @Test
+ public void testValidateLifecycleTypesCreate() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, InterfaceDefinition> mapInterfaces = new HashMap<>();
+ InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ String uniqueId = "01932342212";
+ interfaceDefinition.setUniqueId(uniqueId);
+ mapInterfaces.put("uniqueId", interfaceDefinition);
+ resource.setInterfaces(mapInterfaces);
+ when(interfaceTypeOperation.getInterface(anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ bl.validateLifecycleTypesCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ }
+
+ @Test
+ public void testValidateCapabilityTypesCreate() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ String uniqueId = "18982938994";
+ List<CapabilityDefinition> capabilityDefinitionList= new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilities.put(uniqueId, capabilityDefinitionList);
+ resource.setCapabilities(capabilities);
+ when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
+ thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ try {
+ bl.validateCapabilityTypesCreate(user, bl.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_TOSCA_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateCapabilityTypesCreateWhenHaveCapability() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ String uniqueId = "18982938994";
+ List<CapabilityDefinition> capabilityDefinitionList= new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilities.put(uniqueId, capabilityDefinitionList);
+ resource.setCapabilities(capabilities);
+ CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition();
+ when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
+ thenReturn(Either.left(capabilityTypeDefinition));
+ try {
+ bl.validateCapabilityTypesCreate(user, bl.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_TOSCA_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateCapabilityTypeExists() {
+ Resource resource = createParseResourceObject(true);
+ Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
+ for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
+
+ bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE,
+ eitherResult, typeEntry, false);
+ }
+ }
+
+ @Test
+ public void testValidateCapabilityTypeExistsWhenPropertiesIsNull() {
+ Resource resource = createParseResourceObject(true);
+ Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
+ CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition();
+
+ String uniqueId = "0987348532";
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+ properties.put(uniqueId, propertyDefinition);
+ capabilityTypeDefinition.setProperties(properties);
+
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilities.put(uniqueId, capabilityDefinitionList);
+ resource.setCapabilities(capabilities);
+
+ when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
+ thenReturn(Either.left(capabilityTypeDefinition));
+ for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
+
+ bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE,
+ eitherResult, typeEntry, false);
+ }
+ }
+
+ @Test
+ public void testValidateCapabilityTypeExistsWhenPropertiesNotNull() {
+ Resource resource = createParseResourceObject(true);
+ Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
+ CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition();
+
+ String uniqueId = "0987348532";
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setName(uniqueId);
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+ properties.put(uniqueId, propertyDefinition);
+ capabilityTypeDefinition.setProperties(properties);
+
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+
+
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ List<ComponentInstanceProperty> componentInstancePropertyList = new ArrayList<>();
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
+ componentInstanceProperty.setValueUniqueUid(uniqueId);
+ componentInstanceProperty.setName(uniqueId);
+ componentInstancePropertyList.add(componentInstanceProperty);
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setProperties(componentInstancePropertyList);
+ capabilityDefinitionList.add(capabilityDefinition);
+
+ capabilities.put(uniqueId, capabilityDefinitionList);
+ resource.setCapabilities(capabilities);
+
+
+ when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
+ thenReturn(Either.left(capabilityTypeDefinition));
+ for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
+
+ bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE,
+ eitherResult, typeEntry, false);
+ }
+ }
+
+ @Test
+ public void testValidateCapabilityTypeExists2() {
+ Resource resource = createParseResourceObject(true);
+ Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
+ when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
+ thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ try {
+ for (String type : resource.getRequirements().keySet()) {
+ bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
+ resource.getRequirements().get(type), AuditingActionEnum.IMPORT_RESOURCE, eitherResult, type,
+ false);
+ }
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_TOSCA_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+
+
+ }
+
+ @Test
+ public void testValidateResourceFieldsBeforeCreate() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ bl.validateResourceFieldsBeforeCreate( user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateDerivedFromExist() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
+ .thenReturn(Either.left(true));
+ bl.validateDerivedFromExist( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateDerivedFromExistFailure1() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
+ .thenReturn(Either.left(false));
+ bl.validateDerivedFromExist( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.PARENT_RESOURCE_NOT_FOUND,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateDerivedFromExistFailure2() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
+ .thenReturn(Either.right(StorageOperationStatus.OK));
+ bl.validateDerivedFromExist( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.OK,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateLicenseType() {
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.validateLicenseType( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_CONTENT,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+
+
+ }
+
+ @Test
+ public void testValidateCost() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ bl.validateCost( resource);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_CONTENT,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateResourceVendorModelNumber() {
+ Resource resource = createParseResourceObject(true);
+ bl.validateResourceVendorModelNumber( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ }
+
+ @Test
+ public void testValidateResourceVendorModelNumberWrongLen() {
+ Resource resource = createParseResourceObject(true);
+ resource.setResourceVendorModelNumber("000000000011122221111222333444443222556677788778889999998776554332340");
+ try {
+ bl.validateResourceVendorModelNumber( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateResourceVendorModelNumberWrongValue() {
+ Resource resource = createParseResourceObject(true);
+ resource.setResourceVendorModelNumber("");
+ try {
+ bl.validateResourceVendorModelNumber( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateVendorReleaseName() {
+ Resource resource = createParseResourceObject(true);
+ resource.setVendorRelease("0.1");
+ bl.validateVendorReleaseName( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ }
+
+ @Test
+ public void testValidateVendorReleaseNameFailure() {
+ Resource resource = createParseResourceObject(true);
+ resource.setVendorRelease("");
+ try {
+ bl.validateVendorReleaseName( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.MISSING_VENDOR_RELEASE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+
+ }
+
+ @Test
+ public void testValidateVendorReleaseNameWrongLen() {
+ Resource resource = createParseResourceObject(true);
+ resource.setVendorRelease("000000000011122221111222333444443222556677788778889999998776554332340");
+ try {
+ bl.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateCategory() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ bl.validateCategory( user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateEmptyCategory() {
+ Resource resource = createParseResourceObject(true);
+ resource.setCategories(null);
+ try {
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_MISSING_CATEGORY,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateCategorySizeBiggerThan1() {
+ Resource resource = createParseResourceObject(true);
+ List<CategoryDefinition> categories = new ArrayList<>();
+ CategoryDefinition categoryDefinition1 = new CategoryDefinition();
+ CategoryDefinition categoryDefinition2 = new CategoryDefinition();
+ categories.add(categoryDefinition1);
+ categories.add(categoryDefinition2);
+
+ resource.setCategories(categories);
+ try {
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_TOO_MUCH_CATEGORIES,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateEmptySubCategory() {
+ Resource resource = createParseResourceObject(true);
+ List<CategoryDefinition> categories = resource.getCategories();
+ CategoryDefinition categoryDefinition = categories.get(0);
+ categoryDefinition.setSubcategories(null);
+
+ try {
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_MISSING_SUBCATEGORY,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateEmptySubCategorySizeBiggerThan1() {
+ Resource resource = createParseResourceObject(true);
+ List<CategoryDefinition> categories = resource.getCategories();
+ CategoryDefinition categoryDefinition = categories.get(0);
+ List<SubCategoryDefinition> subcategories = categoryDefinition.getSubcategories();
+ SubCategoryDefinition subCategoryDefinition1 = new SubCategoryDefinition();
+ SubCategoryDefinition subCategoryDefinition2 = new SubCategoryDefinition();
+ subcategories.add(subCategoryDefinition1);
+ subcategories.add(subCategoryDefinition2);
+
+ try {
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.RESOURCE_TOO_MUCH_SUBCATEGORIES,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateEmptyCategoryName() {
+ Resource resource = createParseResourceObject(true);
+ List<CategoryDefinition> categories = resource.getCategories();
+ CategoryDefinition categoryDefinition = categories.get(0);
+ categoryDefinition.setName(null);
+
+ try {
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_MISSING_CATEGORY,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateEmptySubCategoryName() {
+ Resource resource = createParseResourceObject(true);
+ List<CategoryDefinition> categories = resource.getCategories();
+ CategoryDefinition categoryDefinition = categories.get(0);
+ List<SubCategoryDefinition> subcategories = categoryDefinition.getSubcategories();
+ SubCategoryDefinition subCategoryDefinition1 = subcategories.get(0);
+ subCategoryDefinition1.setName(null);
+
+ try {
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_MISSING_SUBCATEGORY,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateCategoryListed() {
+ Resource resource = createParseResourceObject(true);
+ CategoryDefinition category = resource.getCategories().get(0);
+ SubCategoryDefinition subcategory = category.getSubcategories().get(0);
+ try {
+ bl.validateCategoryListed( category, subcategory, user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFailOnInvalidCategory() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ bl.failOnInvalidCategory( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_INVALID_CATEGORY,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+
+ }
+
+ @Test
+ public void testValidateVendorName() {
+ Resource resource = createParseResourceObject(true);
+ try {
+ bl.validateVendorName( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateVendorNameEmpty() {
+ Resource resource = createParseResourceObject(true);
+ resource.setVendorName(null);
+ try {
+ bl.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.MISSING_VENDOR_NAME,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateVendorNameWrongLen() {
+ Resource resource = createParseResourceObject(true);
+ resource.setVendorName("000000000011122221111222333444443222556677788778889999998776554332340");
+ try {
+ bl.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testValidateVendorName2() {
+ Resource resource = createParseResourceObject(true);
+ CategoryDefinition category = resource.getCategories().get(0);
+ SubCategoryDefinition subcategory = category.getSubcategories().get(0);
+ String vendorName = "vendorName";
+ try {
+ bl.validateVendorName( vendorName, user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFillResourceMetadata2() {
+ String yamlName = "yamlName";
+ Resource resourceVf = createParseResourceObject(true);
+ String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "test";
+ resourceVf.setSystemName("systemName");
+ try {
+ bl.fillResourceMetadata( yamlName, resourceVf, nodeName, user);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testFillResourceMetadataWrongStart() {
+ String yamlName = "yamlName";
+ Resource resourceVf = createParseResourceObject(true);
+ String nodeName = "WrongStart" + "test";
+ try {
+ bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testFillResourceMetadataResourceTypeIsAbs() {
+ String yamlName = "yamlName";
+ Resource resourceVf = createParseResourceObject(true);
+ String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + Constants.ABSTRACT;
+ try {
+ bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_NODE_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testGetNodeTypeActualName() {
+ String fullName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX+"test";
+ try {
+ bl.getNodeTypeActualName(fullName);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testAddInput() {
+ Map<String, InputDefinition> currPropertiesMap = new HashMap<>();
+ InputDefinition prop = new InputDefinition();
+ try {
+ bl.addInput(currPropertiesMap, prop);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFindAviableRequirement() {
+ String uniqueId = "101929382910";
+ String regName = uniqueId;
+ String yamlName = uniqueId;
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ ComponentInstance currentCompInstance = new ComponentInstance();
+
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ List<RequirementDefinition> requirementDefinitionList = new ArrayList<>();
+ RequirementDefinition requirementDefinition = new RequirementDefinition();
+ requirementDefinition.setName(uniqueId);
+ requirementDefinition.setMaxOccurrences("10");
+ requirementDefinition.setLeftOccurrences("3");
+ requirementDefinitionList.add(requirementDefinition);
+ requirements.put(uniqueId, requirementDefinitionList);
+ currentCompInstance.setRequirements(requirements);
+
+ String capName = "capName";
+ try {
+ bl.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_NODE_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFindAviableRequirementSameCapName() {
+ String uniqueId = "101929382910";
+ String regName = uniqueId;
+ String yamlName = uniqueId;
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ ComponentInstance currentCompInstance = new ComponentInstance();
+
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ List<RequirementDefinition> requirementDefinitionList = new ArrayList<>();
+ RequirementDefinition requirementDefinition = new RequirementDefinition();
+ requirementDefinition.setName(uniqueId);
+ requirementDefinition.setMaxOccurrences("10");
+ requirementDefinition.setLeftOccurrences("3");
+ requirementDefinitionList.add(requirementDefinition);
+ requirements.put(uniqueId, requirementDefinitionList);
+ currentCompInstance.setRequirements(requirements);
+
+ String capName = uniqueId;
+ try {
+ bl.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.INVALID_NODE_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFindAvailableCapabilityByTypeOrName() {
+ RequirementDefinition validReq = new RequirementDefinition();
+ ComponentInstance currentCapCompInstance = new ComponentInstance();
+ UploadReqInfo uploadReqInfo = new UploadReqInfo();
+
+ try {
+ bl.findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadReqInfo);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+
+ @Test
+ public void testFindAvailableCapability() {
+ String uniqueId = "23422345677";
+ RequirementDefinition validReq = new RequirementDefinition();
+ validReq.setCapability(uniqueId);
+ ComponentInstance instance = new ComponentInstance();
+ Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setMaxOccurrences("3");
+ capabilityDefinition.setLeftOccurrences("2");
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilityMap.put(uniqueId, capabilityDefinitionList);
+ instance.setCapabilities(capabilityMap);
+
+ try {
+ bl.findAvailableCapability(validReq, instance);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testfindAvailableCapability2() {
+ String uniqueId = "23422345677";
+ RequirementDefinition validReq = new RequirementDefinition();
+ validReq.setCapability(uniqueId);
+ ComponentInstance instance = new ComponentInstance();
+ Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setName(uniqueId);
+ capabilityDefinition.setMaxOccurrences("3");
+ capabilityDefinition.setLeftOccurrences("2");
+ capabilityDefinitionList.add(capabilityDefinition);
+ capabilityMap.put(uniqueId, capabilityDefinitionList);
+ instance.setCapabilities(capabilityMap);
+ UploadReqInfo uploadReqInfo = new UploadReqInfo();
+ uploadReqInfo.setCapabilityName(uniqueId);
+ try {
+ bl.findAvailableCapability(validReq, instance, uploadReqInfo);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testGetComponentWithInstancesFilter() {
+ try {
+ bl.getComponentWithInstancesFilter();
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testCreateParseResourceObject() {
+ String key = "0923928394";
+ List<UploadCapInfo> capabilities = new ArrayList<>();
+ UploadCapInfo uploadCapInfo = new UploadCapInfo();
+ uploadCapInfo.setType(key);
+ capabilities.add(uploadCapInfo);
+
+ String resourceId = "resourceId";
+ Map<String, List<CapabilityDefinition>> defaultCapabilities = new HashMap<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setName(key);
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ capabilityDefinitionList.add(capabilityDefinition);
+ defaultCapabilities.put(key, capabilityDefinitionList);
+
+ Map<String, List<CapabilityDefinition>> validCapabilitiesMap = new HashMap<>();
+ InputDefinition prop = new InputDefinition();
+
+ Resource resource = createParseResourceObject(true);
+ Map<String, List<CapabilityDefinition>> capabilitiesMap = resource.getCapabilities();
+ capabilitiesMap.put(key, capabilityDefinitionList);
+
+ when(toscaOperationFacade.getToscaFullElement(anyString()))
+ .thenReturn(Either.left(resource));
+
+ try {
+ bl.addValidComponentInstanceCapabilities(key, capabilities, resourceId, defaultCapabilities,
+ validCapabilitiesMap);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testGetCapabilityFailure() {
+ String resourceId = "resourceId";
+ String key = "0923928394";
+ Map<String, List<CapabilityDefinition>> defaultCapabilities = new HashMap<>();
+ CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
+ capabilityDefinition.setName(key);
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
+ capabilityDefinitionList.add(capabilityDefinition);
+ defaultCapabilities.put(key, capabilityDefinitionList);
+ String capabilityType = key;
+ when(toscaOperationFacade.getToscaFullElement(anyString()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ try {
+ bl.getCapability(resourceId, defaultCapabilities, capabilityType);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_NOT_FOUND,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+
+ @Test
+ public void testValidateCapabilityProperties() {
+ List<UploadCapInfo> capabilities = new ArrayList<>();
+ UploadCapInfo uploadCapInfo = new UploadCapInfo();
+ List<UploadPropInfo> properties = new ArrayList<>();
+ UploadPropInfo uploadPropInfo = new UploadPropInfo();
+ properties.add(uploadPropInfo);
+ uploadCapInfo.setProperties(properties);
+ capabilities.add(uploadCapInfo);
+ String resourceId = "resourceId";
+ CapabilityDefinition defaultCapability = new CapabilityDefinition();
+ defaultCapability.setProperties(null);
+ defaultCapability.setName("test");
+
+ try {
+ bl.validateCapabilityProperties(capabilities, resourceId, defaultCapability);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateUniquenessUpdateUploadedComponentInstanceCapability() {
+ String key = "02124568";
+ List<UploadCapInfo> capabilities = new ArrayList<>();
+ UploadCapInfo uploadCapInfo = new UploadCapInfo();
+ List<UploadPropInfo> properties = new ArrayList<>();
+ UploadPropInfo uploadPropInfo = new UploadPropInfo();
+ uploadPropInfo.setName(key);
+ properties.add(uploadPropInfo);
+ uploadCapInfo.setProperties(properties);
+ capabilities.add(uploadCapInfo);
+ String resourceId = "resourceId";
+ CapabilityDefinition defaultCapability = new CapabilityDefinition();
+ List<ComponentInstanceProperty> componentInstancePropertyList = new ArrayList<>();
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
+ componentInstancePropertyList.add(componentInstanceProperty);
+ defaultCapability.setProperties(componentInstancePropertyList);
+ defaultCapability.setName(key);
+
+ try {
+ bl.validateUniquenessUpdateUploadedComponentInstanceCapability(defaultCapability, uploadCapInfo);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testSetDeploymentArtifactsPlaceHolderByResource() {
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.setDeploymentArtifactsPlaceHolder(resource, user);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testSetDeploymentArtifactsPlaceHolderByService() {
+ Service Service = createServiceObject(true);
+
+ try {
+ bl.setDeploymentArtifactsPlaceHolder(Service, user);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testProcessDeploymentResourceArtifacts() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, ArtifactDefinition> artifactMap = new HashMap<>();
+ String k = "key";
+ Object v = new Object();
+ try {
+ bl.processDeploymentResourceArtifacts(user, resource, artifactMap, k, v);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testMergeOldResourceMetadataWithNew() {
+ Resource oldResource = createParseResourceObject(true);
+ Resource newResource = new Resource();
+
+ try {
+ bl.mergeOldResourceMetadataWithNew(oldResource, newResource);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testBuildComplexVfcMetadata() {
+ Resource resource = createParseResourceObject(true);
+ String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ List<String> derivedFrom = new ArrayList<>();
+ derivedFrom.add("derivedFrom");
+ nodeTypeInfo.setDerivedFrom(derivedFrom);
+ nodesInfo.put(nodeName, nodeTypeInfo);
+
+ try {
+ bl.buildComplexVfcMetadata(getCsarInfo(), nodeName, nodesInfo);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateResourceCreationFromNodeType() {
+ Resource resource = createParseResourceObject(true);
+ resource.setDerivedFrom(null);
+ try {
+ bl.validateResourceCreationFromNodeType(resource, user);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testCreateInputsOnResource() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, InputDefinition> inputs = new HashMap<>();
+
+ try {
+ bl.createInputsOnResource(resource, inputs);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testCreateInputsOnResourceWhenIsNotEmpty() {
+ String key = "12345667";
+ Resource resource = createParseResourceObject(true);
+ List<InputDefinition> inputDefinitionList = new ArrayList<>();
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinitionList.add(inputDefinition);
+ resource.setInputs(inputDefinitionList);
+ Map<String, InputDefinition> inputs = new HashMap<>();
+ inputs.put(key, inputDefinition);
+
+ try {
+ bl.createInputsOnResource(resource, inputs);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateInputsOnService() {
+ Service service = createServiceObject(true);
+ Map<String, InputDefinition> inputs = new HashMap<>();
+
+ try {
+ bl.createInputsOnService(service, inputs);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateServiceTransaction() {
+ Service service = createServiceObject(true);
+
+ try {
+ bl.createServiceTransaction(service, user, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateArtifactsPlaceHolderData() {
+ Service service = createServiceObject(true);
+
+ try {
+ bl.createArtifactsPlaceHolderData(service, user);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSetInformationalArtifactsPlaceHolder() {
+ Service service = createServiceObject(true);
+
+ try {
+ bl.setInformationalArtifactsPlaceHolder(service, user);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateNestedDerivedFromDuringUpdate() {
+ Resource currentResource = createParseResourceObject(true);
+ Resource updateInfoResource = createParseResourceObject(true);
+ String key = "2323456";
+
+ List<String> currentDerivedFromList = new ArrayList<>();
+ currentDerivedFromList.add(key);
+ currentResource.setDerivedFrom(currentDerivedFromList);
+ List<String> updatedDerivedFromList = new ArrayList<>();
+ updatedDerivedFromList.add("23344567778");
+ updateInfoResource.setDerivedFrom(updatedDerivedFromList);
+
+ when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+
+ try {
+ bl.validateNestedDerivedFromDuringUpdate(currentResource, updateInfoResource, true);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateDerivedFromExtending() {
+ Resource currentResource = createParseResourceObject(true);
+ Resource updateInfoResource = createParseResourceObject(true);
+
+ when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
+ .thenReturn(Either.left(false));
+ try {
+ bl.validateDerivedFromExtending(user, currentResource, updateInfoResource,
+ AuditingActionEnum.IMPORT_RESOURCE);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.PARENT_RESOURCE_DOES_NOT_EXTEND,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testValidateResourceFieldsBeforeUpdate() {
+ Resource currentResource = createParseResourceObject(true);
+ Resource updateInfoResource = createParseResourceObject(true);
+
+ try {
+ bl.validateResourceFieldsBeforeUpdate(currentResource, updateInfoResource, true, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateResourceName() {
+ Resource currentResource = createParseResourceObject(true);
+ Resource updateInfoResource = createParseResourceObject(true);
+ currentResource.setName("test1");
+ updateInfoResource.setName("test2");
+
+ try {
+ bl.validateResourceName(currentResource, updateInfoResource, true, false);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testIsResourceNameEquals() {
+ Resource currentResource = createParseResourceObject(true);
+ Resource updateInfoResource = createParseResourceObject(true);
+
+ try {
+ bl.isResourceNameEquals(currentResource, updateInfoResource);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testPrepareResourceForUpdate() {
+ Resource oldResource = createParseResourceObject(true);
+ Resource newResource = createParseResourceObject(true);
+
+ try {
+ bl.prepareResourceForUpdate(oldResource, newResource, user, true, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testFailOnChangeState() {
+ ResponseFormat response = new ResponseFormat();
+ Resource oldResource = createParseResourceObject(true);
+ Resource newResource = createParseResourceObject(true);
+
+ try {
+ bl.failOnChangeState(response, user, oldResource, newResource);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHandleResourceGenericType() {
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.handleResourceGenericType(resource);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUpdateOrCreateGroups() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+
+ try {
+ bl.updateOrCreateGroups(resource, groups);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddGroupsToCreateOrUpdate() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+
+ List<GroupDefinition> groupsFromResource = new ArrayList<>();
+ List<GroupDefinition> groupsAsList = new ArrayList<>();
+ List<GroupDefinition> groupsToUpdate = new ArrayList<>();
+ List<GroupDefinition> groupsToCreate = new ArrayList<>();
+
+ try {
+ bl.addGroupsToCreateOrUpdate(groupsFromResource, groupsAsList, groupsToUpdate, groupsToCreate);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAddGroupsToDelete() {
+ Map<String, GroupDefinition> groups = new HashMap<>();
+
+ List<GroupDefinition> groupsFromResource = new ArrayList<>();
+ List<GroupDefinition> groupsAsList = new ArrayList<>();
+ List<GroupDefinition> groupsToDelete = new ArrayList<>();
+
+ try {
+ bl.addGroupsToDelete(groupsFromResource, groupsAsList, groupsToDelete);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUpdateGroupsMembersUsingResource() {
+ Service component = createServiceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+
+ try {
+ bl.updateGroupsMembersUsingResource(groups, component);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testupdateGroupMembers() {
+ Service component = createServiceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+ GroupDefinition updatedGroupDefinition = new GroupDefinition();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ String groupName = "groupName";
+ Map<String, String> members = new HashMap<>();
+
+ try {
+ bl.updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members);
+ } catch (ComponentException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateCyclicGroupsDependencies() {
+ Service component = createServiceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+ String key = "098738485";
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groups.put(key, groupDefinition);
+
+ try {
+ bl.validateCyclicGroupsDependencies(groups);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.GENERAL_ERROR,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ @Test
+ public void testFillAllGroupMemebersRecursivly() {
+ Map<String, GroupDefinition> allGroups = new HashMap<>();
+ Set<String> allGroupMembers = new HashSet<>();
+ String groupName = "groupName";
+
+ try {
+ bl.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testFillResourceMetadataForService() {
+ String yamlName = "yamlName";
+ Service resourceVf = createServiceObject(true);
+ String nodeName = "nodeName";
+
+ try {
+ bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testpropagateStateToCertified() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
+
+ try {
+ bl.propagateStateToCertified(user, resource, lifecycleChangeInfo, true, true, true);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testBuildValidComplexVfc2() {
+ String nodeName = "nodeName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
+
+ try {
+ bl.buildValidComplexVfc(getCsarInfo(), nodeName, nodesInfo);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testUpdateGroupsOnResource() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+
+ try {
+ bl.updateGroupsOnResource(resource, groups);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testSetInformationalArtifactsPlaceHolder2() {
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.setInformationalArtifactsPlaceHolder(resource, user);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testCreateArtifactsPlaceHolderData2() {
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.createArtifactsPlaceHolderData(resource, user);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testHandleGroupsProperties() {
+ Service service = createServiceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+ try {
+ bl.handleGroupsProperties(service, groups);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testHandleGroupsProperties2() {
+ Resource resource = createParseResourceObject(true);
+ Map<String, GroupDefinition> groups = new HashMap<>();
+ try {
+ bl.handleGroupsProperties(resource, groups);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testHandleGetInputs() {
+ PropertyDataDefinition property = new PropertyDataDefinition();
+ List<InputDefinition> inputs = new ArrayList<>();
+ try {
+ bl.handleGetInputs(property, inputs);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testFindInputByName() {
+ GetInputValueDataDefinition getInput = new GetInputValueDataDefinition();
+ List<InputDefinition> inputs = new ArrayList<>();
+ try {
+ bl.findInputByName(inputs, getInput);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateComponentInstancePropertiesToComponent() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
+ List<InputDefinition> inputs = new ArrayList<>();
+ try {
+ bl.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateComponentInstanceInputsToComponent() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+
+ try {
+ bl.associateComponentInstanceInputsToComponent(yamlName, resource, instInputs);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateDeploymentArtifactsToInstances() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
+
+ try {
+ bl.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateArtifactsToInstances() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
+
+ try {
+ bl.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateArtifactsToInstances2() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
+
+ try {
+ bl.associateArtifactsToInstances(yamlName, resource, instDeploymentArtifacts);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateOrAddCalculatedCapReq() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
+ try {
+ bl.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateInstAttributeToComponentToInstances() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ try {
+ bl.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testThrowComponentExceptionByResource() {
+ StorageOperationStatus status = StorageOperationStatus.OK;
+ Resource resource = createParseResourceObject(true);
+ try {
+ bl.throwComponentExceptionByResource(status, resource);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testGetResourceAfterCreateRelations() {
+
+ Resource resource = createParseResourceObject(true);
+
+ try {
+ bl.getResourceAfterCreateRelations(resource);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testSetCapabilityNamesTypes() {
+
+ Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
+ Map<String, List<UploadCapInfo>> uploadedCapabilities = new HashMap<>();
+
+ try {
+ bl.setCapabilityNamesTypes(originCapabilities, uploadedCapabilities);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateComponentInstanceInputsToComponent2() {
+ String yamlName = "yamlName";
+ Service service = createServiceObject(true);
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+
+ try {
+ bl.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateComponentInstancePropertiesToComponent2() {
+ String yamlName = "yamlName";
+ Service service = createServiceObject(true);
+ Map<String, List<ComponentInstanceProperty>> instInputs = new HashMap<>();
+
+ try {
+ bl.associateComponentInstancePropertiesToComponent(yamlName, service, instInputs);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateDeploymentArtifactsToInstances2() {
+ String yamlName = "yamlName";
+ Service service = createServiceObject(true);
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
+
+ try {
+ bl.associateDeploymentArtifactsToInstances(user, yamlName, service, instDeploymentArtifacts);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateArtifactsToInstances3() {
+ String yamlName = "yamlName";
+ Service service = createServiceObject(true);
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
+
+ try {
+ bl.associateArtifactsToInstances(yamlName, service, instArtifacts);
+ } catch (Exception e) {
+
+ }
+ }
+ @Test
+ public void testAssociateOrAddCalculatedCapReq2() {
+ String yamlName = "yamlName";
+ Service resource = createServiceObject(true);
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities = new HashMap<>();
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
+ try {
+ bl.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateInstAttributeToComponentToInstances2() {
+ String yamlName = "yamlName";
+ Service resource = createServiceObject(true);
+ Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ try {
+ bl.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateRequirementsToService() {
+ String yamlName = "yamlName";
+ Service resource = createServiceObject(true);
+ Map<String, ListRequirementDataDefinition> requirements = new HashMap<>();
+ try {
+ bl.associateRequirementsToService(yamlName, resource, requirements);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateCapabilitiesToService() {
+ String yamlName = "yamlName";
+ Service resource = createServiceObject(true);
+ Map<String, ListCapabilityDataDefinition> capabilities = new HashMap<>();
+ try {
+ bl.associateCapabilitiesToService(yamlName, resource, capabilities);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateResourceInstances() {
+ String yamlName = "yamlName";
+ Service resource = createServiceObject(true);
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ try {
+ bl.associateResourceInstances(yamlName, resource, relations);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAddCapabilities() {
+ Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
+ String type = "type";
+ List<CapabilityDefinition> capabilities = new ArrayList<>();
+ try {
+ bl.addCapabilities(originCapabilities, type, capabilities);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAddCapabilitiesProperties() {
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
+ List<UploadCapInfo> capabilities = new ArrayList<>();
+ try {
+ bl.addCapabilitiesProperties(newPropertiesMap, capabilities);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testGetServiceWithGroups() {
+ String resourceId = "resourceId";
+ try {
+ bl.getServiceWithGroups(resourceId);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testGetResourceWithGroups() {
+ String resourceId = "resourceId";
+ try {
+ bl.getResourceWithGroups(resourceId);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAssociateResourceInstances2() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ try {
+ bl.associateResourceInstances(yamlName, resource, relations);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAddRelationsToRI() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
+ List<ComponentInstance> componentInstancesList = new ArrayList<>();
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ try {
+ bl.addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList, relations);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testAddRelationsToRI2() {
+ String yamlName = "yamlName";
+ Resource resource = createParseResourceObject(true);
+ UploadComponentInstanceInfo nodesInfoValue = new UploadComponentInstanceInfo();
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ try {
+ bl.addRelationToRI(yamlName, resource, nodesInfoValue, relations);
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testFindVfcResource() {
+ Service service = createServiceObject(true);
+ String currVfcToscaName = "currVfcToscaName";
+ String previousVfcToscaName = "previousVfcToscaName";
+ UploadComponentInstanceInfo nodesInfoValue = new UploadComponentInstanceInfo();
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ try {
+ bl.findVfcResource(getCsarInfo(), service, currVfcToscaName, previousVfcToscaName,
+ StorageOperationStatus.OK);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.OK,
+ ComponentTypeEnum.RESOURCE.getValue());
+ }
+ }
+
+ protected Resource createParseResourceObject(boolean afterCreate) {
+ Resource resource = new Resource();
+ resource.setName(RESOURCE_NAME);
+ resource.setToscaResourceName(RESOURCE_TOSCA_NAME);
+ resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
+ resource.setDescription("My short description");
+ List<String> tgs = new ArrayList<>();
+ tgs.add("test");
+ tgs.add(resource.getName());
+ resource.setTags(tgs);
+ List<String> template = new ArrayList<>();
+ template.add("tosca.nodes.Root");
+ resource.setDerivedFrom(template);
+ resource.setVendorName("Motorola");
+ resource.setVendorRelease("1.0.0");
+ resource.setContactId("ya5467");
+ resource.setIcon("defaulticon");
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ List<RequirementDefinition> requirementDefinitionList = new ArrayList<>();
+ requirements.put("test", requirementDefinitionList);
+ resource.setRequirements(requirements);
+ resource.setCost("cost");
+ resource.setResourceVendorModelNumber("02312233");
+
+
+ Map<String, ArtifactDefinition> artifacts = new HashMap<>();
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifacts.put("artifact", artifactDefinition);
+ resource.setArtifacts(artifacts);
+
+ resource.setLicenseType("licType");
+
+ if (afterCreate) {
+ resource.setName(resource.getName());
+ resource.setVersion("0.1");
+ resource.setUniqueId(resource.getName()
+ .toLowerCase() + ":" + resource.getVersion());
+ resource.setCreatorUserId(user.getUserId());
+ resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ }
+ return resource;
+ }
+
+ protected CsarInfo getCsarInfo() {
+ String csarUuid = "0010";
+ User user = new User();
+ Map<String, byte[]> csar = new HashMap<>();
+ String vfReousrceName = "resouceName";
+ String mainTemplateName = "mainTemplateName";
+ String mainTemplateContent = null;
+ try {
+ mainTemplateContent = loadFileNameToJsonString("service_import_template.yml");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ CsarInfo csarInfo = new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent,
+ false);
+ return csarInfo;
+ }
+
+ public static String loadFileNameToJsonString(String fileName) throws IOException {
+ String sourceDir = "src/test/resources/normativeTypes";
+ return loadFileNameToJsonString(sourceDir, fileName);
+ }
+
+ private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException {
+ java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName);
+ byte[] fileContent = Files.readAllBytes(filePath);
+ return new String(fileContent);
+ }
+
+ protected Service createServiceObject (boolean afterCreate) {
+ Service service = new Service();
+ service.setUniqueId("sid");
+ service.setName("Service");
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName(SERVICE_CATEGORY);
+ category.setIcons(Collections.singletonList("defaulticon"));
+ List<CategoryDefinition> categories = new ArrayList<>();
+ categories.add(category);
+ service.setCategories(categories);
+ service.setInstantiationType(INSTANTIATION_TYPE);
+
+ service.setDescription("description");
+ List<String> tgs = new ArrayList<>();
+ tgs.add(service.getName());
+ service.setTags(tgs);
+ service.setIcon("defaulticon");
+ service.setContactId("aa1234");
+ service.setProjectCode("12345");
+ service.setEcompGeneratedNaming(true);
+
+ if (afterCreate) {
+ service.setVersion("0.1");
+ service.setUniqueId(service.getName() + ":" + service.getVersion());
+ service.setCreatorUserId(user.getUserId());
+ service.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
+ }
+ return service;
+ }
+
+ protected void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat actualResponse = e.getResponseFormat() != null ?
+ e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ assertParseResponse(actualResponse, expectedStatus, variables);
+ }
+
+ private void assertParseResponse(ResponseFormat actualResponse, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
+ assertThat(expectedResponse.getStatus()).isEqualTo(actualResponse.getStatus());
+ assertThat(expectedResponse.getFormattedMessage()).isEqualTo(actualResponse.getFormattedMessage());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/CreateServiceFromYamlParameterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/CreateServiceFromYamlParameterTest.java
new file mode 100644
index 0000000000..0ff0d133c5
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/CreateServiceFromYamlParameterTest.java
@@ -0,0 +1,51 @@
+/*
+
+ * Copyright (c) 2018 AT&T Intellectual Property.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
+
+package org.openecomp.sdc.be.components.impl.utils;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CreateServiceFromYamlParameterTest {
+ private CreateServiceFromYamlParameter createTestSubject(){
+ return new CreateServiceFromYamlParameter();
+ }
+
+ @Test
+ public void testYamlName() {
+ CreateServiceFromYamlParameter testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ assertThat(testSubject).isInstanceOf(CreateServiceFromYamlParameter.class);
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
index 1d7a1c5eed..ac64e06917 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
@@ -46,6 +46,7 @@ import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PolicyTypeDefinition;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadArtifactInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
import org.openecomp.sdc.be.model.User;
@@ -145,8 +146,9 @@ public class YamlTemplateParsingHandlerTest {
CsarInfo csarInfo = new CsarInfo(user, CSAR_UUID, csar, RESOURCE_NAME,
MAIN_TEMPLATE_NAME, main_template_content, true);
+ Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- csarInfo.extractNodeTypesInfo(), NODE_NAME);
+ csarInfo.extractNodeTypesInfo(), NODE_NAME, resource);
validateParsedYaml(parsedYaml, NESTED_GROUP_NAME,
Lists.newArrayList("heat_file", "description"));
@@ -155,8 +157,9 @@ public class YamlTemplateParsingHandlerTest {
@Test
public void parseResourceInfoFromYAMLTest() {
+ Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- new HashMap<>(), "");
+ new HashMap<>(), "", resource);
validateParsedYamlWithCapability(parsedYaml);
}
@@ -228,8 +231,9 @@ public class YamlTemplateParsingHandlerTest {
@Test
public void parseResourceWithPoliciesDefined() {
+ Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- new HashMap<>(), "");
+ new HashMap<>(), "", resource);
validateParsedYamlWithPolicies(parsedYaml);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
new file mode 100644
index 0000000000..40341be868
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
@@ -0,0 +1,219 @@
+/*
+
+ * Copyright (c) 2018 AT&T Intellectual Property.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
+
+package org.openecomp.sdc.be.externalapi.servlet;
+
+
+import fj.data.Either;
+import org.apache.http.HttpStatus;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.stubbing.Answer;
+import org.openecomp.sdc.be.components.impl.*;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.config.SpringConfig;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetMetadata;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.impl.WebAppContextWrapper;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+public class AbstractTemplateServletTest extends JerseyTest {
+
+ private static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+ private static final HttpSession session = Mockito.mock(HttpSession.class);
+ private static final ServletContext servletContext = Mockito.mock(ServletContext.class);
+ private static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+ private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
+ private static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
+ private static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+ private static final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
+ private static final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
+ private static final ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
+ private static final ElementBusinessLogic elementBusinessLogic = Mockito.mock(ElementBusinessLogic.class);
+ private static final Resource resource = Mockito.mock(Resource.class);
+ private static final CategoryDefinition categoryDefinition = Mockito.mock(CategoryDefinition.class);
+ private static final SubCategoryDefinition subCategoryDefinition = Mockito.mock(SubCategoryDefinition.class);
+ private static final AssetMetadataConverter assetMetadataConverter = Mockito.mock(AssetMetadataConverter.class);
+ private static final ResourceAssetMetadata resourceAssetMetadata = new ResourceAssetMetadata();
+ private static final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
+ private static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
+ private static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ private static String serviceVertexUuid;
+
+
+ @BeforeClass
+ public static void setup() {
+ ExternalConfiguration.setAppName("catalog-be");
+ when(request.getSession()).thenReturn(session);
+ when(request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER)).thenReturn("mockXEcompInstanceId");
+ when(request.getHeader(Constants.USER_ID_HEADER)).thenReturn("mockAttID");
+ when(request.getRequestURL()).thenReturn(new StringBuffer("sdc/v1/catalog/abstract"));
+
+ when(session.getServletContext()).thenReturn(servletContext);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+ when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
+
+ when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
+ when(webApplicationContext.getBean(ResourceBusinessLogic.class)).thenReturn(resourceBusinessLogic);
+
+ when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
+ mockResponseFormat();
+
+ when(resource.getName()).thenReturn("MockVFCMT");
+ when(resource.getSystemName()).thenReturn("mockvfcmt");
+ Either<Resource, ResponseFormat> eitherRet = Either.left(resource);
+ when(componentsUtils.convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class), Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
+
+ when(webApplicationContext.getBean(ResourceImportManager.class)).thenReturn(resourceImportManager);
+ when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
+ when(categoryDefinition.getName()).thenReturn("Template");
+ when(subCategoryDefinition.getName()).thenReturn("Monitoring Template");
+ when(categoryDefinition.getSubcategories()).thenReturn(Arrays.asList(subCategoryDefinition));
+ when(elementBusinessLogic.getAllResourceCategories()).thenReturn(Either.left(Arrays.asList(categoryDefinition)));
+ when(resourceBusinessLogic.createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(resource);
+ when(webApplicationContext.getBean(AssetMetadataConverter.class)).thenReturn(assetMetadataConverter);
+ when(request.isUserInRole(anyString())).thenReturn(true);
+
+ Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter).convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
+ Mockito.eq(true));
+
+ String appConfigDir = "src/test/abstract/config";
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+
+ org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
+ configuration.setJanusGraphInMemoryGraph(true);
+
+ configurationManager.setConfiguration(configuration);
+ }
+
+ private static void mockResponseFormat() {
+ when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class))).thenAnswer((Answer<ResponseFormat>) invocation -> {
+ ResponseFormat ret;
+ final ActionStatus actionStatus = invocation.getArgument(0);
+ switch( actionStatus ){
+ case CREATED :{
+ ret = new ResponseFormat(HttpStatus.SC_CREATED);
+ break;
+ }
+ default :{
+ ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ break;
+ }
+ }
+ return ret;
+ });
+ }
+ @Test
+ public void createVfcmtHappyScenario() {
+ final JSONObject createRequest = buildCreateJsonRequest();
+ Response response = target().path("/v1/catalog/abstract").request(MediaType.APPLICATION_JSON).header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId").header(Constants.USER_ID_HEADER, "mockAttID")
+ .post(Entity.json(createRequest.toJSONString()), Response.class);
+ assertEquals(response.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+
+ }
+ private static final String BASIC_CREATE_REQUEST = "{\r\n" +
+ " \"name\": \"VFCMT_1\",\r\n" +
+ " \"description\": \"VFCMT Description\",\r\n" +
+ " \"resourceType\" : \"VFCMT\",\r\n" +
+ " \"category\": \"Template\",\r\n" +
+ " \"subcategory\": \"Monitoring Template\",\r\n" +
+ " \"vendorName\" : \"DCAE\",\r\n" +
+ " \"vendorRelease\" : \"1.0\",\r\n" +
+ " \"tags\": [\r\n" +
+ " \"VFCMT_1\"\r\n" +
+ " ],\r\n" +
+ " \"icon\" : \"defaulticon\",\r\n" +
+ " \"contactId\": \"cs0008\"\r\n" +
+ "}";
+ private JSONObject buildCreateJsonRequest() {
+
+ JSONParser parser = new JSONParser();
+ return (JSONObject) FunctionalInterfaces.swallowException( () -> parser.parse(BASIC_CREATE_REQUEST));
+
+ }
+
+ @Override
+ protected Application configure() {
+ ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
+ forceSet(TestProperties.CONTAINER_PORT, "0");
+ return new ResourceConfig()
+ .register(new CrudExternalServlet(userBusinessLogic, componentInstanceBusinessLogic,componentsUtils,servletUtils,resourceImportManager, elementBusinessLogic, assetMetadataConverter, lifecycleBusinessLogic, resourceBusinessLogic, serviceBusinessLogic))
+ .register(new AbstractBinder() {
+
+ @Override
+ protected void configure() {
+ bind(request).to(HttpServletRequest.class);
+ }
+ })
+ .property("contextConfig", context);
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractResourceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractResourceInfoTest.java
new file mode 100644
index 0000000000..45fdf570e7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractResourceInfoTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.externalapi.servlet.representation;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class AbstractResourceInfoTest {
+
+ private AbstractResourceInfo createTestSubject(){
+ return new AbstractResourceInfo();
+ }
+
+ @Test
+ public void testAbstractResourceNameInstance() {
+ AbstractResourceInfo testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ assertThat(testSubject).isInstanceOf(AbstractResourceInfo.class);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractTemplateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractTemplateInfoTest.java
new file mode 100644
index 0000000000..883c4021af
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/AbstractTemplateInfoTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.externalapi.servlet.representation;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class AbstractTemplateInfoTest {
+ private AbstractTemplateInfo createTestSubject(){
+ return new AbstractTemplateInfo();
+ }
+
+ @Test
+ public void testAbstractTemplateNameInstance() {
+ AbstractTemplateInfo testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ assertThat(testSubject).isInstanceOf(AbstractTemplateInfo.class);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/CopyServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/CopyServiceInfoTest.java
new file mode 100644
index 0000000000..00f78a78b7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/CopyServiceInfoTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.externalapi.servlet.representation;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CopyServiceInfoTest {
+
+ private CopyServiceInfo createTestSubject(){
+ return new CopyServiceInfo();
+ }
+
+ @Test
+ public void testCopyServiceNameInstance() {
+ CopyServiceInfo testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ assertThat(testSubject).isInstanceOf(CopyServiceInfo.class);
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ReplaceVNFInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ReplaceVNFInfoTest.java
new file mode 100644
index 0000000000..3dd80c7f2a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ReplaceVNFInfoTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.externalapi.servlet.representation;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ReplaceVNFInfoTest {
+
+ private ReplaceVNFInfo createTestSubject(){
+ return new ReplaceVNFInfo();
+ }
+
+ @Test
+ public void testReplaceVNFInstance() {
+ ReplaceVNFInfo testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ assertThat(testSubject).isInstanceOf(ReplaceVNFInfo.class);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
index af28aca26b..6c1c447f9a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.text.StrSubstitutor;
import org.apache.http.HttpStatus;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
@@ -1033,6 +1034,7 @@ public class ResourceServletTest extends JerseyTest {
bind(resourceImportManager).to(ResourceImportManager.class);
}
})
+ .register(MultiPartFeature.class)
.property("contextConfig", context);
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceUploadServletTest.java
new file mode 100644
index 0000000000..0c1119808d
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceUploadServletTest.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.servlets;
+
+public class ServiceUploadServletTest {
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/resources/normativeTypes/service_import_template.yml b/catalog-be/src/test/resources/normativeTypes/service_import_template.yml
new file mode 100644
index 0000000000..6d8e80433b
--- /dev/null
+++ b/catalog-be/src/test/resources/normativeTypes/service_import_template.yml
@@ -0,0 +1,334 @@
+tosca_definitions_version: tosca_simple_yaml_1_1
+metadata:
+ invariantUUID: 6d17f281-683b-4198-a676-0faeecdc9025
+ UUID: bfeab6b4-199b-4a2b-b724-de416c5e9811
+ name: ser09080002
+ description: ser09080002
+ type: Service
+ category: E2E Service
+ serviceType: ''
+ serviceRole: ''
+ instantiationType: A-la-carte
+ serviceEcompNaming: true
+ ecompGeneratedNaming: true
+ namingPolicy: ''
+ environmentContext: General_Revenue-Bearing
+ serviceFunction: ''
+imports:
+- nodes:
+ file: nodes.yml
+- datatypes:
+ file: data.yml
+- capabilities:
+ file: capabilities.yml
+- relationships:
+ file: relationships.yml
+- groups:
+ file: groups.yml
+- policies:
+ file: policies.yml
+- annotations:
+ file: annotations.yml
+- service-ser09080002-interface:
+ file: service-Ser09080002-template-interface.yml
+- resource-ExtCP:
+ file: resource-Extcp-template.yml
+- resource-zxjTestImportServiceAb:
+ file: resource-Zxjtestimportserviceab-template.yml
+- resource-zxjTestImportServiceAb-interface:
+ file: resource-Zxjtestimportserviceab-template-interface.yml
+- resource-zxjTestServiceNotAbatract:
+ file: resource-Zxjtestservicenotabatract-template.yml
+- resource-zxjTestServiceNotAbatract-interface:
+ file: resource-Zxjtestservicenotabatract-template-interface.yml
+- resource-ext ZTE VL:
+ file: resource-ExtZteVl-template.yml
+topology_template:
+ inputs:
+ skip_post_instantiation_configuration:
+ default: true
+ type: boolean
+ required: false
+ controller_actor:
+ default: SO-REF-DATA
+ type: string
+ required: false
+ cds_model_version:
+ type: string
+ required: false
+ cds_model_name:
+ type: string
+ required: false
+ node_templates:
+ ext ZTE VL 0:
+ type: tosca.nodes.nfv.ext.zte.VL
+ metadata:
+ invariantUUID: 27ab7610-1a97-4daa-938a-3b48e7afcfd0
+ UUID: 9ea63e2c-4b8a-414f-93e3-5703ca5cee0d
+ customizationUUID: e45e79b0-07ab-46b4-ac26-1e9f155ce53c
+ version: '1.0'
+ name: ext ZTE VL
+ description: Ext ZTE VL
+ type: VL
+ category: Generic
+ subcategory: Network Elements
+ resourceVendor: ONAP (Tosca)
+ resourceVendorRelease: 1.0.0.wd03
+ resourceVendorModelNumber: ''
+ zxjTestServiceNotAbatract 0:
+ type: org.openecomp.resource.vf.Zxjtestservicenotabatract
+ metadata:
+ invariantUUID: ce39ce8d-6f97-4e89-8555-ae6789cdcf1c
+ UUID: 4ac822be-f1ae-4ace-a4b8-bf6b5d977005
+ customizationUUID: ee34e1e8-68e2-480f-8ba6-f257bbe90d6a
+ version: '1.0'
+ name: zxjTestServiceNotAbatract
+ description: zxjTestServiceNotAbatract
+ type: VF
+ category: Network L4+
+ subcategory: Common Network Resources
+ resourceVendor: zxjImportService
+ resourceVendorRelease: '1.0'
+ resourceVendorModelNumber: ''
+ properties:
+ nf_naming:
+ ecomp_generated_naming: true
+ skip_post_instantiation_configuration: true
+ multi_stage_design: 'false'
+ controller_actor: SO-REF-DATA
+ availability_zone_max_count: 1
+ capabilities:
+ mme_ipu_vdu.scalable:
+ properties:
+ max_instances: 1
+ min_instances: 1
+ mme_ipu_vdu.nfv_compute:
+ properties:
+ num_cpus: '2'
+ flavor_extra_specs: {
+ }
+ mem_size: '8192'
+ ExtCP 0:
+ type: org.openecomp.resource.cp.extCP
+ metadata:
+ invariantUUID: 9b772728-93f5-424f-bb07-f4cae2783614
+ UUID: 424ac220-4864-453e-b757-917fe4568ff8
+ customizationUUID: 6e65d8a8-4379-4693-87aa-82f9e34b92fd
+ version: '1.0'
+ name: ExtCP
+ description: The AT&T Connection Point base type all other CP derive from
+ type: CP
+ category: Generic
+ subcategory: Network Elements
+ resourceVendor: ONAP (Tosca)
+ resourceVendorRelease: 1.0.0.wd03
+ resourceVendorModelNumber: ''
+ properties:
+ mac_requirements:
+ mac_count_required:
+ is_required: false
+ exCP_naming:
+ ecomp_generated_naming: true
+ zxjTestImportServiceAb 0:
+ type: org.openecomp.resource.vf.Zxjtestimportserviceab
+ metadata:
+ invariantUUID: 41474f7f-3195-443d-a0a2-eb6020a56279
+ UUID: 92e32e49-55f8-46bf-984d-a98c924037ec
+ customizationUUID: 98c7a6c7-a867-45fb-8597-dd464f98e4aa
+ version: '1.0'
+ name: zxjTestImportServiceAb
+ description: zxjTestImportServiceAbstract
+ type: VF
+ category: Generic
+ subcategory: Abstract
+ resourceVendor: zxjImportService
+ resourceVendorRelease: '1.0'
+ resourceVendorModelNumber: ''
+ properties:
+ nf_naming:
+ ecomp_generated_naming: true
+ skip_post_instantiation_configuration: true
+ multi_stage_design: 'false'
+ controller_actor: SO-REF-DATA
+ availability_zone_max_count: 1
+ requirements:
+ - mme_ipu_vdu.dependency:
+ capability: feature
+ node: ExtCP 0
+ - imagefile.dependency:
+ capability: feature
+ node: ext ZTE VL 0
+ capabilities:
+ mme_ipu_vdu.scalable:
+ properties:
+ max_instances: 1
+ min_instances: 1
+ mme_ipu_vdu.nfv_compute:
+ properties:
+ num_cpus: '2'
+ flavor_extra_specs: {
+ }
+ mem_size: '8192'
+ substitution_mappings:
+ node_type: org.openecomp.service.Ser09080002
+ capabilities:
+ extcp0.feature:
+ - ExtCP 0
+ - feature
+ zxjtestservicenotabatract0.mme_ipu_vdu.monitoring_parameter:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.monitoring_parameter
+ zxjtestimportserviceab0.imagefile.guest_os:
+ - zxjTestImportServiceAb 0
+ - imagefile.guest_os
+ zxjtestimportserviceab0.imagefile.feature:
+ - zxjTestImportServiceAb 0
+ - imagefile.feature
+ zxjtestservicenotabatract0.imagefile.guest_os:
+ - zxjTestServiceNotAbatract 0
+ - imagefile.guest_os
+ zxjtestimportserviceab0.ipu_cpd.feature:
+ - zxjTestImportServiceAb 0
+ - ipu_cpd.feature
+ zxjtestservicenotabatract0.mme_ipu_vdu.virtualbinding:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.virtualbinding
+ zxjtestimportserviceab0.mme_ipu_vdu.feature:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.feature
+ extztevl0.feature:
+ - ext ZTE VL 0
+ - feature
+ zxjtestimportserviceab0.imagefile.image_fle:
+ - zxjTestImportServiceAb 0
+ - imagefile.image_fle
+ zxjtestimportserviceab0.mme_ipu_vdu.monitoring_parameter:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.monitoring_parameter
+ zxjtestservicenotabatract0.ipu_cpd.feature:
+ - zxjTestServiceNotAbatract 0
+ - ipu_cpd.feature
+ zxjtestservicenotabatract0.mme_ipu_vdu.nfv_compute:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.nfv_compute
+ zxjtestservicenotabatract0.mme_ipu_vdu.scalable:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.scalable
+ extcp0.internal_connectionPoint:
+ - ExtCP 0
+ - internal_connectionPoint
+ zxjtestimportserviceab0.mme_ipu_vdu.virtualbinding:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.virtualbinding
+ zxjtestservicenotabatract0.imagefile.image_fle:
+ - zxjTestServiceNotAbatract 0
+ - imagefile.image_fle
+ extztevl0.virtual_linkable:
+ - ext ZTE VL 0
+ - virtual_linkable
+ zxjtestservicenotabatract0.imagefile.feature:
+ - zxjTestServiceNotAbatract 0
+ - imagefile.feature
+ zxjtestimportserviceab0.localstorage.feature:
+ - zxjTestImportServiceAb 0
+ - localstorage.feature
+ zxjtestservicenotabatract0.localstorage.local_attachment:
+ - zxjTestServiceNotAbatract 0
+ - localstorage.local_attachment
+ zxjtestimportserviceab0.mme_ipu_vdu.scalable:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.scalable
+ zxjtestservicenotabatract0.localstorage.feature:
+ - zxjTestServiceNotAbatract 0
+ - localstorage.feature
+ zxjtestimportserviceab0.mme_ipu_vdu.nfv_compute:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.nfv_compute
+ zxjtestimportserviceab0.localstorage.local_attachment:
+ - zxjTestImportServiceAb 0
+ - localstorage.local_attachment
+ zxjtestservicenotabatract0.mme_ipu_vdu.feature:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.feature
+ zxjtestimportserviceab0.ipu_cpd.forwarder:
+ - zxjTestImportServiceAb 0
+ - ipu_cpd.forwarder
+ zxjtestservicenotabatract0.ipu_cpd.forwarder:
+ - zxjTestServiceNotAbatract 0
+ - ipu_cpd.forwarder
+ requirements:
+ zxjtestservicenotabatract0.imagefile.dependency:
+ - zxjTestServiceNotAbatract 0
+ - imagefile.dependency
+ zxjtestservicenotabatract0.mme_ipu_vdu.local_storage:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.local_storage
+ zxjtestservicenotabatract0.ipu_cpd.dependency:
+ - zxjTestServiceNotAbatract 0
+ - ipu_cpd.dependency
+ zxjtestservicenotabatract0.mme_ipu_vdu.volume_storage:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.volume_storage
+ zxjtestservicenotabatract0.ipu_cpd.virtualbinding:
+ - zxjTestServiceNotAbatract 0
+ - ipu_cpd.virtualbinding
+ zxjtestservicenotabatract0.mme_ipu_vdu.dependency:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.dependency
+ zxjtestservicenotabatract0.localstorage.dependency:
+ - zxjTestServiceNotAbatract 0
+ - localstorage.dependency
+ zxjtestimportserviceab0.imagefile.dependency:
+ - zxjTestImportServiceAb 0
+ - imagefile.dependency
+ zxjtestimportserviceab0.mme_ipu_vdu.volume_storage:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.volume_storage
+ zxjtestimportserviceab0.ipu_cpd.virtualbinding:
+ - zxjTestImportServiceAb 0
+ - ipu_cpd.virtualbinding
+ extcp0.virtualLink:
+ - ExtCP 0
+ - virtualLink
+ extcp0.virtualBinding:
+ - ExtCP 0
+ - virtualBinding
+ zxjtestimportserviceab0.mme_ipu_vdu.guest_os:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.guest_os
+ extcp0.dependency:
+ - ExtCP 0
+ - dependency
+ zxjtestimportserviceab0.localstorage.dependency:
+ - zxjTestImportServiceAb 0
+ - localstorage.dependency
+ zxjtestservicenotabatract0.ipu_cpd.virtualLink:
+ - zxjTestServiceNotAbatract 0
+ - ipu_cpd.virtualLink
+ extztevl0.dependency:
+ - ext ZTE VL 0
+ - dependency
+ zxjtestimportserviceab0.ipu_cpd.dependency:
+ - zxjTestImportServiceAb 0
+ - ipu_cpd.dependency
+ zxjtestimportserviceab0.mme_ipu_vdu.dependency:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.dependency
+ zxjtestimportserviceab0.mme_ipu_vdu.local_storage:
+ - zxjTestImportServiceAb 0
+ - mme_ipu_vdu.local_storage
+ zxjtestimportserviceab0.ipu_cpd.virtualLink:
+ - zxjTestImportServiceAb 0
+ - ipu_cpd.virtualLink
+ extcp0.external_virtualLink:
+ - ExtCP 0
+ - external_virtualLink
+ zxjtestservicenotabatract0.mme_ipu_vdu.guest_os:
+ - zxjTestServiceNotAbatract 0
+ - mme_ipu_vdu.guest_os
+ zxjtestimportserviceab0.ipu_cpd.forwarder:
+ - zxjTestImportServiceAb 0
+ - ipu_cpd.forwarder
+ zxjtestservicenotabatract0.ipu_cpd.forwarder:
+ - zxjTestServiceNotAbatract 0
+ - ipu_cpd.forwarder