Add test code for Test Topology Auto Design- Service Import
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / ServiceImportBussinessLogicBaseTestSetup.java
1 /*
2
3  * Copyright (c) 2018 AT&T Intellectual Property.
4
5  *
6
7  * Licensed under the Apache License, Version 2.0 (the "License");
8
9  * you may not use this file except in compliance with the License.
10
11  * You may obtain a copy of the License at
12
13  *
14
15  *     http://www.apache.org/licenses/LICENSE-2.0
16
17  *
18
19  * Unless required by applicable law or agreed to in writing, software
20
21  * distributed under the License is distributed on an "AS IS" BASIS,
22
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
25  * See the License for the specific language governing permissions and
26
27  * limitations under the License.
28
29  */
30
31 package org.openecomp.sdc.be.components.impl;
32
33 import fj.data.Either;
34
35 import java.io.IOException;
36 import java.lang.reflect.InvocationTargetException;
37 import java.lang.reflect.Method;
38 import java.nio.file.Files;
39 import java.nio.file.Path;
40 import java.nio.file.Paths;
41 import java.util.HashMap;
42 import java.util.Map;
43
44 import org.apache.commons.codec.binary.Base64;
45 import org.junit.Before;
46 import org.mockito.Mock;
47 import org.mockito.Mockito;
48 import org.openecomp.sdc.ElementOperationMock;
49 import org.openecomp.sdc.be.auditing.impl.AuditingManager;
50 import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
51 import org.openecomp.sdc.be.components.csar.CsarInfo;
52 import org.openecomp.sdc.be.components.distribution.engine.DistributionEngine;
53 import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
54 import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
55 import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter;
56 import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
57 import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
58 import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
59 import org.openecomp.sdc.be.components.validation.UserValidations;
60 import org.openecomp.sdc.be.components.validation.component.*;
61 import org.openecomp.sdc.be.components.validation.service.*;
62 import org.openecomp.sdc.be.dao.api.ActionStatus;
63 import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
64 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
65 import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
66 import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
67 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
68 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
69 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
70 import org.openecomp.sdc.be.externalapi.servlet.representation.*;
71 import org.openecomp.sdc.be.facade.operations.CatalogOperation;
72 import org.openecomp.sdc.be.impl.ComponentsUtils;
73 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
74 import org.openecomp.sdc.be.model.*;
75 import org.openecomp.sdc.be.model.category.CategoryDefinition;
76 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
77 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
78 import org.openecomp.sdc.be.model.operations.api.IElementOperation;
79 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
80 import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
81 import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
82 import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
83 import org.openecomp.sdc.be.user.Role;
84 import org.openecomp.sdc.be.user.UserBusinessLogic;
85 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
86 import org.openecomp.sdc.common.api.Constants;
87 import org.openecomp.sdc.common.api.UploadArtifactInfo;
88 import org.openecomp.sdc.exception.ResponseFormat;
89 import org.springframework.web.context.WebApplicationContext;
90
91 import javax.servlet.ServletContext;
92 import java.util.*;
93
94 import static org.assertj.core.api.Java6Assertions.assertThat;
95 import static org.junit.Assert.assertEquals;
96 import static org.mockito.ArgumentMatchers.*;
97 import static org.mockito.Mockito.when;
98
99 public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicMock {
100     protected ServiceImportBusinessLogic sIB1;
101     protected static final String SERVICE_CATEGORY = "Mobility";
102     protected static final String INSTANTIATION_TYPE = "A-la-carte";
103     protected final ServletContext servletContext = Mockito.mock(ServletContext.class);
104     protected UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
105     protected WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
106     protected WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
107     protected ResponseFormatManager responseManager = null;
108     protected ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
109     protected AuditCassandraDao auditingDao = Mockito.mock(AuditCassandraDao.class);
110     protected ArtifactsBusinessLogic artifactBl = Mockito.mock(ArtifactsBusinessLogic.class);
111     protected GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
112     protected JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class);
113     protected ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
114     protected CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class);
115     protected GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
116     protected UserValidations userValidations = Mockito.mock(UserValidations.class);
117     protected ResourceAdminEvent auditArchive1 = Mockito.mock(ResourceAdminEvent.class);
118     protected CatalogOperation catalogOperation = Mockito.mock(CatalogOperation.class);
119     protected ResourceAdminEvent auditArchive2 = Mockito.mock(ResourceAdminEvent.class);
120     protected ResourceAdminEvent auditRestore = Mockito.mock(ResourceAdminEvent.class);
121     protected ServiceImportParseLogic serviceImportParseLogic = Mockito.mock(ServiceImportParseLogic.class);
122     IElementOperation mockElementDao = new ElementOperationMock();
123     DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class);
124     ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
125     ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
126     ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
127     UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
128     NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
129     NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
130     protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator(componentsUtils);
131     protected ServiceCategoryValidator serviceCategoryValidator = new ServiceCategoryValidator(componentsUtils, mockElementDao);
132     protected ServiceRoleValidator serviceRoleValidator = new ServiceRoleValidator(componentsUtils);
133     protected ServiceFunctionValidator serviceFunctionValidator = new ServiceFunctionValidator(componentsUtils);
134     protected ServiceInstantiationTypeValidator serviceInstantiationTypeValidator = new ServiceInstantiationTypeValidator(componentsUtils);
135     protected ComponentDescriptionValidator componentDescriptionValidator = new ComponentDescriptionValidator(componentsUtils);
136     protected ComponentProjectCodeValidator componentProjectCodeValidator = new ComponentProjectCodeValidator(componentsUtils);
137     protected ComponentIconValidator componentIconValidator = new ComponentIconValidator(componentsUtils);
138     protected ComponentContactIdValidator componentContactIdValidator = new ComponentContactIdValidator(componentsUtils);
139     protected ComponentTagsValidator componentTagsValidator = new ComponentTagsValidator(componentsUtils);
140     protected ComponentNameValidator componentNameValidator = new ComponentNameValidator(componentsUtils, toscaOperationFacade);
141     protected final ComponentValidator componentValidator = Mockito.mock(ComponentValidator.class);
142     protected ServiceValidator serviceValidator = createServiceValidator();
143
144     protected User user = null;
145     protected Resource genericService = null;
146
147     private static final String RESOURCE_NAME = "My-Resource_Name with   space";
148     private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name";
149     private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
150     private static final String RESOURCE_SUBCATEGORY = "Router";
151     protected static final String CERTIFIED_VERSION = "1.0";
152     protected static final String UNCERTIFIED_VERSION = "0.2";
153     protected static final String COMPONNET_ID = "myUniqueId";
154     protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
155
156     protected static final String SERVICE_ROLE = JsonPresentationFields.SERVICE_ROLE.getPresentation();
157     protected static final String SERVICE_TYPE = JsonPresentationFields.SERVICE_TYPE.getPresentation();
158     protected static final String SERVICE_FUNCTION = JsonPresentationFields.SERVICE_FUNCTION.getPresentation();
159
160     public ServiceImportBussinessLogicBaseTestSetup() {
161
162     }
163
164     protected ServiceValidator createServiceValidator() {
165         List<ComponentFieldValidator> componentFieldValidators = Arrays.asList(componentContactIdValidator,
166                 componentDescriptionValidator,
167                 componentIconValidator, componentNameValidator,
168                 new ComponentProjectCodeValidator(componentsUtils),
169                 componentTagsValidator);
170
171         List<ServiceFieldValidator> serviceFieldValidators = Arrays.asList(serviceCategoryValidator, new ServiceEnvironmentContextValidator(),
172                 serviceInstantiationTypeValidator, new ServiceNamingPolicyValidator(componentsUtils),
173                 serviceRoleValidator, serviceTypeValidator);
174         return new ServiceValidator(componentsUtils, componentFieldValidators, serviceFieldValidators);
175     }
176
177     @Before
178     public void setup() {
179
180         // Elements
181         IElementOperation mockElementDao = new ElementOperationMock();
182
183         // User data and management
184         user = new User();
185         user.setUserId("jh0003");
186         user.setFirstName("Jimmi");
187         user.setLastName("Hendrix");
188         user.setRole(Role.ADMIN.name());
189
190         when(mockUserAdmin.getUser("jh0003", false)).thenReturn(user);
191         when(userValidations.validateUserExists(eq("jh0003"))).thenReturn(user);
192         when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(user);
193 //        when(userValidations.validateUserRole(user))
194         // Servlet Context attributes
195         when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
196 //        when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation());
197         when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
198         when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext);
199         when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao);
200         when(graphLockOperation.lockComponent(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Service))).thenReturn(StorageOperationStatus.OK);
201         when(graphLockOperation.lockComponentByName(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Service))).thenReturn(StorageOperationStatus.OK);
202         when(catalogOperation.updateCatalog(Mockito.any(), Mockito.any())).thenReturn(ActionStatus.OK);
203         // artifact bussinesslogic
204         ArtifactDefinition artifactDef = new ArtifactDefinition();
205         when(artifactBl.createArtifactPlaceHolderInfo(Mockito.any(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef);
206
207         // createService
208         Service serviceResponse = createServiceObject(true);
209         Either<Component, StorageOperationStatus> eitherCreate = Either.left(serviceResponse);
210         when(toscaOperationFacade.createToscaComponent(Mockito.any(Component.class))).thenReturn(eitherCreate);
211         when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherCreate);
212         Either<Boolean, StorageOperationStatus> eitherCount = Either.left(false);
213         when(toscaOperationFacade.validateComponentNameExists("Service", null, ComponentTypeEnum.SERVICE)).thenReturn(eitherCount);
214         Either<Boolean, StorageOperationStatus> eitherCountExist = Either.left(true);
215         when(toscaOperationFacade.validateComponentNameExists("alreadyExist", null, ComponentTypeEnum.SERVICE)).thenReturn(eitherCountExist);
216         when(userValidations.validateUserExists(user)).thenReturn(user);
217
218         // createResource
219         Resource resourceRsponse = createParseResourceObject(true);
220         Either<Component, StorageOperationStatus> eitherResourceCreate = Either.left(resourceRsponse);
221         when(toscaOperationFacade.createToscaComponent(Mockito.any(Component.class))).thenReturn(eitherResourceCreate);
222         Either<Component, StorageOperationStatus> eitherResourceRes = Either.left(resourceRsponse);
223         when(toscaOperationFacade.getToscaFullElement(Mockito.anyString())).thenReturn(eitherResourceRes);
224
225         Either<Boolean, StorageOperationStatus> eitherResourceCount = Either.left(false);
226         when(toscaOperationFacade.validateComponentNameExists("Resource", null, ComponentTypeEnum.RESOURCE)).thenReturn(eitherResourceCount);
227         Either<Boolean, StorageOperationStatus> eitherResourceCountExist = Either.left(true);
228         when(toscaOperationFacade.validateComponentNameExists("alreadyExist", null, ComponentTypeEnum.RESOURCE)).thenReturn(eitherResourceCountExist);
229
230         genericService = setupGenericServiceMock();
231         Either<Resource, StorageOperationStatus> findLatestGeneric = Either.left(genericService);
232         when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_SERVICE_NAME)).thenReturn(findLatestGeneric);
233
234         when(serviceImportParseLogic.isArtifactDeletionRequired(anyString(),any(),anyBoolean())).thenReturn(true);
235         Either<Boolean, ResponseFormat> validateCGD = Either.left(true);
236         when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())).thenReturn(validateCGD);
237
238         sIB1 = new ServiceImportBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
239                 groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
240                 artifactBl, distributionEngine, componentInstanceBusinessLogic,
241                 serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter, serviceFilterOperation,
242                 serviceFilterValidator, artifactToscaOperation, componentContactIdValidator,
243                 componentNameValidator, componentTagsValidator, componentValidator,
244                 componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
245
246
247         mockAbstract();
248
249         responseManager = ResponseFormatManager.getInstance();
250     }
251
252     protected Service createServiceObject(boolean afterCreate) {
253         Service service = new Service();
254         service.setUniqueId("sid");
255         service.setName("Service");
256         CategoryDefinition category = new CategoryDefinition();
257         category.setName(SERVICE_CATEGORY);
258         category.setIcons(Collections.singletonList("defaulticon"));
259         List<CategoryDefinition> categories = new ArrayList<>();
260         categories.add(category);
261         service.setCategories(categories);
262         service.setInstantiationType(INSTANTIATION_TYPE);
263
264         service.setDescription("description");
265         List<String> tgs = new ArrayList<>();
266         tgs.add(service.getName());
267         service.setTags(tgs);
268         // service.setVendorName("Motorola");
269         // service.setVendorRelease("1.0.0");
270         service.setIcon("defaulticon");
271         // service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
272         service.setContactId("aa1234");
273         service.setProjectCode("12345");
274         service.setEcompGeneratedNaming(true);
275
276         if (afterCreate) {
277             service.setVersion("0.1");
278             service.setUniqueId(service.getName() + ":" + service.getVersion());
279             service.setCreatorUserId(user.getUserId());
280             service.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
281         }
282         return service;
283     }
284
285     protected Resource createResourceObject(boolean afterCreate) {
286         Resource resource = new Resource();
287         resource.setUniqueId("sid");
288         resource.setName("Service");
289         CategoryDefinition category = new CategoryDefinition();
290         category.setName(SERVICE_CATEGORY);
291         category.setIcons(Collections.singletonList("defaulticon"));
292         List<CategoryDefinition> categories = new ArrayList<>();
293         categories.add(category);
294         resource.setCategories(categories);
295
296
297         resource.setDescription("description");
298         List<String> tgs = new ArrayList<>();
299         tgs.add(resource.getName());
300         resource.setTags(tgs);
301         resource.setIcon("defaulticon");
302         resource.setContactId("aa1234");
303         resource.setProjectCode("12345");
304
305
306         if (afterCreate) {
307             resource.setVersion("0.1");
308             resource.setUniqueId(resource.getName() + ":" + resource.getVersion());
309             resource.setCreatorUserId(user.getUserId());
310             resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
311         }
312         return resource;
313     }
314         
315 protected Resource createParseResourceObject(boolean afterCreate) {
316         Resource resource = new Resource();
317         resource.setName(RESOURCE_NAME);
318         resource.setToscaResourceName(RESOURCE_TOSCA_NAME);
319         resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
320         resource.setDescription("My short description");
321         List<String> tgs = new ArrayList<>();
322         tgs.add("test");
323         tgs.add(resource.getName());
324         resource.setTags(tgs);
325         List<String> template = new ArrayList<>();
326         template.add("tosca.nodes.Root");
327         resource.setDerivedFrom(template);
328         resource.setVendorName("Motorola");
329         resource.setVendorRelease("1.0.0");
330         resource.setContactId("ya5467");
331         resource.setIcon("defaulticon");
332         Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
333         List<RequirementDefinition> requirementDefinitionList= new ArrayList<>();
334         requirements.put("test", requirementDefinitionList);
335         resource.setRequirements(requirements);
336
337         if (afterCreate) {
338             resource.setName(resource.getName());
339             resource.setVersion("0.1");
340             resource.setUniqueId(resource.getName()
341                     .toLowerCase() + ":" + resource.getVersion());
342             resource.setCreatorUserId(user.getUserId());
343             resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
344             resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
345         }
346         return resource;
347     }
348     protected Resource setupGenericServiceMock() {
349         Resource genericService = new Resource();
350         genericService.setVersion("1.0");
351         genericService.setToscaResourceName(GENERIC_SERVICE_NAME);
352         return genericService;
353     }
354
355
356     protected Map<String, GroupDefinition> getGroups() {
357         Map<String, GroupDefinition> groups = new HashMap<>();
358         GroupDefinition groupDefinition = new GroupDefinition();
359         groupDefinition.setName("groupDefinitionName");
360         groups.put("groupsMap",groupDefinition);
361         return groups;
362     }
363
364     protected UploadComponentInstanceInfo getuploadComponentInstanceInfo(){
365         UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
366         uploadComponentInstanceInfo.setType("resources");
367         Collection<String> directives = new Collection<String>() {
368             @Override
369             public int size() {
370                 return 0;
371             }
372
373             @Override
374             public boolean isEmpty() {
375                 return false;
376             }
377
378             @Override
379             public boolean contains(Object o) {
380                 return false;
381             }
382
383             @Override
384             public Iterator<String> iterator() {
385                 return null;
386             }
387
388             @Override
389             public Object[] toArray() {
390                 return new Object[0];
391             }
392
393             @Override
394             public <T> T[] toArray(T[] ts) {
395                 return null;
396             }
397
398             @Override
399             public boolean add(String s) {
400                 return false;
401             }
402
403             @Override
404             public boolean remove(Object o) {
405                 return false;
406             }
407
408             @Override
409             public boolean containsAll(Collection<?> collection) {
410                 return false;
411             }
412
413             @Override
414             public boolean addAll(Collection<? extends String> collection) {
415                 return false;
416             }
417
418             @Override
419             public boolean removeAll(Collection<?> collection) {
420                 return false;
421             }
422
423             @Override
424             public boolean retainAll(Collection<?> collection) {
425                 return false;
426             }
427
428             @Override
429             public void clear() {
430
431             }
432         };
433         uploadComponentInstanceInfo.setDirectives(directives);
434         UploadNodeFilterInfo uploadNodeFilterInfo = new UploadNodeFilterInfo();
435         Map<String, List<UploadReqInfo>> requirements = new HashMap<>();
436         List<UploadReqInfo> uploadReqInfoList = new ArrayList<>();
437         UploadReqInfo uploadReqInfo = new UploadReqInfo();
438         uploadReqInfo.setName("uploadReqInfo");
439         uploadReqInfo.setCapabilityName("tosca.capabilities.Node");
440         uploadReqInfoList.add(uploadReqInfo);
441         requirements.put("requirements",uploadReqInfoList);
442         uploadNodeFilterInfo.setName("mme_ipu_vdu.virtualbinding");
443         uploadComponentInstanceInfo.setCapabilities(getCapabilities());
444         uploadComponentInstanceInfo.setRequirements(requirements);
445         uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
446         return uploadComponentInstanceInfo;
447     }
448
449     protected Map<String, List<UploadCapInfo>> getCapabilities(){
450         List<UploadCapInfo> uploadCapInfoList = new ArrayList<>();
451         UploadCapInfo uploadCapInfo = new UploadCapInfo();
452         uploadCapInfo.setNode("tosca.nodes.Root");
453         uploadCapInfo.setName("mme_ipu_vdu.dependency");
454         uploadCapInfoList.add(uploadCapInfo);
455         Map<String, List<UploadCapInfo>> uploadCapInfoMap = new HashMap<>();
456         uploadCapInfoMap.put("tosca.capabilities.Node",uploadCapInfoList);
457         return uploadCapInfoMap;
458     }
459
460     protected List<ComponentInstance> creatComponentInstances(){
461         List<ComponentInstance> componentInstances = new ArrayList<>();
462         ComponentInstance componentInstance = new ComponentInstance();
463         Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
464         List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
465         CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
466         capabilityDefinition.setName("mme_ipu_vdu.feature");
467         capabilityDefinitionList.add(capabilityDefinition);
468         capabilities.put("tosca.capabilities.Node",capabilityDefinitionList);
469
470         Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
471         List<RequirementDefinition> requirementDefinitionList = new ArrayList<>();
472         RequirementDefinition requirementDefinition = new RequirementDefinition();
473         requirementDefinition.setName("zxjtestimportserviceab0.mme_ipu_vdu.dependency.test");
474         requirementDefinitionList.add(requirementDefinition);
475         requirements.put("tosca.capabilities.Node",requirementDefinitionList);
476         componentInstance.setRequirements(requirements);
477         componentInstance.setCapabilities(capabilities);
478         componentInstance.setUniqueId("uniqueId");
479         componentInstance.setComponentUid("componentUid");
480         componentInstance.setName("zxjTestImportServiceAb");
481         componentInstances.add(componentInstance);
482         return componentInstances;
483     }
484
485     protected UploadComponentInstanceInfo createUploadComponentInstanceInfo(){
486         UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
487         uploadComponentInstanceInfo.setName("UploadComponentInstanceInfo");
488         return uploadComponentInstanceInfo;
489     }
490
491     private void mockAbstract() {
492         checkCreateAbstract();
493         checkCreateOther();
494         checkCreateFile();
495     }
496
497     private void checkCreateAbstract(){
498         AbstractResourceInfo abstractResourceInfo = new AbstractResourceInfo();
499         List<RequirementCapabilityRelDef> componentInstancesRelations = new ArrayList<>();
500         abstractResourceInfo.setComponentInstancesRelations(componentInstancesRelations);
501         abstractResourceInfo.setAbstractResourceUniqueId("abstractResourceUniqueId");
502         abstractResourceInfo.setAbstractResourceName("abstractResourceName");
503         abstractResourceInfo.setAbstractResourceUUid("abstractResourceUUid");
504
505         AbstractResourceInfo getAbstractResourceInfo = new AbstractResourceInfo();
506         getAbstractResourceInfo.getAbstractResourceName();
507         getAbstractResourceInfo.getAbstractResourceUniqueId();
508         getAbstractResourceInfo.getAbstractResourceUUid();
509         getAbstractResourceInfo.getComponentInstancesRelations();
510
511         AbstractTemplateInfo createAbstractTemplateInfo = new AbstractTemplateInfo();
512         List<AbstractResourceInfo> abstractResourceInfoList = new ArrayList<>();
513         abstractResourceInfoList.add(abstractResourceInfo);
514         createAbstractTemplateInfo.setAbstractResourceInfoList(abstractResourceInfoList);
515         createAbstractTemplateInfo.setServiceUniqueId("serviceUniqueId");
516         createAbstractTemplateInfo.setIsAbstractTemplate(true);
517         createAbstractTemplateInfo.setServiceUUid("serviceUUid");
518
519         AbstractTemplateInfo getAbstractTemplateInfo = new AbstractTemplateInfo();
520         getAbstractTemplateInfo.getAbstractResourceInfoList();
521         getAbstractTemplateInfo.getIsAbstractTemplate();
522         getAbstractTemplateInfo.getServiceUniqueId();
523         getAbstractTemplateInfo.getServiceUUid();
524
525         CopyServiceInfo copyServiceInfo = new CopyServiceInfo();
526         copyServiceInfo.setNewServiceName("newServiceName");
527         copyServiceInfo.setNewServiceUUid("serviceUUid");
528         copyServiceInfo.setOldServiceUUid("oldServiceUUid");
529
530         CopyServiceInfo getCopyServiceInfo = new CopyServiceInfo();
531         getCopyServiceInfo.getNewServiceName();
532         getCopyServiceInfo.getNewServiceUUid();
533         getCopyServiceInfo.getOldServiceUUid();
534
535         ReplaceVNFInfo replaceVNFInfo = new ReplaceVNFInfo();
536         ComponentInstance realVNFComponentInstance = new ComponentInstance();
537         replaceVNFInfo.setAbstractResourceUniqueId("abstractResourceUniqueId");
538         replaceVNFInfo.setRealVNFComponentInstance(realVNFComponentInstance);
539         replaceVNFInfo.setServiceUniqueId("serviceUniqueId");
540
541         ReplaceVNFInfo getReplaceVNFInfo = new ReplaceVNFInfo();
542         getReplaceVNFInfo.getServiceUniqueId();
543         getReplaceVNFInfo.getAbstractResourceUniqueId();
544         getReplaceVNFInfo.getRealVNFComponentInstance();
545     }
546
547     private void checkCreateOther(){
548         ResourceInstanceMetadata resourceInstanceMetadata = new ResourceInstanceMetadata();
549         List<ArtifactMetadata> artifacts = new ArrayList<>();
550         resourceInstanceMetadata.setArtifacts(artifacts);
551         resourceInstanceMetadata.setResoucreType("resoucreType");
552         resourceInstanceMetadata.setResourceInstanceName("resourceInstanceName");
553         resourceInstanceMetadata.setResourceInvariantUUID("resourceInvariantUUID");
554         resourceInstanceMetadata.setResourceName("resourceName");
555         resourceInstanceMetadata.setResourceUUID("resourceUUID");
556         resourceInstanceMetadata.setResourceVersion("resourceVersion");
557
558         ResourceInstanceMetadata getResourceInstanceMetadata = new ResourceInstanceMetadata();
559         getResourceInstanceMetadata.getArtifacts();
560         getResourceInstanceMetadata.getResoucreType();
561         getResourceInstanceMetadata.getResourceInstanceName();
562         getResourceInstanceMetadata.getResourceInvariantUUID();
563         getResourceInstanceMetadata.getResourceName();
564         getResourceInstanceMetadata.getResourceUUID();
565         getResourceInstanceMetadata.getResourceVersion();
566
567         UploadServiceInfo uploadServiceInfo = new UploadServiceInfo();
568         List<String> tags = new ArrayList<>();
569         List<CategoryDefinition> categories = new ArrayList<>();
570         List<UploadArtifactInfo> artifactList = new ArrayList<>();
571         uploadServiceInfo.setProjectCode("projectCode");
572         uploadServiceInfo.setCategories(categories);
573         uploadServiceInfo.setServiceType("");
574         uploadServiceInfo.setServiceVendorModelNumber("serviceVendorModelNumber");
575         uploadServiceInfo.setVendorRelease("vendorRelease");
576         uploadServiceInfo.setVendorName("vendorName");
577         uploadServiceInfo.setServiceIconPath("serviceIconPath");
578         uploadServiceInfo.setName("uploadServiceInfo");
579         uploadServiceInfo.setContactId("contactId");
580         uploadServiceInfo.setIcon("icon");
581         uploadServiceInfo.setNamingPolicy("namingPolicy");
582         uploadServiceInfo.setEcompGeneratedNaming("ecompGeneratedNaming");
583         uploadServiceInfo.setServiceEcompNaming("serviceEcompNaming");
584         uploadServiceInfo.setServiceRole("serviceRole");
585         uploadServiceInfo.setSubcategory("subcategory");
586         uploadServiceInfo.setCategory("category");
587         uploadServiceInfo.setType("type");
588         uploadServiceInfo.setUUID("UUID");
589         uploadServiceInfo.setInvariantUUID("invariantUUID");
590         uploadServiceInfo.setResourceVendorRelease("resourceVendorRelease");
591         uploadServiceInfo.setResourceVendor("resourceVendor");
592         uploadServiceInfo.setDescription("description");
593         uploadServiceInfo.setTags(tags);
594         uploadServiceInfo.setArtifactList(artifactList);
595         uploadServiceInfo.setPayloadName("payloadName");
596         uploadServiceInfo.setPayloadData("payloadData");
597     }
598
599     protected void checkGetUploadServiceInfo(){
600         UploadServiceInfo uploadServiceInfo = new UploadServiceInfo();
601         List<String> tags = new ArrayList<>();
602         List<CategoryDefinition> categories = new ArrayList<>();
603         List<UploadArtifactInfo> artifactList = new ArrayList<>();
604         uploadServiceInfo.getProjectCode();
605         uploadServiceInfo.getCategories();
606         uploadServiceInfo.getServiceType();
607         uploadServiceInfo.getServiceVendorModelNumber();
608         uploadServiceInfo.getVendorRelease();
609         uploadServiceInfo.getVendorName();
610         uploadServiceInfo.getServiceIconPath();
611         uploadServiceInfo.getName();
612         uploadServiceInfo.getContactId();
613         uploadServiceInfo.getIcon();
614         uploadServiceInfo.getNamingPolicy();
615         uploadServiceInfo.getEcompGeneratedNaming();
616         uploadServiceInfo.getServiceEcompNaming();
617         uploadServiceInfo.getServiceRole();
618         uploadServiceInfo.getSubcategory();
619         uploadServiceInfo.getCategory();
620         uploadServiceInfo.getType();
621         uploadServiceInfo.getUUID();
622         uploadServiceInfo.getInvariantUUID();
623         uploadServiceInfo.getResourceVendorRelease();
624         uploadServiceInfo.getResourceVendor();
625         uploadServiceInfo.getDescription();
626         uploadServiceInfo.getTags();
627         uploadServiceInfo.getArtifactList();
628         uploadServiceInfo.getPayloadName();
629         uploadServiceInfo.getPayloadData();
630     }
631
632     private void checkCreateFile(){
633         CreateServiceFromYamlParameter csfp = new CreateServiceFromYamlParameter();
634         Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
635         ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
636         List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
637         CsarInfo csarInfo = getCsarInfo();
638         csfp.setYamlName("yamlName");
639         csfp.setNodeTypesInfo(nodeTypesInfo);
640         csfp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
641         csfp.setCsarInfo(csarInfo);
642         csfp.setCreatedArtifacts(createdArtifacts);
643         csfp.setYamlName("yamlName");
644         csfp.setShouldLock(true);
645         csfp.setInTransaction(true);
646         csfp.setNodeName("nodeName");
647
648         CreateServiceFromYamlParameter getCsfy = new CreateServiceFromYamlParameter();
649         getCsfy.getYamlName();
650         getCsfy.getNodeTypesInfo();
651         getCsfy.getParsedToscaYamlInfo();
652         getCsfy.getCsarInfo();
653         getCsfy.getCreatedArtifacts();
654         getCsfy.getYamlName();
655         getCsfy.isShouldLock();
656         getCsfy.isInTransaction();
657         getCsfy.getNodeName();
658     }
659
660     protected CsarInfo getCsarInfo ()
661     {
662         String csarUuid = "0010";
663         User user = new User();
664         Map<String, byte[]> csar = crateCsarFromPayload();
665         String vfReousrceName = "resouceName";
666         String mainTemplateName = "mainTemplateName";
667         String mainTemplateContent = getMainTemplateContent();
668         final Service service = createServiceObject(false);
669         CsarInfo csarInfo = new CsarInfo(user, csarUuid,  csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
670         return csarInfo;
671     }
672
673     protected Map<String, byte[]> crateCsarFromPayload() {
674         String payloadName = "valid_vf.csar";
675         byte[] data = new byte[1024];
676         Map<String, byte[]> returnValue = new HashMap<>();
677         returnValue.put(payloadName,data);
678
679         return returnValue;
680     }
681
682     protected String getGroupsYaml(){
683         return "zxjTestImportServiceAb 0:\n" +
684                 "      type: org.openecomp.resource.vf.Zxjtestimportserviceab\n" +
685                 "      metadata:\n" +
686                 "        invariantUUID: 41474f7f-3195-443d-a0a2-eb6020a56279\n" +
687                 "        UUID: 92e32e49-55f8-46bf-984d-a98c924037ec\n" +
688                 "        customizationUUID: 40286158-96d0-408e-9f27-21d43817d37c\n" +
689                 "        version: '1.0'\n" +
690                 "        name: zxjTestImportServiceAb\n" +
691                 "        description: zxjTestImportServiceAbstract\n" +
692                 "        type: VF\n" +
693                 "        category: Generic\n" +
694                 "        subcategory: Abstract\n" +
695                 "        resourceVendor: zxjImportService\n" +
696                 "        resourceVendorRelease: '1.0'\n" +
697                 "        resourceVendorModelNumber: ''\n" +
698                 "      properties:\n" +
699                 "        skip_post_instantiation_configuration: true\n" +
700                 "        nf_naming:\n" +
701                 "          ecomp_generated_naming: true\n" +
702                 "        multi_stage_design: 'false'\n" +
703                 "        controller_actor: SO-REF-DATA\n" +
704                 "        availability_zone_max_count: 1\n" +
705                 "      requirements:\n" +
706                 "      - imagefile.dependency:\n" +
707                 "          capability: feature\n" +
708                 "          node: ext ZTE VL 0\n" +
709                 "      - mme_ipu_vdu.dependency:\n" +
710                 "          capability: feature\n" +
711                 "          node: ExtCP 0\n" +
712                 "      capabilities:\n" +
713                 "        mme_ipu_vdu.scalable:\n" +
714                 "          properties:\n" +
715                 "            max_instances: 1\n" +
716                 "            min_instances: 1\n" +
717                 "        mme_ipu_vdu.nfv_compute:\n" +
718                 "          properties:\n" +
719                 "            num_cpus: '2'\n" +
720                 "            flavor_extra_specs: {\n" +
721                 "              }\n" +
722                 "            mem_size: '8192'";
723     }
724
725     protected String getYamlFileContent(){
726         return "tosca_definitions_version: tosca_simple_yaml_1_1\n" +
727                 "imports:\n" +
728                 "- data.yml\n" +
729                 "group_types:\n" +
730                 "  tosca.groups.Root:\n" +
731                 "    description: The TOSCA Group Type all other TOSCA Group Types derive from\n" +
732                 "    interfaces:\n" +
733                 "      Standard:\n" +
734                 "        type: tosca.interfaces.node.lifecycle.Standard\n" +
735                 "  org.openecomp.groups.heat.HeatStack:\n" +
736                 "    derived_from: tosca.groups.Root\n" +
737                 "    description: Grouped all heat resources which are in the same heat stack\n" +
738                 "    properties:\n" +
739                 "      heat_file:\n" +
740                 "        type: string\n" +
741                 "        description: Heat file which associate to this group/heat stack\n" +
742                 "        required: true\n" +
743                 "        status: supported\n" +
744                 "      description:\n" +
745                 "        type: string\n" +
746                 "        description: group description\n" +
747                 "        required: true\n" +
748                 "        status: supported\n" +
749                 "  org.openecomp.groups.VfModule:\n" +
750                 "    derived_from: tosca.groups.Root\n" +
751                 "    description: Grouped all heat resources which are in the same VF Module\n" +
752                 "    properties:\n" +
753                 "      isBase:\n" +
754                 "        type: boolean\n" +
755                 "        description: Whether this module should be deployed before other modules\n" +
756                 "        required: true\n" +
757                 "        default: false\n" +
758                 "        status: supported\n" +
759                 "      vf_module_label:\n" +
760                 "        type: string\n" +
761                 "        required: true\n" +
762                 "        description: |\n" +
763                 "          Alternate textual key used to reference this VF-Module model. Must be unique within the VNF model\n" +
764                 "      vf_module_description:\n" +
765                 "        type: string\n" +
766                 "        required: true\n" +
767                 "        description: |\n" +
768                 "          Description of the VF-modules contents and purpose (e.g. \"Front-End\" or \"Database Cluster\")\n" +
769                 "      min_vf_module_instances:\n" +
770                 "        type: integer\n" +
771                 "        required: true\n" +
772                 "        description: The minimum instances of this VF-Module\n" +
773                 "      max_vf_module_instances:\n" +
774                 "        type: integer\n" +
775                 "        required: false\n" +
776                 "        description: The maximum instances of this VF-Module\n" +
777                 "      initial_count:\n" +
778                 "        type: integer\n" +
779                 "        required: false\n" +
780                 "        description: |\n" +
781                 "          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" +
782                 "      vf_module_type:\n" +
783                 "        type: string\n" +
784                 "        required: true\n" +
785                 "        constraint:\n" +
786                 "        - valid_values:\n" +
787                 "          - Base\n" +
788                 "          - Expansion\n" +
789                 "      volume_group:\n" +
790                 "        type: boolean\n" +
791                 "        required: true\n" +
792                 "        default: false\n" +
793                 "        description: |\n" +
794                 "          \"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" +
795                 "      availability_zone_count:\n" +
796                 "        type: integer\n" +
797                 "        required: false\n" +
798                 "        description: |\n" +
799                 "          Quantity of Availability Zones needed for this VF-Module (source: Extracted from VF-Module HEAT template)\n" +
800                 "      vfc_list:\n" +
801                 "        type: map\n" +
802                 "        entry_schema:\n" +
803                 "          description: <vfc_id>:<count>\n" +
804                 "          type: string\n" +
805                 "        required: false\n" +
806                 "        description: |\n" +
807                 "          Identifies the set of VM types and their count included in the VF-Module\n" +
808                 "  org.openecomp.groups.NetworkCollection:\n" +
809                 "    derived_from: tosca.groups.Root\n" +
810                 "    description: groups l3-networks in network collection\n" +
811                 "    properties:\n" +
812                 "      network_collection_function:\n" +
813                 "        type: string\n" +
814                 "        required: true\n" +
815                 "        description: network collection function\n" +
816                 "      network_collection_description:\n" +
817                 "        type: string\n" +
818                 "        required: true\n" +
819                 "        description: network collection description, free format text\n" +
820                 "  org.openecomp.groups.VfcInstanceGroup:\n" +
821                 "    derived_from: tosca.groups.Root\n" +
822                 "    description: groups VFCs with same parent port role\n" +
823                 "    properties:\n" +
824                 "      vfc_instance_group_function:\n" +
825                 "        type: string\n" +
826                 "        required: true\n" +
827                 "        description: function of this VFC group\n" +
828                 "      vfc_parent_port_role:\n" +
829                 "        type: string\n" +
830                 "        required: true\n" +
831                 "        description: common role of parent ports of VFCs in this group\n" +
832                 "      network_collection_function:\n" +
833                 "        type: string\n" +
834                 "        required: true\n" +
835                 "        description: network collection function assigned to this group\n" +
836                 "      subinterface_role:\n" +
837                 "        type: string\n" +
838                 "        required: true\n" +
839                 "        description: common role of subinterfaces of VFCs in this group, criteria the group is created\n" +
840                 "    capabilities:\n" +
841                 "      vlan_assignment:\n" +
842                 "        type: org.openecomp.capabilities.VLANAssignment\n" +
843                 "        properties:\n" +
844                 "          vfc_instance_group_reference:\n" +
845                 "            type: string\n" +
846                 "  tosca.groups.nfv.PlacementGroup:\n" +
847                 "    derived_from: tosca.groups.Root\n" +
848                 "    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" +
849                 "    properties:\n" +
850                 "      description:\n" +
851                 "        type: string\n" +
852                 "        description: Human readable description of the group\n" +
853                 "        required: true\n" +
854                 "    members:\n" +
855                 "    - tosca.nodes.nfv.Vdu.Compute\n" +
856                 "    - tosca.nodes.nfv.VnfVirtualLink";
857     }
858
859     public String getMainTemplateContent(){
860         return "tosca_definitions_version: tosca_simple_yaml_1_1\n"
861                 + "metadata:\n"
862                 + "  invariantUUID: 6d17f281-683b-4198-a676-0faeecdc9025\n"
863                 + "  UUID: bfeab6b4-199b-4a2b-b724-de416c5e9811\n"
864                 + "  name: ser09080002\n"
865                 + "  description: ser09080002\n"
866                 + "  type: Service\n"
867                 + "  category: E2E Service\n"
868                 + "  serviceType: ''\n"
869                 + "  serviceRole: ''\n"
870                 + "  instantiationType: A-la-carte\n"
871                 + "  serviceEcompNaming: true\n"
872                 + "  ecompGeneratedNaming: true\n"
873                 + "  namingPolicy: ''\n"
874                 + "  environmentContext: General_Revenue-Bearing\n"
875                 + "  serviceFunction: ''\n"
876                 + "imports:\n"
877                 + "- nodes:\n"
878                 + "    file: nodes.yml\n"
879                 + "- datatypes:\n"
880                 + "    file: data.yml\n"
881                 + "- capabilities:\n"
882                 + "    file: capabilities.yml\n"
883                 + "- relationships:\n"
884                 + "    file: relationships.yml\n"
885                 + "- groups:\n"
886                 + "    file: groups.yml\n"
887                 + "- policies:\n"
888                 + "    file: policies.yml\n"
889                 + "- annotations:\n"
890                 + "    file: annotations.yml\n"
891                 + "- service-ser09080002-interface:\n"
892                 + "    file: service-Ser09080002-template-interface.yml\n"
893                 + "- resource-ExtCP:\n"
894                 + "    file: resource-Extcp-template.yml\n"
895                 + "- resource-zxjTestImportServiceAb:\n"
896                 + "    file: resource-Zxjtestimportserviceab-template.yml\n"
897                 + "- resource-zxjTestImportServiceAb-interface:\n"
898                 + "    file: resource-Zxjtestimportserviceab-template-interface.yml\n"
899                 + "- resource-zxjTestServiceNotAbatract:\n"
900                 + "    file: resource-Zxjtestservicenotabatract-template.yml\n"
901                 + "- resource-zxjTestServiceNotAbatract-interface:\n"
902                 + "    file: resource-Zxjtestservicenotabatract-template-interface.yml\n"
903                 + "- resource-ext ZTE VL:\n"
904                 + "    file: resource-ExtZteVl-template.yml\n"
905                 + "topology_template:\n"
906                 + "  inputs:\n"
907                 + "    skip_post_instantiation_configuration:\n"
908                 + "      default: true\n"
909                 + "      type: boolean\n"
910                 + "      required: false\n"
911                 + "    controller_actor:\n"
912                 + "      default: SO-REF-DATA\n"
913                 + "      type: string\n"
914                 + "      required: false\n"
915                 + "    cds_model_version:\n"
916                 + "      type: string\n"
917                 + "      required: false\n"
918                 + "    cds_model_name:\n"
919                 + "      type: string\n"
920                 + "      required: false\n"
921                 + "  node_templates:\n"
922                 + "    ext ZTE VL 0:\n"
923                 + "      type: tosca.nodes.nfv.ext.zte.VL\n"
924                 + "      metadata:\n"
925                 + "        invariantUUID: 27ab7610-1a97-4daa-938a-3b48e7afcfd0\n"
926                 + "        UUID: 9ea63e2c-4b8a-414f-93e3-5703ca5cee0d\n"
927                 + "        customizationUUID: e45e79b0-07ab-46b4-ac26-1e9f155ce53c\n"
928                 + "        version: '1.0'\n"
929                 + "        name: ext ZTE VL\n"
930                 + "        description: Ext ZTE VL\n"
931                 + "        type: VL\n"
932                 + "        category: Generic\n"
933                 + "        subcategory: Network Elements\n"
934                 + "        resourceVendor: ONAP (Tosca)\n"
935                 + "        resourceVendorRelease: 1.0.0.wd03\n"
936                 + "        resourceVendorModelNumber: ''\n"
937                 + "    zxjTestServiceNotAbatract 0:\n"
938                 + "      type: org.openecomp.resource.vf.Zxjtestservicenotabatract\n"
939                 + "      metadata:\n"
940                 + "        invariantUUID: ce39ce8d-6f97-4e89-8555-ae6789cdcf1c\n"
941                 + "        UUID: 4ac822be-f1ae-4ace-a4b8-bf6b5d977005\n"
942                 + "        customizationUUID: ee34e1e8-68e2-480f-8ba6-f257bbe90d6a\n"
943                 + "        version: '1.0'\n"
944                 + "        name: zxjTestServiceNotAbatract\n"
945                 + "        description: zxjTestServiceNotAbatract\n"
946                 + "        type: VF\n"
947                 + "        category: Network L4+\n"
948                 + "        subcategory: Common Network Resources\n"
949                 + "        resourceVendor: zxjImportService\n"
950                 + "        resourceVendorRelease: '1.0'\n"
951                 + "        resourceVendorModelNumber: ''\n"
952                 + "      properties:\n"
953                 + "        nf_naming:\n"
954                 + "          ecomp_generated_naming: true\n"
955                 + "        skip_post_instantiation_configuration: true\n"
956                 + "        multi_stage_design: 'false'\n"
957                 + "        controller_actor: SO-REF-DATA\n"
958                 + "        availability_zone_max_count: 1\n"
959                 + "      capabilities:\n"
960                 + "        mme_ipu_vdu.scalable:\n"
961                 + "          properties:\n"
962                 + "            max_instances: 1\n"
963                 + "            min_instances: 1\n"
964                 + "        mme_ipu_vdu.nfv_compute:\n"
965                 + "          properties:\n"
966                 + "            num_cpus: '2'\n"
967                 + "            flavor_extra_specs: {\n"
968                 + "              }\n"
969                 + "            mem_size: '8192'\n"
970                 + "    ExtCP 0:\n"
971                 + "      type: org.openecomp.resource.cp.extCP\n"
972                 + "      metadata:\n"
973                 + "        invariantUUID: 9b772728-93f5-424f-bb07-f4cae2783614\n"
974                 + "        UUID: 424ac220-4864-453e-b757-917fe4568ff8\n"
975                 + "        customizationUUID: 6e65d8a8-4379-4693-87aa-82f9e34b92fd\n"
976                 + "        version: '1.0'\n"
977                 + "        name: ExtCP\n"
978                 + "        description: The AT&T Connection Point base type all other CP derive from\n"
979                 + "        type: CP\n"
980                 + "        category: Generic\n"
981                 + "        subcategory: Network Elements\n"
982                 + "        resourceVendor: ONAP (Tosca)\n"
983                 + "        resourceVendorRelease: 1.0.0.wd03\n"
984                 + "        resourceVendorModelNumber: ''\n"
985                 + "      properties:\n"
986                 + "        mac_requirements:\n"
987                 + "          mac_count_required:\n"
988                 + "            is_required: false\n"
989                 + "        exCP_naming:\n"
990                 + "          ecomp_generated_naming: true\n"
991                 + "    zxjTestImportServiceAb 0:\n"
992                 + "      type: org.openecomp.resource.vf.Zxjtestimportserviceab\n"
993                 + "      metadata:\n"
994                 + "        invariantUUID: 41474f7f-3195-443d-a0a2-eb6020a56279\n"
995                 + "        UUID: 92e32e49-55f8-46bf-984d-a98c924037ec\n"
996                 + "        customizationUUID: 98c7a6c7-a867-45fb-8597-dd464f98e4aa\n"
997                 + "        version: '1.0'\n"
998                 + "        name: zxjTestImportServiceAb\n"
999                 + "        description: zxjTestImportServiceAbstract\n"
1000                 + "        type: VF\n"
1001                 + "        category: Generic\n"
1002                 + "        subcategory: Abstract\n"
1003                 + "        resourceVendor: zxjImportService\n"
1004                 + "        resourceVendorRelease: '1.0'\n"
1005                 + "        resourceVendorModelNumber: ''\n"
1006                 + "      properties:\n"
1007                 + "        nf_naming:\n"
1008                 + "          ecomp_generated_naming: true\n"
1009                 + "        skip_post_instantiation_configuration: true\n"
1010                 + "        multi_stage_design: 'false'\n"
1011                 + "        controller_actor: SO-REF-DATA\n"
1012                 + "        availability_zone_max_count: 1\n"
1013                 + "      requirements:\n"
1014                 + "      - mme_ipu_vdu.dependency:\n"
1015                 + "          capability: feature\n"
1016                 + "          node: ExtCP 0\n"
1017                 + "      - imagefile.dependency:\n"
1018                 + "          capability: feature\n"
1019                 + "          node: ext ZTE VL 0\n"
1020                 + "      capabilities:\n"
1021                 + "        mme_ipu_vdu.scalable:\n"
1022                 + "          properties:\n"
1023                 + "            max_instances: 1\n"
1024                 + "            min_instances: 1\n"
1025                 + "        mme_ipu_vdu.nfv_compute:\n"
1026                 + "          properties:\n"
1027                 + "            num_cpus: '2'\n"
1028                 + "            flavor_extra_specs: {\n"
1029                 + "              }\n"
1030                 + "            mem_size: '8192'\n"
1031                 + "  substitution_mappings:\n"
1032                 + "    node_type: org.openecomp.service.Ser09080002\n"
1033                 + "    capabilities:\n"
1034                 + "      extcp0.feature:\n"
1035                 + "      - ExtCP 0\n"
1036                 + "      - feature\n"
1037                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.monitoring_parameter:\n"
1038                 + "      - zxjTestServiceNotAbatract 0\n"
1039                 + "      - mme_ipu_vdu.monitoring_parameter\n"
1040                 + "      zxjtestimportserviceab0.imagefile.guest_os:\n"
1041                 + "      - zxjTestImportServiceAb 0\n"
1042                 + "      - imagefile.guest_os\n"
1043                 + "      zxjtestimportserviceab0.imagefile.feature:\n"
1044                 + "      - zxjTestImportServiceAb 0\n"
1045                 + "      - imagefile.feature\n"
1046                 + "      zxjtestservicenotabatract0.imagefile.guest_os:\n"
1047                 + "      - zxjTestServiceNotAbatract 0\n"
1048                 + "      - imagefile.guest_os\n"
1049                 + "      zxjtestimportserviceab0.ipu_cpd.feature:\n"
1050                 + "      - zxjTestImportServiceAb 0\n"
1051                 + "      - ipu_cpd.feature\n"
1052                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.virtualbinding:\n"
1053                 + "      - zxjTestServiceNotAbatract 0\n"
1054                 + "      - mme_ipu_vdu.virtualbinding\n"
1055                 + "      zxjtestimportserviceab0.mme_ipu_vdu.feature:\n"
1056                 + "      - zxjTestImportServiceAb 0\n"
1057                 + "      - mme_ipu_vdu.feature\n"
1058                 + "      extztevl0.feature:\n"
1059                 + "      - ext ZTE VL 0\n"
1060                 + "      - feature\n"
1061                 + "      zxjtestimportserviceab0.imagefile.image_fle:\n"
1062                 + "      - zxjTestImportServiceAb 0\n"
1063                 + "      - imagefile.image_fle\n"
1064                 + "      zxjtestimportserviceab0.mme_ipu_vdu.monitoring_parameter:\n"
1065                 + "      - zxjTestImportServiceAb 0\n"
1066                 + "      - mme_ipu_vdu.monitoring_parameter\n"
1067                 + "      zxjtestservicenotabatract0.ipu_cpd.feature:\n"
1068                 + "      - zxjTestServiceNotAbatract 0\n"
1069                 + "      - ipu_cpd.feature\n"
1070                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.nfv_compute:\n"
1071                 + "      - zxjTestServiceNotAbatract 0\n"
1072                 + "      - mme_ipu_vdu.nfv_compute\n"
1073                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.scalable:\n"
1074                 + "      - zxjTestServiceNotAbatract 0\n"
1075                 + "      - mme_ipu_vdu.scalable\n"
1076                 + "      extcp0.internal_connectionPoint:\n"
1077                 + "      - ExtCP 0\n"
1078                 + "      - internal_connectionPoint\n"
1079                 + "      zxjtestimportserviceab0.mme_ipu_vdu.virtualbinding:\n"
1080                 + "      - zxjTestImportServiceAb 0\n"
1081                 + "      - mme_ipu_vdu.virtualbinding\n"
1082                 + "      zxjtestservicenotabatract0.imagefile.image_fle:\n"
1083                 + "      - zxjTestServiceNotAbatract 0\n"
1084                 + "      - imagefile.image_fle\n"
1085                 + "      extztevl0.virtual_linkable:\n"
1086                 + "      - ext ZTE VL 0\n"
1087                 + "      - virtual_linkable\n"
1088                 + "      zxjtestservicenotabatract0.imagefile.feature:\n"
1089                 + "      - zxjTestServiceNotAbatract 0\n"
1090                 + "      - imagefile.feature\n"
1091                 + "      zxjtestimportserviceab0.localstorage.feature:\n"
1092                 + "      - zxjTestImportServiceAb 0\n"
1093                 + "      - localstorage.feature\n"
1094                 + "      zxjtestservicenotabatract0.localstorage.local_attachment:\n"
1095                 + "      - zxjTestServiceNotAbatract 0\n"
1096                 + "      - localstorage.local_attachment\n"
1097                 + "      zxjtestimportserviceab0.mme_ipu_vdu.scalable:\n"
1098                 + "      - zxjTestImportServiceAb 0\n"
1099                 + "      - mme_ipu_vdu.scalable\n"
1100                 + "      zxjtestservicenotabatract0.localstorage.feature:\n"
1101                 + "      - zxjTestServiceNotAbatract 0\n"
1102                 + "      - localstorage.feature\n"
1103                 + "      zxjtestimportserviceab0.mme_ipu_vdu.nfv_compute:\n"
1104                 + "      - zxjTestImportServiceAb 0\n"
1105                 + "      - mme_ipu_vdu.nfv_compute\n"
1106                 + "      zxjtestimportserviceab0.localstorage.local_attachment:\n"
1107                 + "      - zxjTestImportServiceAb 0\n"
1108                 + "      - localstorage.local_attachment\n"
1109                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.feature:\n"
1110                 + "      - zxjTestServiceNotAbatract 0\n"
1111                 + "      - mme_ipu_vdu.feature\n"
1112                 + "      zxjtestimportserviceab0.ipu_cpd.forwarder:\n"
1113                 + "      - zxjTestImportServiceAb 0\n"
1114                 + "      - ipu_cpd.forwarder\n"
1115                 + "      zxjtestservicenotabatract0.ipu_cpd.forwarder:\n"
1116                 + "      - zxjTestServiceNotAbatract 0\n"
1117                 + "      - ipu_cpd.forwarder\n"
1118                 + "    requirements:\n"
1119                 + "      zxjtestservicenotabatract0.imagefile.dependency:\n"
1120                 + "      - zxjTestServiceNotAbatract 0\n"
1121                 + "      - imagefile.dependency\n"
1122                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.local_storage:\n"
1123                 + "      - zxjTestServiceNotAbatract 0\n"
1124                 + "      - mme_ipu_vdu.local_storage\n"
1125                 + "      zxjtestservicenotabatract0.ipu_cpd.dependency:\n"
1126                 + "      - zxjTestServiceNotAbatract 0\n"
1127                 + "      - ipu_cpd.dependency\n"
1128                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.volume_storage:\n"
1129                 + "      - zxjTestServiceNotAbatract 0\n"
1130                 + "      - mme_ipu_vdu.volume_storage\n"
1131                 + "      zxjtestservicenotabatract0.ipu_cpd.virtualbinding:\n"
1132                 + "      - zxjTestServiceNotAbatract 0\n"
1133                 + "      - ipu_cpd.virtualbinding\n"
1134                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.dependency:\n"
1135                 + "      - zxjTestServiceNotAbatract 0\n"
1136                 + "      - mme_ipu_vdu.dependency\n"
1137                 + "      zxjtestservicenotabatract0.localstorage.dependency:\n"
1138                 + "      - zxjTestServiceNotAbatract 0\n"
1139                 + "      - localstorage.dependency\n"
1140                 + "      zxjtestimportserviceab0.imagefile.dependency:\n"
1141                 + "      - zxjTestImportServiceAb 0\n"
1142                 + "      - imagefile.dependency\n"
1143                 + "      zxjtestimportserviceab0.mme_ipu_vdu.volume_storage:\n"
1144                 + "      - zxjTestImportServiceAb 0\n"
1145                 + "      - mme_ipu_vdu.volume_storage\n"
1146                 + "      zxjtestimportserviceab0.ipu_cpd.virtualbinding:\n"
1147                 + "      - zxjTestImportServiceAb 0\n"
1148                 + "      - ipu_cpd.virtualbinding\n"
1149                 + "      extcp0.virtualLink:\n"
1150                 + "      - ExtCP 0\n"
1151                 + "      - virtualLink\n"
1152                 + "      extcp0.virtualBinding:\n"
1153                 + "      - ExtCP 0\n"
1154                 + "      - virtualBinding\n"
1155                 + "      zxjtestimportserviceab0.mme_ipu_vdu.guest_os:\n"
1156                 + "      - zxjTestImportServiceAb 0\n"
1157                 + "      - mme_ipu_vdu.guest_os\n"
1158                 + "      extcp0.dependency:\n"
1159                 + "      - ExtCP 0\n"
1160                 + "      - dependency\n"
1161                 + "      zxjtestimportserviceab0.localstorage.dependency:\n"
1162                 + "      - zxjTestImportServiceAb 0\n"
1163                 + "      - localstorage.dependency\n"
1164                 + "      zxjtestservicenotabatract0.ipu_cpd.virtualLink:\n"
1165                 + "      - zxjTestServiceNotAbatract 0\n"
1166                 + "      - ipu_cpd.virtualLink\n"
1167                 + "      extztevl0.dependency:\n"
1168                 + "      - ext ZTE VL 0\n"
1169                 + "      - dependency\n"
1170                 + "      zxjtestimportserviceab0.ipu_cpd.dependency:\n"
1171                 + "      - zxjTestImportServiceAb 0\n"
1172                 + "      - ipu_cpd.dependency\n"
1173                 + "      zxjtestimportserviceab0.mme_ipu_vdu.dependency:\n"
1174                 + "      - zxjTestImportServiceAb 0\n"
1175                 + "      - mme_ipu_vdu.dependency\n"
1176                 + "      zxjtestimportserviceab0.mme_ipu_vdu.local_storage:\n"
1177                 + "      - zxjTestImportServiceAb 0\n"
1178                 + "      - mme_ipu_vdu.local_storage\n"
1179                 + "      zxjtestimportserviceab0.ipu_cpd.virtualLink:\n"
1180                 + "      - zxjTestImportServiceAb 0\n"
1181                 + "      - ipu_cpd.virtualLink\n"
1182                 + "      extcp0.external_virtualLink:\n"
1183                 + "      - ExtCP 0\n"
1184                 + "      - external_virtualLink\n"
1185                 + "      zxjtestservicenotabatract0.mme_ipu_vdu.guest_os:\n"
1186                 + "      - zxjTestServiceNotAbatract 0\n"
1187                 + "      - mme_ipu_vdu.guest_os\n"
1188                 + "      zxjtestimportserviceab0.ipu_cpd.forwarder:\n"
1189                 + "      - zxjTestImportServiceAb 0\n"
1190                 + "      - ipu_cpd.forwarder\n"
1191                 + "      zxjtestservicenotabatract0.ipu_cpd.forwarder:\n"
1192                 + "      - zxjTestServiceNotAbatract 0\n"
1193                 + "      - ipu_cpd.forwarder\n";
1194     }
1195
1196     protected void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) {
1197         ResponseFormat actualResponse = e.getResponseFormat() != null ?
1198                 e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
1199         assertResponse(actualResponse, expectedStatus, variables);
1200     }
1201
1202     protected void assertResponse(ResponseFormat actualResponse, ActionStatus expectedStatus, String... variables) {
1203         ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
1204         assertEquals(expectedResponse.getStatus(), actualResponse.getStatus());
1205         assertEquals("assert error description", expectedResponse.getFormattedMessage(), actualResponse.getFormattedMessage());
1206     }
1207
1208 }