1 package org.openecomp.sdc.ci.tests.execute.sanity;
3 import com.aventstack.extentreports.Status;
4 import com.clearspring.analytics.util.Pair;
6 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
7 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
8 import org.openecomp.sdc.be.model.*;
9 import org.openecomp.sdc.be.model.Service;
10 import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders;
11 import org.openecomp.sdc.ci.tests.datatypes.*;
12 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
13 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
14 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
15 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
16 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
17 import org.openecomp.sdc.ci.tests.tosca.datatypes.*;
18 import org.openecomp.sdc.ci.tests.tosca.model.ToscaMetadataFieldsPresentationEnum;
19 import org.openecomp.sdc.ci.tests.utilities.DownloadManager;
20 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
21 import org.openecomp.sdc.ci.tests.utils.CsarParserUtils;
22 import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
23 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
24 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
25 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis;
26 import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
27 import org.openecomp.sdc.ci.tests.verificator.ToscaValidation;
28 import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
29 import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
30 import org.openecomp.sdc.toscaparser.api.Group;
31 import org.openecomp.sdc.toscaparser.api.NodeTemplate;
32 import org.openecomp.sdc.toscaparser.api.elements.Metadata;
33 import org.testng.Assert;
34 import org.testng.annotations.Test;
40 public class ToscaValidationTest extends SetupCDTest{
42 private static final String GENERIC_VF = "Generic_VF";
43 private static final String GENERIC_PNF = "Generic_PNF";
45 protected SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
46 User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
48 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
49 public void toscaFileValidator(String filePath, String vnfFile) throws Exception, Throwable{
50 //--------------------------GENERAL--------------------------------
51 /*// for debugging only
53 File amdocsCsarFileName = (new File("C:\\Users\\al714h\\Downloads\\d218be69637647b0b693647d84a8c03f.csar"));
54 toscaMainAmdocsDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName);
55 toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:\\Users\\al714h\\Downloads\\resource-Civfonboarded2016073VmxBv301072E2eE60f5c15-csar.csar"));
57 // vnfFile = "BE-HEAT.zip";
59 List<Boolean> status = new ArrayList<>();
60 ISdcCsarHelper fdntCsarHelper;
61 File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory());
62 //--------------------------AMDOCS--------------------------------
63 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, user);//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
64 resourceReqDetails = createCustomizedVsp(resourceReqDetails, filePath, vnfFile);
65 ToscaDefinition toscaMainAmdocsDefinition = downloadAndGetToscaMainYamlObjectUI(resourceReqDetails, filesFolder);
66 //------adding generic inputs to expected object
67 toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_VF);
69 ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition);
70 // create list of modules from HEAT.meta file
71 File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
72 List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(latestFilefromDir);
73 //TODO VfModuleVerificator.verifyGroupMetadata();
74 //TODO--------------------------AMDOCS DOWNLOAD VIA APIS--------------------------------
75 //--------------------------VF--------------------------------
76 // create VF base on VNF imported from previous step - have, resourceReqDetails object include part of resource metadata
77 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
78 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
79 ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder);
80 //--------------------------SERVICE--------------------------------
81 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
82 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
83 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
84 ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value();
85 //--------------------------getProperties set values and declare--------------------
86 Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER);
87 Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs();
88 setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition);
89 PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user);
91 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
92 File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar");
93 OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName));
94 ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName));
95 //--------------------------initialization of Tosca Parser--------------------------------
96 fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder);
97 ////---------------------------TESTS--------------------------------------------------
98 status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status);
99 status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status);
100 status = validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status);
101 status = validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status);
102 status = validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status);
103 status = validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status);
104 status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status);
105 status = validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status);
106 status = validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status);
108 Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject = createExpectedToscaServiceGroupsDefinitionObject(resource, service, listTypeHeatMetaDefinition);
109 status = validateServiceModuleMetadata(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition, vnfFile, status);
110 status = validateServiceModuleProperty(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition, vnfFile, status);
111 status = validateServiceModuleMetadataUsingParser(fdntCsarHelper, expectedToscaServiceGroupsDefinitionObject, vnfFile, status);
112 status = validateServiceModulePropertyUsingParser(fdntCsarHelper, expectedToscaServiceGroupsDefinitionObject, vnfFile, status);
114 if(status.contains(false)){
115 SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile);
116 Assert.assertFalse(true);
121 public void NetworkModel() throws Exception{
122 //--------------------------GENERAL--------------------------------
123 String vnfFile = "networkModel";
125 List<Boolean> status = new ArrayList<>();
126 ISdcCsarHelper fdntCsarHelper;
127 ToscaDefinition toscaMainAmdocsDefinition = new ToscaDefinition();
128 File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory());
129 // filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory());
131 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, user);
132 toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_PNF);
133 ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition);
134 //--------------------------VF--------------------------------
135 Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceReqDetails,UserRoleEnum.DESIGNER,true).left().value();
136 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
138 ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder);
140 //--------------------------SERVICE--------------------------------
141 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
142 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
144 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
145 ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value();
147 //--------------------------getProperties set values and declare--------------------
149 Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER);
150 Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs();
151 setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition);
152 PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user);
154 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
155 File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar");
156 OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName));
157 ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName));
159 //--------------------------initialization of Tosca Parser--------------------------------
161 fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder);
164 //---------------------------TESTS--------------------------------------------------
165 status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status);
166 status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status);
167 status = validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status);
168 status = validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status);
169 status = validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status);
170 status = validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status);
171 status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status);
172 status = validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status);
173 status = validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status);
175 if(status.contains(false)){
176 SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile);
177 Assert.assertFalse(true);
181 /**The method set values to toscaDefinition object service level only, to resource level should put instead of setDefault --> setValue
182 * inputs.get(componentInstanceInput.getName()).setValue(randomString);
183 * @param componentInstancesInputs
184 * @param toscaDefinition
186 private void setValuesToPropertiesList(Map<String, List<ComponentInstanceInput>> componentInstancesInputs, ToscaDefinition toscaDefinition) {
187 for(Map.Entry<String, List<ComponentInstanceInput>> entry : componentInstancesInputs.entrySet()) {
188 List<ComponentInstanceInput> value = entry.getValue();
189 String[] names = entry.getKey().split("\\.");
190 String expectedServiceInputPrefix = null;
191 Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs();
193 expectedServiceInputPrefix = names[names.length - 1] + "_";
195 for (ComponentInstanceInput componentInstanceInput :value) {
198 String type = componentInstanceInput.getType();
199 List<String> myList = new ArrayList<String>();
200 myList.add("cbf8049e-69e8-48c3-a06f-255634391403");
201 if (type.equals("string")) {
202 String randomString = getRandomString();
203 componentInstanceInput.setValue(randomString);
204 inputs.get(componentInstanceInput.getName()).setDefault(randomString);
207 else if (type.equals("integer") ) {
208 int randomInteger = getRandomInteger();
209 componentInstanceInput.setValue(Integer.toString(randomInteger));
210 inputs.get(componentInstanceInput.getName()).setDefault(randomInteger);
212 else if (type.equals("float") ){
213 componentInstanceInput.setValue("5.5");
214 inputs.get(componentInstanceInput.getName()).setDefault("5.5");
217 else if (type.equals("boolean") ){
218 componentInstanceInput.setValue("true");
219 inputs.get(componentInstanceInput.getName()).setDefault("true");
221 else if (type.equals("list") ){
222 String myListofStrings = myList.toString();
223 componentInstanceInput.setValue(myListofStrings);
224 inputs.get(componentInstanceInput.getName()).setDefault(myListofStrings);
226 else if (type.equals("json") ){
227 String myJson = "{\"firstParam\":\"my First Param Value\",\"secondParam\":\"my Second Param Value\",\"numberParam\":666}";
228 componentInstanceInput.setValue(myJson);
229 inputs.get(componentInstanceInput.getName()).setDefault(myJson);
231 else if (type.equals("comma_delimited_list") ){
232 String commaDelimitedList = "[\"one\", \"two\"]";
233 componentInstanceInput.setValue(commaDelimitedList);
234 inputs.get(componentInstanceInput.getName()).setDefault(commaDelimitedList);
237 String expectedServiceInputName = expectedServiceInputPrefix + componentInstanceInput.getName();
238 ToscaInputsTopologyTemplateDefinition oldInput = inputs.get(componentInstanceInput.getName());
239 inputs.put(expectedServiceInputName, oldInput);
240 inputs.remove(componentInstanceInput.getName());
247 protected String getRandomString() {
248 String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
249 StringBuilder salt = new StringBuilder();
250 Random rnd = new Random();
251 while (salt.length() < 18) { // length of the random string.
252 int index = (int) (rnd.nextFloat() * SALTCHARS.length());
253 salt.append(SALTCHARS.charAt(index));
255 String strValue = salt.toString();
260 protected int getRandomInteger() {
261 Random r = new Random();
264 int integerValue = r.nextInt(High - Low) + Low;
269 //--------------------------Metadata verification--------------------------------
270 //--------------------------Resource--------------------------------
272 public List<Boolean> validateVfMetadata(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, ResourceReqDetails resourceReqDetails,Resource resource, String vnfFile, List<Boolean> status) throws Exception{
273 reportStartTestPrint("validateVfMetadata", vnfFile);
274 //add resource metadata to expected object
275 toscaMainAmdocsDefinition = addAndGenerateResourceMetadataToExpectedObject(toscaMainAmdocsDefinition, resourceReqDetails, resource);
276 Either<Boolean,Map<String,Object>> resourceToscaMetadataValidator = ToscaValidation.resourceToscaMetadataValidator(toscaMainAmdocsDefinition, toscaMainVfDefinition);
277 if(resourceToscaMetadataValidator.isRight())
282 public List<Boolean> validateResourceNodeTemplateMetadata(ToscaDefinition toscaMainVfDefinition, Resource resource, String vnfFile, List<Boolean> status) throws Exception{
283 reportStartTestPrint("validateResourceNodeTemplateMetadata", vnfFile);
284 Map<String, Map<String, String>> generateReosurceNodeTemplateMetadataToExpectedObject = generateResourceNodeTemplateMetadataToExpectedObject(resource);
285 Boolean resourceToscaMetadataValidator = ToscaValidation.resourceToscaNodeTemplateMetadataValidator(generateReosurceNodeTemplateMetadataToExpectedObject, toscaMainVfDefinition);
286 if(! resourceToscaMetadataValidator)
291 //--------------------------Service--------------------------------
292 public List<Boolean> validateServiceMetadata(ToscaDefinition toscaMainServiceDefinition, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception{
293 reportStartTestPrint("validateServiceMetadata", vnfFile);
294 Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service);
295 Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(generateServiceMetadataToExpectedObject, toscaMainServiceDefinition);
296 if(serviceToscaMetadataValidator.isRight())
302 public List<Boolean> validateServiceNodeTemplateMetadata(ToscaDefinition toscaMainServiceDefinition, ComponentInstance componentInstanceDefinition, ResourceReqDetails resourceReqDetails, Resource resource, String vnfFile, List<Boolean> status) throws Exception{
303 reportStartTestPrint("validateServiceNodeTemplateMetadata", vnfFile);
304 Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition);
305 Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.componentToscaNodeTemplateMetadataValidator(generateServiceNodeTemplateMetadataToExpectedObject, toscaMainServiceDefinition, componentInstanceDefinition.getName(), ComponentTypeEnum.SERVICE, componentInstanceDefinition.getName());
306 if(serviceToscaMetadataValidator.isRight())
311 //--------------------------Service verification against Pavel Parser--------------------------------
312 public List<Boolean> validateServiceMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception{
313 if(fdntCsarHelper == null){
314 reportSkipTestPrint("validateServiceMetadataUsingParser", status);
316 reportStartTestPrint("validateServiceMetadataUsingParser", vnfFile);
317 Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service);
318 Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
319 Either<Boolean,Map<String, Object>> serviceToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceMetadataToExpectedObject, serviceMetadata);
320 if(serviceToscaMetadataValidatorAgainstParser.isRight())
326 public List<Boolean> validateServiceNodeTemplateMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ResourceReqDetails resourceReqDetails,Resource resource, ComponentInstance componentInstanceDefinition, String vnfFile, List<Boolean> status) throws Exception{
327 if(fdntCsarHelper == null){
328 reportSkipTestPrint("validateServiceNodeTemplateMetadataUsingParser", status);
330 reportStartTestPrint("validateServiceNodeTemplateMetadataUsingParser", vnfFile);
331 Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition);
332 List<NodeTemplate> serviceNodeTemplates = fdntCsarHelper.getServiceNodeTemplates();
333 Metadata serviceNodeTemplateMetadata = serviceNodeTemplates.get(0).getMetaData();
334 Either<Boolean,Map<String, Object>> serviceNodeTemplateToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceNodeTemplateMetadataToExpectedObject, serviceNodeTemplateMetadata);
335 if(serviceNodeTemplateToscaMetadataValidatorAgainstParser.isRight())
341 //--------------------------Input verification--------------------------------
343 //--------------------------Resource--------------------------------
344 public List<Boolean> validateResourceInputs(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, String vnfFile, List<Boolean> status) throws Exception{
345 reportStartTestPrint("validateResourceInputs", vnfFile);
346 Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaMainAmdocsDefinition.getTopology_template().getInputs();
347 Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainVfDefinition.getTopology_template().getInputs();
348 Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap);
349 if(toscaInputsValidator.isRight())
354 //--------------------------Service--------------------------------
356 public List<Boolean> validateServiceInputs(ToscaDefinition toscaExpectedMainServiceDefinition, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception{
357 reportStartTestPrint("validateServiceInputs", vnfFile);
358 Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs();
359 Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainServiceDefinition.getTopology_template().getInputs();
360 Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap);
361 if(toscaInputsValidator.isRight())
366 public List<Boolean> validateServiceModuleMetadata(Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) {
367 reportStartTestPrint("validateServiceModuleMetadata", vnfFile);
369 Either<Boolean,Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition);
370 if(toscaServiceModuleMetadataValidator.isRight())
375 public List<Boolean> validateServiceModuleProperty(Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) {
376 reportStartTestPrint("validateServiceModuleProperty", vnfFile);
378 Either<Boolean,Map<String, Object>> toscaServiceModulePropertyValidator = ToscaValidation.serviceToscaGroupPropertyValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition);
379 if(toscaServiceModulePropertyValidator.isRight())
384 //--------------------------Service verification against Pavel Parser--------------------------------
385 public List<Boolean> validateServiceInputsUsingParser(ISdcCsarHelper fdntCsarHelper, ToscaDefinition toscaExpectedMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception{
386 if(fdntCsarHelper == null){
387 reportSkipTestPrint("validateServiceInputsUsingParser", status);
389 reportStartTestPrint("validateServiceInputsUsingParser", vnfFile);
390 Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs();
391 Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidatorAgainstParser(expectedInputsMap, fdntCsarHelper);
392 if(toscaInputsValidator.isRight())
398 public List<Boolean> validateServiceModuleMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, String vnfFile, List<Boolean> status) {
399 reportStartTestPrint("validateServiceModuleMetadataUsingParser", vnfFile);
400 String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID");
401 List<Group> actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID);
402 Either<Boolean,Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups);
403 if(toscaServiceModuleMetadataValidator.isRight())
408 public List<Boolean> validateServiceModulePropertyUsingParser(ISdcCsarHelper fdntCsarHelper, Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, String vnfFile, List<Boolean> status) {
409 reportStartTestPrint("validateServiceModuleMetadataUsingParser", vnfFile);
410 String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID");
411 List<Group> actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID);
412 Either<Boolean,Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupPropertyValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups);
413 if(toscaServiceModuleMetadataValidator.isRight())
418 private Map<String, ToscaGroupsTopologyTemplateDefinition> createExpectedToscaServiceGroupsDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) {
419 Map<String, ToscaGroupsTopologyTemplateDefinition> toscaGroupsTopologyTemplateDefinitionMap = new HashMap<>();
421 for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) {
422 if (!moduleType.getTypeName().equals("artifacts")) {
423 for(GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()){
424 ToscaGroupsTopologyTemplateDefinition toscaGroupsTopologyTemplateDefinition = new ToscaGroupsTopologyTemplateDefinition();
425 String resourceModuleName = buildResourceModuleName(resource, module.getGroupName());
426 ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource);
427 if(!toscaServiceGroupsMetadataDefinition.equals("")){
428 String serviceModuleName = buildServiceModuleName(service.getComponentInstances().get(0).getNormalizedName(), toscaServiceGroupsMetadataDefinition.getVfModuleModelName());
429 toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, serviceModuleName, service);
430 toscaGroupsTopologyTemplateDefinition.setMetadata(toscaServiceGroupsMetadataDefinition);
431 ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = setGroupProperty(module);
432 toscaGroupsTopologyTemplateDefinition.setProperties(toscaGroupPropertyDefinition);
433 toscaGroupsTopologyTemplateDefinitionMap.put(serviceModuleName,toscaGroupsTopologyTemplateDefinition);
436 getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource");
441 return toscaGroupsTopologyTemplateDefinitionMap;
445 private ToscaGroupPropertyDefinition setGroupProperty(GroupHeatMetaDefinition module) {
446 ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = new ToscaGroupPropertyDefinition();
447 toscaGroupPropertyDefinition.setVf_module_label(module.getGroupName());
448 Boolean isBase = module.getPropertyHeatMetaDefinition().getValue();
450 toscaGroupPropertyDefinition.setInitial_count("1");
451 toscaGroupPropertyDefinition.setMin_vf_module_instances("1");
452 toscaGroupPropertyDefinition.setMax_vf_module_instances("1");
453 toscaGroupPropertyDefinition.setVf_module_type("Base");
455 toscaGroupPropertyDefinition.setInitial_count("0");
456 toscaGroupPropertyDefinition.setMin_vf_module_instances("0");
457 toscaGroupPropertyDefinition.setMax_vf_module_instances(null);
458 toscaGroupPropertyDefinition.setVf_module_type("Expansion");
460 toscaGroupPropertyDefinition.setAvailability_zone_count(null);
461 toscaGroupPropertyDefinition.setVfc_list(null);
462 toscaGroupPropertyDefinition.setVf_module_description(null);
463 toscaGroupPropertyDefinition.setVolume_group(isVolumeGroup(module));
465 return toscaGroupPropertyDefinition;
468 private String isVolumeGroup(GroupHeatMetaDefinition module) {
469 String isVolumeGroup = "false";
470 for( HeatMetaFirstLevelDefinition artifactList : module.getArtifactList()){
471 if(artifactList.getType().equals(ArtifactTypeEnum.HEAT_VOL.getType())){
472 isVolumeGroup = "true";
473 return isVolumeGroup;
476 return isVolumeGroup;
479 private Map<String,ToscaServiceGroupsMetadataDefinition> createExpectedToscaServiceGroupsPropertyDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) {
481 Map<String,ToscaServiceGroupsMetadataDefinition> toscaServiceGroupsMetadataDefinitionMap = new HashMap<>();
482 for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) {
483 Map<String, String> groupProperty = new HashMap<>();
485 ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = new ToscaServiceGroupsMetadataDefinition();
486 for(GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()){
487 String resourceModuleName = buildResourceModuleName(resource, module.getGroupName());
488 toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource);
489 if(!toscaServiceGroupsMetadataDefinition.equals("")){
490 String serviceModuleName = buildServiceModuleName(service.getComponentInstances().get(0).getNormalizedName(), toscaServiceGroupsMetadataDefinition.getVfModuleModelName());
491 toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, serviceModuleName, service);
492 toscaServiceGroupsMetadataDefinitionMap.put(serviceModuleName, toscaServiceGroupsMetadataDefinition);
494 getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource");
498 return toscaServiceGroupsMetadataDefinitionMap;
502 private ToscaServiceGroupsMetadataDefinition setGroupMetadataFromServiceObject(ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition, String serviceModuleName, Service service) {
503 for (GroupInstance groupInstance : service.getComponentInstances().get(0).getGroupInstances()) {
504 if (groupInstance.getName().equals(serviceModuleName)) {
505 toscaServiceGroupsMetadataDefinition.setVfModuleModelCustomizationUUID(groupInstance.getCustomizationUUID());
506 return toscaServiceGroupsMetadataDefinition;
509 return toscaServiceGroupsMetadataDefinition;
512 private ToscaServiceGroupsMetadataDefinition setGroupMetadataFromResourceObject(String resourceModuleName, Resource resource) {
513 ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = new ToscaServiceGroupsMetadataDefinition();
514 for (GroupDefinition group : resource.getGroups()) {
515 if (group.getName().contains(resourceModuleName)) {
516 toscaServiceGroupsMetadataDefinition.setVfModuleModelName(group.getName());
517 toscaServiceGroupsMetadataDefinition.setVfModuleModelInvariantUUID(group.getInvariantUUID());
518 toscaServiceGroupsMetadataDefinition.setVfModuleModelUUID(group.getGroupUUID());
519 toscaServiceGroupsMetadataDefinition.setVfModuleModelVersion(group.getVersion());
520 return toscaServiceGroupsMetadataDefinition;
523 return toscaServiceGroupsMetadataDefinition;
526 public static String buildResourceModuleName(Resource resource, String groupName ){
527 return resource.getSystemName()+".."+groupName+".."+"module-";
529 public static String buildServiceModuleName(String resourceInstanceNormalizedName, String resourceGroupName ){
530 return resourceInstanceNormalizedName+".."+resourceGroupName;
535 protected UserRoleEnum getRole() {
536 return UserRoleEnum.DESIGNER;
540 public static ToscaDefinition addGenericInputsToToscaObject(ToscaDefinition toscaDefinition, String genericName) throws Exception {
541 Resource genericResource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, genericName, "1.0");
542 ToscaTopologyTemplateDefinition topologyTemplate = toscaDefinition.getTopology_template();
543 Map<String, ToscaInputsTopologyTemplateDefinition> newInput = new HashMap<String, ToscaInputsTopologyTemplateDefinition>();
544 for (PropertyDefinition property : genericResource.getProperties()) {
545 ToscaInputsTopologyTemplateDefinition input = new ToscaInputsTopologyTemplateDefinition();
546 // input.setConstraints(property.getConstraints());
547 input.setDefault(property.getDefaultValue());
548 input.setDescription(property.getDescription());
549 // input.setEntry_schema(property.getSchema());
550 input.setName(property.getName());
551 // input.setRequired(property.get);
552 input.setStatus(property.getStatus());
553 input.setType(property.getType());
554 input.setValue(property.getValue());
555 newInput.put(property.getName(),input);
558 topologyTemplate.addInputs(newInput);
559 toscaDefinition.setTopology_template(topologyTemplate);
560 return toscaDefinition;
563 public static ToscaDefinition setNameToToscaInput(ToscaDefinition toscaDefinition) {
564 Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs();
565 for (String name : inputs.keySet()) {
566 inputs.get(name).setName(name);
568 toscaDefinition.getTopology_template().setInputs(inputs);
569 return toscaDefinition;
572 public static ToscaDefinition addAndGenerateResourceMetadataToExpectedObject(ToscaDefinition toscaDefinition, ResourceReqDetails resourceReqDetails, Component component) {
574 Map<String, String> metadata = convertResourceMetadataToMap(resourceReqDetails, component);
575 toscaDefinition.setMetadata(metadata);
576 return toscaDefinition;
579 public static Map<String, String> convertResourceMetadataToMap(ResourceReqDetails resourceReqDetails, Component component) {
580 Map<String, String> metadata = new HashMap<>();
582 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resourceReqDetails.getCategories().get(0).getName());
583 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resourceReqDetails.getDescription());
584 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID());
585 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resourceReqDetails.getResourceType());
586 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID());
587 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName());
589 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_NAME.value, resourceReqDetails.getVendorName());
590 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_MODEL_NUMBER.value, resourceReqDetails.getResourceVendorModelNumber());
591 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_RELEASE.value, resourceReqDetails.getVendorRelease());
592 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SUBCATEGORY.value, resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName());
596 public static Map<String, String> convertResourceNodeTemplateMetadataToMap(ComponentInstance componentInstance) throws Exception{
598 Resource resource = AtomicOperationUtils.getResourceObject(componentInstance.getComponentUid());
599 Map<String, String> metadata = new HashMap<>();
601 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resource.getCategories().get(0).getName());
602 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resource.getDescription());
603 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, resource.getInvariantUUID());
604 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resource.getResourceType().toString());
605 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, resource.getUUID());
606 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, resource.getName());
608 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_NAME.value, resource.getVendorName());
609 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_MODEL_NUMBER.value, resource.getResourceVendorModelNumber());
610 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_RELEASE.value, resource.getVendorRelease());
611 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SUBCATEGORY.value, resource.getCategories().get(0).getSubcategories().get(0).getName());
612 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CUSTOMIZATION_UUID.value, componentInstance.getCustomizationUUID());
613 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.VERSION.value, componentInstance.getComponentVersion());
618 public static Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject(ResourceReqDetails resourceReqDetails, Component component, ComponentInstance componentInstanceDefinition) {
620 Map<String, String> metadata = convertResourceMetadataToMap(resourceReqDetails, component);
621 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CUSTOMIZATION_UUID.value, componentInstanceDefinition.getCustomizationUUID());
622 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.VERSION.value, componentInstanceDefinition.getComponentVersion());
627 public static Map<String, Map<String, String>> generateResourceNodeTemplateMetadataToExpectedObject(Component component) throws Exception {
629 Map<String, Map<String, String>> resourcesNodeTemplateMetadataMap = new HashMap<>();
630 if(component.getComponentInstances() != null && component.getComponentInstances().size() != 0){
631 for (ComponentInstance componentInstance:component.getComponentInstances()){
632 Map<String, String> metadata = convertResourceNodeTemplateMetadataToMap(componentInstance);
633 resourcesNodeTemplateMetadataMap.put(componentInstance.getName(), metadata);
636 return resourcesNodeTemplateMetadataMap;
639 public static Map<String, String> generateServiceMetadataToExpectedObject(ServiceReqDetails serviceReqDetails, Component component) {
641 Map<String, String> metadata = new HashMap<>();
643 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, serviceReqDetails.getCategories().get(0).getName());
644 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, serviceReqDetails.getDescription());
645 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID());
646 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, "Service");
647 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID());
648 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName());
650 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_TYPE.value, serviceReqDetails.getServiceType());
651 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ROLE.value, serviceReqDetails.getServiceRole());
652 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAMING_POLICY.value, serviceReqDetails.getNamingPolicy());
653 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.ECOMP_GENERATED_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString());
654 metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ECOMP_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString());//equals to ECOMP_GENERATED_NAMING
659 public static void reportStartTestPrint (String testName, String vnfFile){
660 // reportMessageInColor("info", "blue", "Running test \" + testName + \" with zip file - \" + vnfFile");
661 SetupCDTest.getExtendTest().log(Status.INFO, "<html><font color=\"blue\"> Running test " + testName + " with zip file - " + vnfFile + "</font></html>");
663 public static void reportSkipTestPrint (String testName, List<Boolean> status){
664 // reportMessageInColor("error", "orange", "Skip test \" + testName + \" due to previous tosca parser error");
665 SetupCDTest.getExtendTest().log(Status.ERROR, "<html><font color=\"orange\"> Skip test " + testName + " due to previous tosca parser error" + "</font></html>");
669 public static void reportMessageInColor(String status, String color, String message){
670 String printLine = getReportMessageInColor(color, message);
671 SetupCDTest.getExtendTest().log(Status.valueOf(status), printLine);
672 // SetupCDTest.getExtendTest().log(Status.valueOf(status), getReportMessageInColor(color, message));
675 * @param color = red, green, orange, blue ...
676 * @param message - message string
677 * @return string in desired color
679 public static String getReportMessageInColor(String color, String message){
680 String returnValue = ("<html><font color=\\\"+color+\"\">" + message + "</font></html>").toString();
685 public void printTest(){
686 System.out.println("print");
687 reportMessageInColor("ERROR", "green", "green");
688 reportMessageInColor("INFO", "orange", "orange");
689 reportMessageInColor("INFO", "red", "red");
693 public void allottedResourceModelTest() throws Exception{
694 List<Boolean> status = new ArrayList<>();
696 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
697 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder);
698 String vnfFile = newRandomFileNamesFromFolder.get(0);
700 String filePath = FileHandling.getVnfRepositoryPath();
701 File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory());
703 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.ALLOTTED_RESOURCE_SERVICE_ADMIN);
704 resourceReqDetails = createCustomizedVsp(resourceReqDetails, filePath, vnfFile);
706 ToscaDefinition toscaMainAmdocsDefinition = downloadAndGetToscaMainYamlObjectUI(resourceReqDetails, filesFolder);
707 toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_VF);
709 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
710 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
712 ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder);
714 status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status);
715 status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status);
716 status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status);
718 if(status.contains(false)){
719 SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: allottedResourceModelTest tosca validation test failed with zip file " + vnfFile);
720 Assert.assertFalse(true);
727 // help method to toscaValidation tests
728 private ISdcCsarHelper initSdcCsarHelper(File serviceCsarFileName, File filesFolder) {
730 ISdcCsarHelper fdntCsarHelper;
732 SetupCDTest.getExtendTest().log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object...");
733 fdntCsarHelper = factory.getSdcCsarHelper(filesFolder.getPath() + serviceCsarFileName);
735 SetupCDTest.getExtendTest().log(Status.ERROR, "Tosca parser FAILED to convert service csar file to ISdcCsarHelper object...");
736 SetupCDTest.getExtendTest().log(Status.FAIL, e);
737 fdntCsarHelper = null;
739 return fdntCsarHelper;
744 * @param resourceReqDetails to create Vsp
745 * @return updated resourceReqDetails after Vsp was created
747 private ResourceReqDetails createCustomizedVsp(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception {
748 Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user);
749 VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
750 vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left);
751 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
752 return resourceReqDetails;
756 * @param resourceReqDetails to download csar file via UI
757 * @return Tosca definition object from main yaml file
759 private ToscaDefinition downloadAndGetToscaMainYamlObjectUI(ResourceReqDetails resourceReqDetails, File filesFolder) throws Exception {
760 DownloadManager.downloadCsarByNameFromVSPRepository(resourceReqDetails.getName(), false);
761 File amdocsCsarFileName = FileHandling.getLastModifiedFileNameFromDir(filesFolder.getAbsolutePath());
762 return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName);
766 * @param toscaMainAmdocsDefinition object to add generic properties
767 * @param genericName resource name
768 * @return updated toscaMainAmdocsDefinition object
770 private ToscaDefinition addGenericPropertiesToToscaDefinitionObject(ToscaDefinition toscaMainAmdocsDefinition, String genericName) throws Exception {
771 toscaMainAmdocsDefinition = setNameToToscaInput(toscaMainAmdocsDefinition);
772 toscaMainAmdocsDefinition = addGenericInputsToToscaObject(toscaMainAmdocsDefinition, genericName);
773 return toscaMainAmdocsDefinition;
777 * @param resource to download csar file via API
778 * @return Tosca definition object from main yaml file
780 private ToscaDefinition downloadAndGetToscaMainYamlObjectApi(Resource resource, File filesFolder) throws Exception {
781 File VfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar");
782 OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + VfCsarFileName));
783 return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + VfCsarFileName));