New docker start monitor engine
[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                 System.out.println(" method.getName() " + method.getName());
133                 if (!method.getName().equals("onboardVNFShotFlow"))  {
134                         System.out.println("ExtentReport instance started from BeforeMethod...");
135                         ExtentTestManager.startTest(method.getName());
136                         ExtentTestManager.assignCategory(this.getClass());
137
138                 } else {
139                         System.out.println("ExtentReport instance started from Test...");
140                 }
141       
142
143         }
144         
145         @AfterMethod(alwaysRun = true)
146         public void quitAfterTest(ITestResult result, ITestContext context) throws Exception {
147
148                 String testName = result.getName();
149                 Throwable throwable = result.getThrowable();
150                 int status = result.getStatus();
151                 
152                 switch(status){
153                 case ITestResult.SUCCESS:                               
154                         getExtendTest().log(Status.PASS, "Test Result : <span class='label success'>Success</span>");
155                         break;
156                                 
157                 case ITestResult.FAILURE:
158                         getExtendTest().log(Status.ERROR, "ERROR - The following exepction occured");
159                         getExtendTest().log(Status.ERROR, result.getThrowable());
160                         getExtendTest().log(Status.FAIL, "<span class='label failure'>Failure</span>");
161                         break;
162                         
163                 case ITestResult.SKIP:
164                         getExtendTest().log(Status.SKIP, "SKIP - The following exepction occured");
165                         break;
166                 default:
167                         break;
168                 }
169
170
171                 ExtentTestManager.endTest();
172         
173                 
174         }
175
176         @AfterClass(alwaysRun = true)
177         public synchronized static void cleanAfterClass() throws Exception{
178
179                 System.out.println("delete components AfterClass");
180                 deleteCreatedComponents(getCatalogAsMap());
181
182         }
183         
184         @AfterSuite(alwaysRun = true)
185         public static void shutdownTitan() throws Exception {
186                 
187                 performClean();
188                 shutdownTitanLogic();
189
190         }
191
192         protected static void openTitanLogic() throws Exception {
193         
194                 logger.trace(config.toString());
195                 String titanConfigFilePath = config.getTitanPropertiesFile();
196                 titanGraph = TitanFactory.open(titanConfigFilePath);
197                 assertNotNull(titanGraph);
198                 
199         }
200
201
202         protected static void shutdownTitanLogic() {
203                 if (titanGraph.isOpen()) {
204                         titanGraph.close();
205                 }
206                 CassandraUtils.close();
207         }
208
209         
210
211         public void setLog(String fromDataProvider) {
212
213                 String suiteName = ExtentManager.getSuiteName(myContext);
214                 ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
215                 ExtentTestManager.assignCategory(this.getClass());
216
217         }
218
219         protected static void performClean() throws Exception, FileNotFoundException {
220 //              cleanComponents();
221                 deleteCreatedComponents(getCatalogAsMap());
222                 CassandraUtils.truncateAllKeyspaces();
223         }
224
225         public void verifyErrorCode(RestResponse response, String action, int expectedCode) {
226                 assertNotNull("check response object is not null after " + action, response);
227                 assertNotNull("check error code exists in response after " + action, response.getErrorCode());
228                 assertEquals("Check response code after  + action" + action, expectedCode, response.getErrorCode().intValue());
229         }
230
231         private static void cleanComponents() throws Exception {
232
233                 // Components to delete
234                 List<String> vfResourcesToDelete = new ArrayList<String>();
235                 List<String> nonVfResourcesToDelete = new ArrayList<String>();
236                 List<String> servicesToDelete = new ArrayList<String>();
237                 List<String> productsToDelete = new ArrayList<String>();
238
239                 // Categories to delete
240                 List<ImmutableTriple<String, String, String>> productGroupingsToDelete = new ArrayList<>();
241                 List<ImmutablePair<String, String>> productSubsToDelete = new ArrayList<>();
242                 List<ImmutablePair<String, String>> resourceSubsToDelete = new ArrayList<>();
243                 List<String> productCategoriesToDelete = new ArrayList<>();
244                 List<String> resourceCategoriesToDelete = new ArrayList<String>();
245                 List<String> serviceCategoriesToDelete = new ArrayList<String>();
246
247                 List<String> resourcesNotToDelete = config.getResourcesNotToDelete();
248                 List<String> resourceCategoriesNotToDelete = config.getResourceCategoriesNotToDelete();
249                 List<String> serviceCategoriesNotToDelete = config.getServiceCategoriesNotToDelete();
250
251                 Iterable<TitanVertex> vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Resource.getName()).vertices();
252                 if (vertices != null) {
253                         Iterator<TitanVertex> iter = vertices.iterator();
254                         while (iter.hasNext()) {
255                                 Vertex vertex = iter.next();
256                                 Boolean isAbstract = vertex.value(GraphPropertiesDictionary.IS_ABSTRACT.getProperty());
257                                 // if (!isAbstract) {
258                                 String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
259                                 String version = vertex.value(GraphPropertiesDictionary.VERSION.getProperty());
260
261                                 if ((resourcesNotToDelete != null && !resourcesNotToDelete.contains(name)) || (version != null && !version.equals("1.0"))) {
262                                         String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
263                                         String resourceType = vertex.value(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty());
264                                         if (name.startsWith("ci")) {
265                                                 if (resourceType.equals(ResourceTypeEnum.VF.name())) {
266                                                         vfResourcesToDelete.add(id);
267                                                 } else {
268                                                         nonVfResourcesToDelete.add(id);
269                                                 }
270                                         }
271                                 } else if ((resourcesNotToDelete != null && !resourcesNotToDelete.contains(name)) || (version != null && version.equals("1.0"))) {
272                                         if ((boolean) vertex.value(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()) == false) {
273                                                 vertex.property(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
274                                         }
275                                 }
276                                 // }
277                         }
278                 }
279                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Service.getName()).vertices();
280                 if (vertices != null) {
281                         Iterator<TitanVertex> iter = vertices.iterator();
282                         while (iter.hasNext()) {
283                                 Vertex vertex = iter.next();
284                                 String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
285                                 String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
286                                 if (name.startsWith("ci")) {
287                                         servicesToDelete.add(id);
288                                 }
289                         }
290                 }
291
292                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Product.getName()).vertices();
293                 if (vertices != null) {
294                         Iterator<TitanVertex> iter = vertices.iterator();
295                         while (iter.hasNext()) {
296                                 Vertex vertex = iter.next();
297                                 String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
298                                 String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
299                                 if (name.startsWith("Ci")) {
300                                         productsToDelete.add(id);
301                                 }
302                         }
303                 }
304
305                 // Getting categories
306
307                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ResourceNewCategory.getName()).vertices();
308                 if (vertices != null) {
309                         Iterator<TitanVertex> iter = vertices.iterator();
310                         while (iter.hasNext()) {
311                                 Vertex category = iter.next();
312                                 String name = category.value(GraphPropertiesDictionary.NAME.getProperty());
313                                 if (!resourceCategoriesNotToDelete.contains(name)) {
314                                         String catId = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
315                                         resourceCategoriesToDelete.add(catId);
316                                         Iterator<Vertex> subs = category.vertices(Direction.OUT, GraphEdgeLabels.SUB_CATEGORY.getProperty());
317                                         while (subs.hasNext()) {
318                                                 Vertex sub = subs.next();
319                                                 String subCatId = sub.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
320                                                 resourceSubsToDelete.add(new ImmutablePair<String, String>(catId, subCatId));
321                                         }
322                                 }
323                         }
324                 }
325
326                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ServiceNewCategory.getName()).vertices();
327                 if (vertices != null) {
328                         Iterator<TitanVertex> iter = vertices.iterator();
329                         while (iter.hasNext()) {
330                                 Vertex category = iter.next();
331                                 String name = category.value(GraphPropertiesDictionary.NAME.getProperty());
332                                 if (!serviceCategoriesNotToDelete.contains(name)) {
333                                         String id = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
334                                         serviceCategoriesToDelete.add(id);
335                                 }
336                         }
337                 }
338
339                 vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ProductCategory.getName()).vertices();
340                 if (vertices != null) {
341                         Iterator<TitanVertex> iter = vertices.iterator();
342                         while (iter.hasNext()) {
343                                 Vertex category = iter.next();
344                                 String catId = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
345                                 productCategoriesToDelete.add(catId);
346                                 Iterator<Vertex> subs = category.vertices(Direction.OUT, GraphEdgeLabels.SUB_CATEGORY.getProperty());
347                                 while (subs.hasNext()) {
348                                         Vertex sub = subs.next();
349                                         String subCatId = sub.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
350                                         productSubsToDelete.add(new ImmutablePair<String, String>(catId, subCatId));
351                                         Iterator<Vertex> groupings = sub.vertices(Direction.OUT, GraphEdgeLabels.GROUPING.getProperty());
352                                         while (groupings.hasNext()) {
353                                                 Vertex grouping = groupings.next();
354                                                 String groupId = grouping.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
355                                                 productGroupingsToDelete.add(new ImmutableTriple<String, String, String>(catId, subCatId, groupId));
356                                         }
357                                 }
358
359                         }
360                 }
361
362                 titanGraph.tx().commit();
363
364                 String adminId = UserRoleEnum.ADMIN.getUserId();
365                 String productStrategistId = UserRoleEnum.PRODUCT_STRATEGIST1.getUserId();
366
367                 // Component delete
368                 for (String id : productsToDelete) {
369                         RestResponse deleteProduct = ProductRestUtils.deleteProduct(id, productStrategistId);
370
371                 }
372                 for (String id : servicesToDelete) {
373                         RestResponse deleteServiceById = ServiceRestUtils.deleteServiceById(id, adminId);
374
375                 }
376                 for (String id : vfResourcesToDelete) {
377                         RestResponse deleteResource = ResourceRestUtils.deleteResource(id, adminId);
378
379                 }
380
381                 for (String id : nonVfResourcesToDelete) {
382                         RestResponse deleteResource = ResourceRestUtils.deleteResource(id, adminId);
383
384                 }
385
386                 // Categories delete - product
387                 String componentType = BaseRestUtils.PRODUCT_COMPONENT_TYPE;
388                 for (ImmutableTriple<String, String, String> triple : productGroupingsToDelete) {
389                         CategoryRestUtils.deleteGrouping(triple.getRight(), triple.getMiddle(), triple.getLeft(), productStrategistId, componentType);
390                 }
391                 for (ImmutablePair<String, String> pair : productSubsToDelete) {
392                         CategoryRestUtils.deleteSubCategory(pair.getRight(), pair.getLeft(), productStrategistId, componentType);
393                 }
394                 for (String id : productCategoriesToDelete) {
395                         CategoryRestUtils.deleteCategory(id, productStrategistId, componentType);
396                 }
397
398                 // Categories delete - resource
399                 componentType = BaseRestUtils.RESOURCE_COMPONENT_TYPE;
400                 for (ImmutablePair<String, String> pair : resourceSubsToDelete) {
401                         CategoryRestUtils.deleteSubCategory(pair.getRight(), pair.getLeft(), adminId, componentType);
402                 }
403                 for (String id : resourceCategoriesToDelete) {
404                         CategoryRestUtils.deleteCategory(id, adminId, componentType);
405                 }
406                 // Categories delete - resource
407                 componentType = BaseRestUtils.SERVICE_COMPONENT_TYPE;
408                 for (String id : serviceCategoriesToDelete) {
409                         CategoryRestUtils.deleteCategory(id, adminId, componentType);
410                 }
411
412         }
413
414         private static void deleteCreatedComponents(Map<String, List<Component>> convertCatalogResponseToJavaObject) throws IOException {
415                 final String userId = UserRoleEnum.DESIGNER.getUserId();
416                 
417                 List<Component> resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.PRODUCT_PARAM_NAME);
418                 if (resourcesArrayList.size() > 0) {
419                         List<String> collect = buildCollectionUniqueId(resourcesArrayList);
420                         for (String uId : collect) {
421                                 ProductRestUtils.deleteProduct(uId, userId);
422                         }
423                 }
424                 
425                 
426                 resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.SERVICE_PARAM_NAME);
427                 if (resourcesArrayList.size() > 0) {
428                         List<String> collect = buildCollectionUniqueId(resourcesArrayList);
429                         for (String uId : collect) {
430                                 ServiceRestUtils.markServiceToDelete(uId, userId);
431                         }
432                         ServiceRestUtils.deleteMarkedServices(userId);
433                 }
434
435                 
436                 resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.RESOURCE_PARAM_NAME);
437
438                 // List<String> collect = resourcesArrayList.stream().filter(s ->
439                 // s.getName().startsWith("ci")).map(e ->
440                 // e.getUniqueId()).collect(Collectors.toList());
441
442                 // List<Map<String, String>> collect =
443                 // resourcesArrayList.stream().filter(s ->
444                 // s.getName().startsWith("ci")).map(e ->
445                 // e.getAllVersions()).collect(Collectors.toList());
446                 /*
447                  * List<String> collect = resourcesArrayList.stream().filter(s -> s.getName().startsWith("ci")) .flatMap(e -> e.getAllVersions().values().stream()).collect(Collectors.toList());
448                  */
449
450                 if (!CollectionUtils.isEmpty(resourcesArrayList)) {
451                         List<String> collect = buildCollectionUniqueId(resourcesArrayList);
452                         for (String uId : collect) {
453                                 ResourceRestUtils.markResourceToDelete(uId, userId);
454                         }
455                         ResourceRestUtils.deleteMarkedResources(userId);
456                 }
457
458         
459
460         }
461
462         private void deleteCollection(List<Component> componentArrayList, Consumer<String> deleteHandler) {
463
464                 if (componentArrayList.size() > 0) {
465                         List<String> collect = buildCollectionUniqueId(componentArrayList);
466                         for (String uId : collect) {
467                                 deleteHandler.accept(uId);
468                                 // ProductRestUtils.deleteProduct(uId, userId);
469                         }
470                 }
471         }
472
473         protected static List<String> buildCollectionUniqueId(List<Component> resourcesArrayList) {
474
475                 // Stream<String> flatMap = resourcesArrayList.stream().filter(s ->
476                 // s.getName().startsWith("ci")).map(e -> e.getAllVersions()).map( e ->
477                 // e.values()).flatMap( e -> e.stream());
478
479                 // List<String> collect = resourcesArrayList.stream()
480                 // //
481                 // .filter(s -> s.getName().startsWith("ci") )
482                 // //
483                 // .map(e -> e.getUniqueId())
484
485                 // .map( e -> e.values())
486                 // .filter(out -> out!=null )
487                 // .flatMap( e -> e.stream())
488                 // .collect(Collectors.toList());
489
490                 // List<String> collect = resourcesArrayList.stream().filter(s ->
491                 // s.getName().startsWith("ci"))
492                 // .flatMap(e ->
493                 // e.getAllVersions().values().stream()).collect(Collectors.toList());
494                 ComponentTypeEnum componentTypeEnum = resourcesArrayList.get(0).getComponentType();
495  
496                 List<String> genericCollection = new ArrayList<String>();
497                 
498                 resourcesArrayList.stream().filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")).map(e -> e.getUniqueId()).collect(Collectors.toList()).forEach((i) -> {
499                         buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i);
500                 });
501                 
502         
503                 //
504
505                 // List<String> collect =
506                 // genericCollection.stream().collect(Collectors.toList());
507
508                 return genericCollection;
509         }
510
511         public static void buildCollectionBaseOnComponentType(ComponentTypeEnum componentTypeEnum,
512                         List<String> genericCollection, String i) {
513                 try {
514                         switch (componentTypeEnum) {
515                         case RESOURCE:
516                                 RestResponse resource = ResourceRestUtils.getResource(i);
517                                 Resource convertResourceResponseToJavaObject = ResponseParser.convertResourceResponseToJavaObject(resource.getResponse());
518                                 Map<String, String> allVersions = convertResourceResponseToJavaObject.getAllVersions();
519                                 Collection<String> values = allVersions.values();
520                                 genericCollection.addAll(values);
521                                         
522                                 break;
523                         case SERVICE:
524                                 RestResponse service = ServiceRestUtils.getService(i);
525                                 Service convertServiceResponseToJavaObject = ResponseParser.convertServiceResponseToJavaObject(service.getResponse());
526                                 allVersions = convertServiceResponseToJavaObject.getAllVersions();
527                                 values = allVersions.values();
528                                 genericCollection.addAll(values);
529
530                                 break;
531                                         
532
533                         case PRODUCT:
534                                 RestResponse product = ProductRestUtils.getProduct(i);
535                                 Product convertProductResponseToJavaObject = ResponseParser.convertProductResponseToJavaObject(product.getResponse());
536                                 allVersions = convertProductResponseToJavaObject.getAllVersions();
537                                 values = allVersions.values();
538                                 genericCollection.addAll(values);
539
540                                 break;
541
542                         // default:
543                         // break;
544                         }
545                 } catch (Exception e1) {
546                         // TODO Auto-generated catch block
547                         e1.printStackTrace();
548                 }
549         }
550
551         protected static Map<String, List<Component>> getCatalogAsMap() throws Exception {
552                 RestResponse catalog = CatalogRestUtils.getCatalog(UserRoleEnum.DESIGNER.getUserId());
553                 Map<String, List<Component>> convertCatalogResponseToJavaObject = ResponseParser.convertCatalogResponseToJavaObject(catalog.getResponse());
554                 return convertCatalogResponseToJavaObject;
555         }
556         protected Resource createVfFromCSAR(User sdncModifierDetails, String csarId) throws Exception {
557                 // create new resource from Csar
558                 ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
559
560                 resourceDetails.setCsarUUID(csarId);
561                 resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
562                 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
563                 BaseRestUtils.checkCreateResponse(createResource);
564                 Resource createdResource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
565                 return createdResource;
566         }
567         
568
569
570 }