1817b6e5cb0ac4c5a65e1a53a19b3b6ad61699e4
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / api / ComponentBaseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.api;
22
23 import ch.qos.logback.classic.Level;
24 import ch.qos.logback.classic.LoggerContext;
25 import com.aventstack.extentreports.ExtentTest;
26 import com.aventstack.extentreports.Status;
27 import com.thinkaurelius.titan.core.TitanFactory;
28 import com.thinkaurelius.titan.core.TitanGraph;
29 import com.thinkaurelius.titan.core.TitanVertex;
30 import org.apache.commons.collections.CollectionUtils;
31 import org.apache.commons.lang3.tuple.ImmutablePair;
32 import org.apache.commons.lang3.tuple.ImmutableTriple;
33 import org.apache.log4j.Logger;
34 import org.apache.tinkerpop.gremlin.structure.Direction;
35 import org.apache.tinkerpop.gremlin.structure.Vertex;
36 import org.junit.rules.TestName;
37 import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
38 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
39 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
40 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
41 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
42 import org.openecomp.sdc.be.model.*;
43 import org.openecomp.sdc.ci.tests.config.Config;
44 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
45 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
46 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
47 import org.openecomp.sdc.ci.tests.utils.Utils;
48 import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils;
49 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
50 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
51 import org.openecomp.sdc.ci.tests.utils.rest.*;
52 import org.slf4j.LoggerFactory;
53 import org.testng.ITestContext;
54 import org.testng.ITestResult;
55 import org.testng.annotations.*;
56
57 import java.io.File;
58 import java.io.FileNotFoundException;
59 import java.io.IOException;
60 import java.util.*;
61 import java.util.function.Consumer;
62 import java.util.stream.Collectors;
63
64 import static org.testng.AssertJUnit.assertEquals;
65 import static org.testng.AssertJUnit.assertNotNull;
66
67 public abstract class ComponentBaseTest {
68
69 //      private static Logger logger = LoggerFactory.getLogger(ComponentBaseTest.class.getName());
70         
71         protected static Logger logger= Logger.getLogger(ComponentBaseTest.class);      
72         
73
74 //       public ComponentBaseTest(TestName testName, String className) {
75 //       super(testName, className);
76 //       }
77
78         protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator;
79         private static final String VERSIONS_INFO_FILE_NAME = "versions.info";
80         private static final String REPORT_FILE_NAME = "SDC_CI_Extent_Report.html";
81         protected static TitanGraph titanGraph;
82         public static Config config;
83         protected static ITestContext myContext;
84         
85         
86         
87         /**************** METHODS ****************/
88         public static ExtentTest getExtendTest() {
89                 return ExtentTestManager.getTest();
90         }
91
92         public static enum ComponentOperationEnum {
93                 CREATE_COMPONENT, UPDATE_COMPONENT, GET_COMPONENT, DELETE_COMPONENT, CHANGE_STATE_CHECKIN, CHANGE_STATE_CHECKOUT, CHANGE_STATE_UNDO_CHECKOUT
94         };
95
96         public ComponentBaseTest(TestName name, String name2) {
97                 // TODO Auto-generated constructor stub
98                 LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
99                 lc.getLogger("com.thinkaurelius").setLevel(Level.INFO);
100                 lc.getLogger("com.datastax").setLevel(Level.INFO);
101                 lc.getLogger("io.netty").setLevel(Level.INFO);
102                 lc.getLogger("c.d").setLevel(Level.INFO);
103         }
104         
105         public static String getReportFolder() {
106                 return REPORT_FOLDER;
107         }
108
109         @BeforeSuite(alwaysRun = true)
110         public void setupBeforeSuite(ITestContext context) throws Exception {
111                 config = Utils.getConfig();
112                 myContext=context;
113                 ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context);       
114                 AtomicOperationUtils.createDefaultConsumer(true);
115                 openTitanLogic();
116                 performClean();
117                 
118                 
119
120         }
121         
122         @BeforeMethod(alwaysRun = true)
123         public void setBrowserBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception {
124
125
126 //                  String suiteName = ExtentManager.getSuiteName(context);
127 //                      ExtentTestManager.startTest(method.getName());
128 //                      ExtentTestManager.assignCategory(this.getClass());
129
130                 boolean emptyDataProvider = method.getAnnotation(Test.class).dataProvider().isEmpty();
131                 String className = method.getDeclaringClass().getName();
132                 if (!method.getName().equals("onboardVNFShotFlow"))  {
133                         System.out.println("ExtentReport instance started from BeforeMethod...");
134                         ExtentTestManager.startTest(method.getName());
135                         ExtentTestManager.assignCategory(this.getClass());
136
137                 } else {
138                         System.out.println("ExtentReport instance started from Test...");
139                 }
140       
141
142         }
143         
144         @AfterMethod(alwaysRun = true)
145         public void quitAfterTest(ITestResult result, ITestContext context) throws Exception {
146
147                 String testName = result.getName();
148                 Throwable throwable = result.getThrowable();
149                 int status = result.getStatus();
150                 
151                 switch(status){
152                 case ITestResult.SUCCESS:                               
153                         getExtendTest().log(Status.PASS, "Test Result : <span class='label success'>Success</span>");
154                         break;
155                                 
156                 case ITestResult.FAILURE:
157                         getExtendTest().log(Status.ERROR, "ERROR - The following exepction occured");
158                         getExtendTest().log(Status.ERROR, result.getThrowable());
159                         getExtendTest().log(Status.FAIL, "<span class='label failure'>Failure</span>");
160                         break;
161                         
162                 case ITestResult.SKIP:
163                         getExtendTest().log(Status.SKIP, "SKIP - The following exepction occured");
164                         break;
165                 default:
166                         break;
167                 }
168
169
170                 ExtentTestManager.endTest();
171         
172                 
173         }
174
175         @AfterClass(alwaysRun = true)
176         public synchronized static void cleanAfterClass() throws Exception{
177
178                 System.out.println("delete components AfterClass");
179                 deleteCreatedComponents(getCatalogAsMap());
180
181         }
182         
183         @AfterSuite(alwaysRun = true)
184         public static void shutdownTitan() throws Exception {
185                 
186                 performClean();
187                 shutdownTitanLogic();
188
189         }
190
191         protected static void openTitanLogic() throws Exception {
192         
193                 logger.trace(config.toString());
194                 String titanConfigFilePath = config.getTitanPropertiesFile();
195                 titanGraph = TitanFactory.open(titanConfigFilePath);
196                 assertNotNull(titanGraph);
197                 
198         }
199
200
201         protected static void shutdownTitanLogic() {
202                 if (titanGraph.isOpen()) {
203                         titanGraph.close();
204                 }
205                 CassandraUtils.close();
206         }
207
208         
209
210         public void setLog(String fromDataProvider) {
211
212                 String suiteName = ExtentManager.getSuiteName(myContext);
213                 ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
214                 ExtentTestManager.assignCategory(this.getClass());
215
216         }
217
218         protected static void performClean() throws Exception, FileNotFoundException {
219 //              cleanComponents();
220                 deleteCreatedComponents(getCatalogAsMap());
221                 CassandraUtils.truncateAllKeyspaces();
222         }
223
224         public void verifyErrorCode(RestResponse response, String action, int expectedCode) {
225                 assertNotNull("check response object is not null after " + action, response);
226                 assertNotNull("check error code exists in response after " + action, response.getErrorCode());
227                 assertEquals("Check response code after  + action" + action, expectedCode, response.getErrorCode().intValue());
228         }
229
230         private static void cleanComponents() throws Exception {
231
232                 // Components to delete
233                 List<String> vfResourcesToDelete = new ArrayList<String>();
234                 List<String> nonVfResourcesToDelete = new ArrayList<String>();
235                 List<String> servicesToDelete = new ArrayList<String>();
236                 List<String> productsToDelete = new ArrayList<String>();
237
238                 // Categories to delete
239                 List<ImmutableTriple<String, String, String>> productGroupingsToDelete = new ArrayList<>();
240                 List<ImmutablePair<String, String>> productSubsToDelete = new ArrayList<>();
241                 List<ImmutablePair<String, String>> resourceSubsToDelete = new ArrayList<>();
242                 List<String> productCategoriesToDelete = new ArrayList<>();
243                 List<String> resourceCategoriesToDelete = new ArrayList<String>();
244                 List<String> serviceCategoriesToDelete = new ArrayList<String>();
245
246                 List<String> resourcesNotToDelete = config.getResourcesNotToDelete();
247                 List<String> resourceCategoriesNotToDelete = config.getResourceCategoriesNotToDelete();
248                 List<String> serviceCategoriesNotToDelete = config.getServiceCategoriesNotToDelete();
249
250                 Iterable<TitanVertex> vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Resource.getName()).vertices();
251                 if (vertices != null) {
252                         Iterator<TitanVertex> iter = vertices.iterator();
253                         while (iter.hasNext()) {
254                                 Vertex vertex = iter.next();
255                                 Boolean isAbstract = vertex.value(GraphPropertiesDictionary.IS_ABSTRACT.getProperty());
256                                 // if (!isAbstract) {
257                                 String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
258                                 String version = vertex.value(GraphPropertiesDictionary.VERSION.getProperty());
259
260                                 if ((resourcesNotToDelete != null && !resourcesNotToDelete.contains(name)) || (version != null && !version.equals("1.0"))) {
261                                         String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
262                                         String resourceType = vertex.value(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty());
263                                         if (name.startsWith("ci")) {
264                                                 if (resourceType.equals(ResourceTypeEnum.VF.name())) {
265                                                         vfResourcesToDelete.add(id);
266                                                 } else {
267                                                         nonVfResourcesToDelete.add(id);
268                                                 }
269                                         }
270                                 } else if ((resourcesNotToDelete != null && !resourcesNotToDelete.contains(name)) || (version != null && version.equals("1.0"))) {
271                                         if ((boolean) vertex.value(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()) == false) {
272                                                 vertex.property(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
273                                         }
274                                 }
275                                 // }
276                         }
277                 }
278                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Service.getName()).vertices();
279                 if (vertices != null) {
280                         Iterator<TitanVertex> iter = vertices.iterator();
281                         while (iter.hasNext()) {
282                                 Vertex vertex = iter.next();
283                                 String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
284                                 String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
285                                 if (name.startsWith("ci")) {
286                                         servicesToDelete.add(id);
287                                 }
288                         }
289                 }
290
291                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Product.getName()).vertices();
292                 if (vertices != null) {
293                         Iterator<TitanVertex> iter = vertices.iterator();
294                         while (iter.hasNext()) {
295                                 Vertex vertex = iter.next();
296                                 String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
297                                 String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
298                                 if (name.startsWith("Ci")) {
299                                         productsToDelete.add(id);
300                                 }
301                         }
302                 }
303
304                 // Getting categories
305
306                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ResourceNewCategory.getName()).vertices();
307                 if (vertices != null) {
308                         Iterator<TitanVertex> iter = vertices.iterator();
309                         while (iter.hasNext()) {
310                                 Vertex category = iter.next();
311                                 String name = category.value(GraphPropertiesDictionary.NAME.getProperty());
312                                 if (!resourceCategoriesNotToDelete.contains(name)) {
313                                         String catId = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
314                                         resourceCategoriesToDelete.add(catId);
315                                         Iterator<Vertex> subs = category.vertices(Direction.OUT, GraphEdgeLabels.SUB_CATEGORY.getProperty());
316                                         while (subs.hasNext()) {
317                                                 Vertex sub = subs.next();
318                                                 String subCatId = sub.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
319                                                 resourceSubsToDelete.add(new ImmutablePair<String, String>(catId, subCatId));
320                                         }
321                                 }
322                         }
323                 }
324
325                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ServiceNewCategory.getName()).vertices();
326                 if (vertices != null) {
327                         Iterator<TitanVertex> iter = vertices.iterator();
328                         while (iter.hasNext()) {
329                                 Vertex category = iter.next();
330                                 String name = category.value(GraphPropertiesDictionary.NAME.getProperty());
331                                 if (!serviceCategoriesNotToDelete.contains(name)) {
332                                         String id = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
333                                         serviceCategoriesToDelete.add(id);
334                                 }
335                         }
336                 }
337
338                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ProductCategory.getName()).vertices();
339                 if (vertices != null) {
340                         Iterator<TitanVertex> iter = vertices.iterator();
341                         while (iter.hasNext()) {
342                                 Vertex category = iter.next();
343                                 String catId = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
344                                 productCategoriesToDelete.add(catId);
345                                 Iterator<Vertex> subs = category.vertices(Direction.OUT, GraphEdgeLabels.SUB_CATEGORY.getProperty());
346                                 while (subs.hasNext()) {
347                                         Vertex sub = subs.next();
348                                         String subCatId = sub.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
349                                         productSubsToDelete.add(new ImmutablePair<String, String>(catId, subCatId));
350                                         Iterator<Vertex> groupings = sub.vertices(Direction.OUT, GraphEdgeLabels.GROUPING.getProperty());
351                                         while (groupings.hasNext()) {
352                                                 Vertex grouping = groupings.next();
353                                                 String groupId = grouping.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
354                                                 productGroupingsToDelete.add(new ImmutableTriple<String, String, String>(catId, subCatId, groupId));
355                                         }
356                                 }
357
358                         }
359                 }
360
361                 titanGraph.tx().commit();
362
363                 String adminId = UserRoleEnum.ADMIN.getUserId();
364                 String productStrategistId = UserRoleEnum.PRODUCT_STRATEGIST1.getUserId();
365
366                 // Component delete
367                 for (String id : productsToDelete) {
368                         RestResponse deleteProduct = ProductRestUtils.deleteProduct(id, productStrategistId);
369
370                 }
371                 for (String id : servicesToDelete) {
372                         RestResponse deleteServiceById = ServiceRestUtils.deleteServiceById(id, adminId);
373
374                 }
375                 for (String id : vfResourcesToDelete) {
376                         RestResponse deleteResource = ResourceRestUtils.deleteResource(id, adminId);
377
378                 }
379
380                 for (String id : nonVfResourcesToDelete) {
381                         RestResponse deleteResource = ResourceRestUtils.deleteResource(id, adminId);
382
383                 }
384
385                 // Categories delete - product
386                 String componentType = BaseRestUtils.PRODUCT_COMPONENT_TYPE;
387                 for (ImmutableTriple<String, String, String> triple : productGroupingsToDelete) {
388                         CategoryRestUtils.deleteGrouping(triple.getRight(), triple.getMiddle(), triple.getLeft(), productStrategistId, componentType);
389                 }
390                 for (ImmutablePair<String, String> pair : productSubsToDelete) {
391                         CategoryRestUtils.deleteSubCategory(pair.getRight(), pair.getLeft(), productStrategistId, componentType);
392                 }
393                 for (String id : productCategoriesToDelete) {
394                         CategoryRestUtils.deleteCategory(id, productStrategistId, componentType);
395                 }
396
397                 // Categories delete - resource
398                 componentType = BaseRestUtils.RESOURCE_COMPONENT_TYPE;
399                 for (ImmutablePair<String, String> pair : resourceSubsToDelete) {
400                         CategoryRestUtils.deleteSubCategory(pair.getRight(), pair.getLeft(), adminId, componentType);
401                 }
402                 for (String id : resourceCategoriesToDelete) {
403                         CategoryRestUtils.deleteCategory(id, adminId, componentType);
404                 }
405                 // Categories delete - resource
406                 componentType = BaseRestUtils.SERVICE_COMPONENT_TYPE;
407                 for (String id : serviceCategoriesToDelete) {
408                         CategoryRestUtils.deleteCategory(id, adminId, componentType);
409                 }
410
411         }
412
413         private static void deleteCreatedComponents(Map<String, List<Component>> convertCatalogResponseToJavaObject) throws IOException {
414                 final String userId = UserRoleEnum.DESIGNER.getUserId();
415                 
416                 List<Component> resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.PRODUCT_PARAM_NAME);
417                 if (resourcesArrayList.size() > 0) {
418                         List<String> collect = buildCollectionUniqueId(resourcesArrayList);
419                         for (String uId : collect) {
420                                 ProductRestUtils.deleteProduct(uId, userId);
421                         }
422                 }
423                 
424                 
425                 resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.SERVICE_PARAM_NAME);
426                 if (resourcesArrayList.size() > 0) {
427                         List<String> collect = buildCollectionUniqueId(resourcesArrayList);
428                         for (String uId : collect) {
429                                 ServiceRestUtils.markServiceToDelete(uId, userId);
430                         }
431                         ServiceRestUtils.deleteMarkedServices(userId);
432                 }
433
434                 
435                 resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.RESOURCE_PARAM_NAME);
436
437                 // List<String> collect = resourcesArrayList.stream().filter(s ->
438                 // s.getName().startsWith("ci")).map(e ->
439                 // e.getUniqueId()).collect(Collectors.toList());
440
441                 // List<Map<String, String>> collect =
442                 // resourcesArrayList.stream().filter(s ->
443                 // s.getName().startsWith("ci")).map(e ->
444                 // e.getAllVersions()).collect(Collectors.toList());
445                 /*
446                  * List<String> collect = resourcesArrayList.stream().filter(s -> s.getName().startsWith("ci")) .flatMap(e -> e.getAllVersions().values().stream()).collect(Collectors.toList());
447                  */
448
449                 if (!CollectionUtils.isEmpty(resourcesArrayList)) {
450                         List<String> collect = buildCollectionUniqueId(resourcesArrayList);
451                         for (String uId : collect) {
452                                 ResourceRestUtils.markResourceToDelete(uId, userId);
453                         }
454                         ResourceRestUtils.deleteMarkedResources(userId);
455                 }
456
457         
458
459         }
460
461         private void deleteCollection(List<Component> componentArrayList, Consumer<String> deleteHandler) {
462
463                 if (componentArrayList.size() > 0) {
464                         List<String> collect = buildCollectionUniqueId(componentArrayList);
465                         for (String uId : collect) {
466                                 deleteHandler.accept(uId);
467                                 // ProductRestUtils.deleteProduct(uId, userId);
468                         }
469                 }
470         }
471
472         protected static List<String> buildCollectionUniqueId(List<Component> resourcesArrayList) {
473
474                 // Stream<String> flatMap = resourcesArrayList.stream().filter(s ->
475                 // s.getName().startsWith("ci")).map(e -> e.getAllVersions()).map( e ->
476                 // e.values()).flatMap( e -> e.stream());
477
478                 // List<String> collect = resourcesArrayList.stream()
479                 // //
480                 // .filter(s -> s.getName().startsWith("ci") )
481                 // //
482                 // .map(e -> e.getUniqueId())
483
484                 // .map( e -> e.values())
485                 // .filter(out -> out!=null )
486                 // .flatMap( e -> e.stream())
487                 // .collect(Collectors.toList());
488
489                 // List<String> collect = resourcesArrayList.stream().filter(s ->
490                 // s.getName().startsWith("ci"))
491                 // .flatMap(e ->
492                 // e.getAllVersions().values().stream()).collect(Collectors.toList());
493                 ComponentTypeEnum componentTypeEnum = resourcesArrayList.get(0).getComponentType();
494  
495                 List<String> genericCollection = new ArrayList<String>();
496                 
497                 resourcesArrayList.stream().filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")).map(e -> e.getUniqueId()).collect(Collectors.toList()).forEach((i) -> {
498                         buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i);
499                 });
500                 
501         
502                 //
503
504                 // List<String> collect =
505                 // genericCollection.stream().collect(Collectors.toList());
506
507                 return genericCollection;
508         }
509
510         public static void buildCollectionBaseOnComponentType(ComponentTypeEnum componentTypeEnum,
511                         List<String> genericCollection, String i) {
512                 try {
513                         switch (componentTypeEnum) {
514                         case RESOURCE:
515                                 RestResponse resource = ResourceRestUtils.getResource(i);
516                                 Resource convertResourceResponseToJavaObject = ResponseParser.convertResourceResponseToJavaObject(resource.getResponse());
517                                 Map<String, String> allVersions = convertResourceResponseToJavaObject.getAllVersions();
518                                 Collection<String> values = allVersions.values();
519                                 genericCollection.addAll(values);
520                                         
521                                 break;
522                         case SERVICE:
523                                 RestResponse service = ServiceRestUtils.getService(i);
524                                 Service convertServiceResponseToJavaObject = ResponseParser.convertServiceResponseToJavaObject(service.getResponse());
525                                 allVersions = convertServiceResponseToJavaObject.getAllVersions();
526                                 values = allVersions.values();
527                                 genericCollection.addAll(values);
528
529                                 break;
530                                         
531
532                         case PRODUCT:
533                                 RestResponse product = ProductRestUtils.getProduct(i);
534                                 Product convertProductResponseToJavaObject = ResponseParser.convertProductResponseToJavaObject(product.getResponse());
535                                 allVersions = convertProductResponseToJavaObject.getAllVersions();
536                                 values = allVersions.values();
537                                 genericCollection.addAll(values);
538
539                                 break;
540
541                         // default:
542                         // break;
543                         }
544                 } catch (Exception e1) {
545                         // TODO Auto-generated catch block
546                         e1.printStackTrace();
547                 }
548         }
549
550         protected static Map<String, List<Component>> getCatalogAsMap() throws Exception {
551                 RestResponse catalog = CatalogRestUtils.getCatalog(UserRoleEnum.DESIGNER.getUserId());
552                 Map<String, List<Component>> convertCatalogResponseToJavaObject = ResponseParser.convertCatalogResponseToJavaObject(catalog.getResponse());
553                 return convertCatalogResponseToJavaObject;
554         }
555         protected Resource createVfFromCSAR(User sdncModifierDetails, String csarId) throws Exception {
556                 // create new resource from Csar
557                 ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
558
559                 resourceDetails.setCsarUUID(csarId);
560                 resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
561                 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
562                 BaseRestUtils.checkCreateResponse(createResource);
563                 Resource createdResource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
564                 return createdResource;
565         }
566         
567
568
569 }