[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / utils / Utils.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.utils;
22
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNotNull;
25 import static org.testng.AssertJUnit.assertTrue;
26
27 import java.io.File;
28 import java.io.FileInputStream;
29 import java.io.FileNotFoundException;
30 import java.io.InputStream;
31 import java.text.ParseException;
32 import java.text.SimpleDateFormat;
33 import java.util.ArrayList;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Map.Entry;
37
38 import org.apache.commons.lang3.StringUtils;
39 import org.apache.log4j.Logger;
40 import org.openecomp.sdc.ci.tests.config.Config;
41 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
42 import org.openecomp.sdc.common.api.ToscaNodeTypeInfo;
43 import org.openecomp.sdc.common.api.YamlConstants;
44 import org.yaml.snakeyaml.Yaml;
45
46 import com.google.gson.Gson;
47 import com.google.gson.JsonElement;
48 import com.google.gson.JsonObject;
49 import com.google.gson.JsonParser;
50
51 public final class Utils {
52
53         Gson gson = new Gson();
54
55         static Logger logger = Logger.getLogger(Utils.class.getName());
56
57         String contentTypeHeaderData = "application/json";
58         String acceptHeaderDate = "application/json";
59
60         public Utils() {
61                 /*
62                  * super();
63                  * 
64                  * StartTest.enableLogger(); logger =
65                  * Logger.getLogger(Utils.class.getName());
66                  */
67
68         }
69
70         // public String serviceTopologyPattern = "/topology/topology/%s";
71         // public String serviceTopologyTemplatePattern =
72         // "/topologytemplate/topologytemplate/%s";
73         //
74         // public String serviceTopologySearchPattern =
75         // "topology/topology/_search?q=%s";
76         // public String serviceTopologyTemplateSearchPattern =
77         // "topologytemplate/topologytemplate/_search?q=%s";
78         //
79         // public ArtifactTypeEnum getFileTypeByExtension(String fileName) {
80         //
81         // String fileExtension = null;
82         // if (fileName.matches("(.*)\\.(.*)")) {
83         // System.out.println(fileName.substring(fileName.lastIndexOf(".") + 1));
84         // fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
85         // }
86         //
87         // switch (fileExtension) {
88         // case "sh":
89         // return ArtifactTypeEnum.SHELL_SCRIPT;
90         // case "png":
91         // return ArtifactTypeEnum.ICON;
92         // case "ppp":
93         // return ArtifactTypeEnum.PUPPET;
94         // case "yang":
95         // return ArtifactTypeEnum.YANG;
96         // default:
97         // return ArtifactTypeEnum.UNKNOWN;
98         // }
99         //
100         // }
101         //
102         // public ArrayList<String> getScriptList (List<UploadArtifactInfo>
103         // artifactsList){
104         //
105         // ArrayList<String> scriptNameArray = new ArrayList<>();
106         // if (artifactsList != null){
107         // for (UploadArtifactInfo fileInArtifactsList : artifactsList){
108         // String artifactFileName = fileInArtifactsList.getArtifactName();
109         // ArtifactTypeEnum artifactFileType =
110         // fileInArtifactsList.getArtifactType();
111         // if (! artifactFileType.equals(ArtifactTypeEnum.ICON)){
112         // scriptNameArray.add(artifactFileName);
113         // }
114         // continue;
115         // }
116         // return scriptNameArray;
117         // }
118         // return null;
119         // }
120         //
121         //
122         // public String getYamlFileLocation(File testResourcesPath) {
123         // File[] files = testResourcesPath.listFiles();
124         // if (files.length == 0){
125         // return null;
126         // }else{
127         // for (int i = 0; i < files.length; i++){
128         // if (files[i].isFile()){
129         // return files[i].getAbsoluteFile().toString();
130         // }
131         // }
132         // }
133         // return null;
134         // }
135         //
136         // public String readFileContentToString (String fileName) throws
137         // IOException {
138         //
139         // Path path = Paths.get(fileName);
140         // String stringFromFile = new String(Files.readAllBytes(path));
141         // return stringFromFile;
142         //
143         //
144         // }
145         //
146         @SuppressWarnings("unchecked")
147         public ToscaNodeTypeInfo parseToscaNodeYaml(String fileContent) {
148
149                 ToscaNodeTypeInfo result = new ToscaNodeTypeInfo();
150                 Object templateVersion = null;
151                 Object templateName = null;
152
153                 if (fileContent != null) {
154                         Yaml yaml = new Yaml();
155
156                         Map<String, Object> yamlObject = (Map<String, Object>) yaml.load(fileContent);
157
158                         templateVersion = yamlObject.get(YamlConstants.TEMPLATE_VERSION);
159                         if (templateVersion != null) {
160                                 result.setTemplateVersion(templateVersion.toString());
161                         }
162                         templateName = yamlObject.get(YamlConstants.TEMPLATE_NAME);
163                         if (templateName != null) {
164                                 result.setTemplateName(templateName.toString());
165                         }
166                         Object nodeTypes = yamlObject.get(YamlConstants.NODE_TYPES);
167
168                         if (nodeTypes != null) {
169                                 Map<String, Object> nodeTypesMap = (Map<String, Object>) nodeTypes;
170                                 for (Entry<String, Object> entry : nodeTypesMap.entrySet()) {
171
172                                         String nodeName = entry.getKey();
173                                         if (nodeName != null) {
174                                                 result.setNodeName(nodeName);
175                                         }
176
177                                         break;
178
179                                 }
180                         }
181
182                 }
183
184                 return result;
185         }
186
187         //
188         //
189         // public ArtifactsMetadata getArtifactsMetadata(String response){
190         // ArtifactsMetadata artifactsMetadata = new ArtifactsMetadata();
191         //
192         // artifactsMetadata.setId(getJsonObjectValueByKey(response, "id"));
193         // artifactsMetadata.setName(getJsonObjectValueByKey(response, "name"));
194         // artifactsMetadata.setType(getJsonObjectValueByKey(response, "type"));
195         //
196         // artifactsMetadata.setCreator(getJsonObjectValueByKey(response,
197         // "creator"));
198         // artifactsMetadata.setCreationTime(getJsonObjectValueByKey(response,
199         // "creationTime"));
200         // artifactsMetadata.setLastUpdateTime(getJsonObjectValueByKey(response,
201         // "lastUpdateTime"));
202         // artifactsMetadata.setChecksum(getJsonObjectValueByKey(response,
203         // "checksum"));
204         // artifactsMetadata.setDescription(getJsonObjectValueByKey(response,
205         // "description"));
206         // artifactsMetadata.setLastUpdater(getJsonObjectValueByKey(response,
207         // "lastUpdater"));
208         //
209         // return artifactsMetadata;
210         // }
211         //
212         public static String getJsonObjectValueByKey(String metadata, String key) {
213                 JsonElement jelement = new JsonParser().parse(metadata);
214
215                 JsonObject jobject = jelement.getAsJsonObject();
216                 Object obj = jobject.get(key);
217                 if (obj == null) {
218                         return null;
219                 } else {
220                         String value;
221                         value = (String) jobject.get(key).getAsString();
222                         return value;
223                 }
224         }
225
226         public static Config getConfig() throws FileNotFoundException {
227                 Config config = Config.instance();
228                 return config;
229         }
230
231         // public void uploadNormativeTypes() throws IOException{
232         // Config config = getConfig();
233         // String[] normativeTypes = {"root", "compute", "blockStorage",
234         // "softwareComponent", "DBMS", "database", "network", "objectStorage",
235         // "webServer", "webApplication"};
236         // for( String normativeType : normativeTypes ){
237         // uploadComponent(config.getComponentsConfigDir()+File.separator+"normativeTypes"+File.separator+normativeType);
238         // }
239         //
240         // }
241         //
242         // public void uploadApacheComponent() throws IOException{
243         // Config config = getConfig();
244         // uploadComponent(config.getComponentsConfigDir()+File.separator+"apache");
245         // }
246         //
247         // public void uploadComponent(String componentDir) throws IOException{
248         //
249         // //*********************************************upload*************************************************************
250         // Config config = getConfig();
251         // ZipDirectory zipDirectory = new ZipDirectory();
252         // System.out.println(config.getEsHost());
253         //
254         // List<UploadArtifactInfo> artifactsList = new
255         // ArrayList<UploadArtifactInfo>();
256         //
257         //// read test resources and zip it as byte array
258         // byte[] zippedAsByteArray = zipDirectory.zip(componentDir, artifactsList);
259         //
260         //// encode zipped directory using base64
261         // String payload = Decoder.encode(zippedAsByteArray);
262         //
263         //// zip name build as testName with ".zip" extension
264         // String payloadZipName = getPayloadZipName(componentDir);
265         //
266         //// build json
267         // UploadResourceInfo resourceInfo = new UploadResourceInfo(payload,
268         // payloadZipName, "description", "category/mycategory", null,
269         // artifactsList);
270         // String json = new Gson().toJson(resourceInfo);
271         //
272         //// calculate md5 on the content of json
273         // String jsonMd5 =
274         // org.apache.commons.codec.digest.DigestUtils.md5Hex(json);
275         //
276         //// encode the md5 to base64, sent as header in post http request
277         // String encodedMd5 = Decoder.encode(jsonMd5.getBytes());
278         //
279         //// upload component to Elastic Search DB
280         // String url = null;
281         // HttpRequest http = new HttpRequest();
282         //
283         // url = String.format(Urls.UPLOAD_ZIP_URL, config.getCatalogFeHost(),
284         // config.getCatalogFePort());
285         //
286         //// Prepare headers to post upload component request
287         // HeaderData headerData = new HeaderData(encodedMd5, "application/json",
288         // "att", "test", "testIvanovich", "RoyalSeal", "Far_Far_Away",
289         // "getResourceArtifactListTest");
290         //
291         // MustHeaders headers = new MustHeaders(headerData);
292         // System.out.println("headers:"+headers.getMap());
293         //
294         // RestResponse response = http.httpSendPost(url, json, headers.getMap());
295         //
296         // assertEquals("upload component failed with code " +
297         // response.getErrorCode().intValue(),response.getErrorCode().intValue(),
298         // 204);
299         // }
300         //
301         // private String getPayloadZipName(String componentDir) {
302         // String payloadName;
303         // if( componentDir.contains( File.separator) ){
304         // String delimiter = null;
305         // if( File.separator.equals("\\")){
306         // delimiter ="\\\\";
307         // }
308         // else{
309         // delimiter = File.separator;
310         // }
311         // String[] split = componentDir.split(delimiter);
312         // payloadName = split[split.length-1];
313         // }
314         // else{
315         // payloadName = componentDir;
316         // }
317         // return payloadName+".zip";
318         // }
319         //
320         //
321         //
322         // public List<UploadArtifactInfo> createArtifactsList(String srcDir) {
323         //
324         // List<UploadArtifactInfo> artifactsList = new
325         // ArrayList<UploadArtifactInfo>();
326         // File srcFile = new File(srcDir);
327         // addFileToList(srcFile, artifactsList);
328         //
329         // return artifactsList;
330         // }
331         //
332         // public void addFileToList(File srcFile, List<UploadArtifactInfo>
333         // artifactsList) {
334         //
335         // File[] files = srcFile.listFiles();
336         //
337         // for (int i = 0; i < files.length; i++) {
338         // // if the file is directory, use recursion
339         // if (files[i].isDirectory()) {
340         // addFileToList(files[i], artifactsList);
341         // continue;
342         // }
343         //
344         // String fileName = files[i].getName();
345         // String artifactPath = fileName;
346         //
347         // if ( ! files[i].getName().matches("(.*)\\.y(?)ml($)")) {
348         // UploadArtifactInfo uploadArtifactInfo = new UploadArtifactInfo();
349         // uploadArtifactInfo.setArtifactName(files[i].getName());
350         // String parent = files[i].getParent();
351         //
352         // if (parent != null) {
353         // System.out.println(parent);
354         // int lastSepartor = parent.lastIndexOf(File.separator);
355         // if (lastSepartor > -1) {
356         // String actualParent = parent.substring(lastSepartor + 1);
357         // artifactPath = actualParent + "/" + artifactPath;
358         // }
359         // }
360         //
361         // uploadArtifactInfo.setArtifactPath(artifactPath);
362         // uploadArtifactInfo.setArtifactType(getFileTypeByExtension(fileName));
363         // uploadArtifactInfo.setArtifactDescription("description");
364         // artifactsList.add(uploadArtifactInfo);
365         //
366         // System.out.println("artifact list: " + artifactsList);
367         //
368         // }
369         //
370         // }
371         // }
372         //
373         //
374         // public String buildArtifactListUrl (String nodesType, String
375         // templateVersion, String artifactName) throws FileNotFoundException{
376         // //"http://172.20.43.132/sdc2/v1/catalog/resources/tosca.nodes.Root/1.0.0.wd03-SNAPSHOT/artifacts/wxs_baseline_compare.sh"
377         // Config config = getConfig();
378         // return "\"http://" + config.getCatalogBeHost() + ":" +
379         // config.getCatalogBePort() + "/sdc2/v1/catalog/resources/" +nodesType +
380         // "/" + templateVersion + "/artifacts/" + artifactName +"\"";
381         // }
382         //
383         //
384         // public void addTopologyToES(String testFolder, String
385         // serviceTopologyPattern) throws IOException{
386         // Config config = getConfig();
387         // String url = String.format(Urls.ES_URL, config.getEsHost(),
388         // config.getEsPort()) + serviceTopologyPattern;
389         // String sourceDir =
390         // config.getResourceConfigDir()+File.separator+testFolder;
391         // Path filePath = FileSystems.getDefault().getPath(sourceDir,
392         // "topology.txt");
393         // postFileContentsToUrl(url, filePath);
394         // }
395         //
396         // public void addTopologyTemplateToES(String testFolder, String
397         // serviceTopologyTemplatePattern) throws IOException{
398         // Config config = getConfig();
399         // String url = String.format(Urls.ES_URL, config.getEsHost(),
400         // config.getEsPort()) + serviceTopologyTemplatePattern;
401         // String sourceDir =
402         // config.getResourceConfigDir()+File.separator+testFolder;
403         // Path filePath = FileSystems.getDefault().getPath(sourceDir,
404         // "topologyTemplate.txt");
405         // postFileContentsToUrl(url, filePath);
406         // }
407         //
408         //
409         // public void postFileContentsToUrl(String url, Path filePath) throws
410         // IOException {
411         // HttpClientContext localContext = HttpClientContext.create();
412         // CloseableHttpResponse response = null;
413         //
414         // byte[] fileContent = Files.readAllBytes(filePath);
415         //
416         // try(CloseableHttpClient httpClient = HttpClients.createDefault()){
417         // HttpPost httpPost = new HttpPost(url);
418         // StringEntity entity = new StringEntity(new String(fileContent) ,
419         // ContentType.APPLICATION_JSON);
420         // httpPost.setEntity(entity);
421         // response = httpClient.execute(httpPost, localContext);
422         //
423         // }
424         // finally{
425         // response.close();
426         // }
427         //
428         //
429         // }
430         //
431         //
432         //// public boolean isPatternInEsDb(String patternToSearch)throws
433         // IOException{
434         //// Config config = getConfig();
435         //// String url = String.format(Urls.GET_SEARCH_DATA_FROM_ES,
436         // config.getEsHost(), config.getEsPort(),patternToSearch);
437         //// HttpRequest httpRequest = new HttpRequest();
438         //// RestResponse restResponse = httpRequest.httpSendGet(url);
439         //// if (restResponse.getErrorCode() == 200){
440         //// return true;
441         //// }
442         //// if (restResponse.getErrorCode() == 404){
443         //// return false;
444         //// }
445         ////
446         //// return false;
447         //// }
448         //
449         // public static RestResponse deleteAllDataFromEs() throws IOException{
450         // return deleteFromEsDbByPattern("_all");
451         // }
452         //
453
454         //
455         // public List<String> buildIdArrayListByTypesIndex (String index, String
456         // types) throws IOException{
457         //
458         // Config config = getConfig();
459         // HttpRequest http = new HttpRequest();
460         // RestResponse getResponce =
461         // http.httpSendGet(String.format(Urls.GET_ID_LIST_BY_INDEX_FROM_ES,
462         // config.getEsHost(), config.getEsPort(), index, types), null);
463         //
464         // List <String> idArray = new ArrayList<String>();
465         //
466         // JsonElement jelement = new JsonParser().parse(getResponce.getResponse());
467         // JsonObject jobject = jelement.getAsJsonObject();
468         // JsonObject hitsObject = (JsonObject) jobject.get("hits");
469         // JsonArray hitsArray = (JsonArray) hitsObject.get("hits");
470         // for (int i = 0; i < hitsArray.size(); i ++){
471         // JsonObject idObject = (JsonObject) hitsArray.get(i);
472         // String id = idObject.get("_id").toString();
473         // id = id.replace("\"", "");
474         // idArray.add(id);
475         // }
476         //
477         // return idArray;
478         // }
479         //
480         // public List<String> buildCategoriesTagsListFromJson(String
481         // categoriesTagsJson){
482         //
483         // ArrayList<String> categoriesTagsArray = new ArrayList<>();
484         // JsonElement jelement = new JsonParser().parse(categoriesTagsJson);
485         // JsonArray jArray = jelement.getAsJsonArray();
486         // for (int i = 0; i < jArray.size(); i ++){
487         // JsonObject categoriesTagsObject = (JsonObject) jArray.get(i);
488         // String categories = categoriesTagsObject.get("name").toString();
489         // categoriesTagsArray.add(categories);
490         // }
491         //
492         // return categoriesTagsArray;
493         // }
494         //
495         // public ArrayList <String> getCategoriesFromDb() throws Exception{
496         //
497         // ArrayList<String> categoriesFromDbArrayList = new ArrayList<>();
498         // RestResponse restResponse = new RestResponse();
499         // String contentTypeHeaderData = "application/json";
500         // String acceptHeaderDate = "application/json";
501         //
502         // Map<String, String> headersMap = new HashMap<String,String>();
503         // headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(),contentTypeHeaderData);
504         // headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
505         //
506         // HttpRequest httpRequest = new HttpRequest();
507         // String url = String.format(Urls.QUERY_NEO4J,
508         // Config.instance().getNeoHost(), Config.instance().getNeoPort());
509         // String body = "{\"statements\" : [ { \"statement\" : \"MATCH
510         // (category:category) return (category)\"} ]}";
511         // restResponse = httpRequest.httpSendPostWithAuth(url, body, headersMap,
512         // Config.instance().getNeoDBusername(),
513         // Config.instance().getNeoDBpassword());
514         //
515         // if (restResponse.getResponse()==null){
516         // return categoriesFromDbArrayList;
517         // }else{
518         // JsonElement jelement = new
519         // JsonParser().parse(restResponse.getResponse());
520         // JsonObject jobject = jelement.getAsJsonObject();
521         // JsonArray resultsArray = (JsonArray) jobject.get("results");
522         // JsonObject resObject = (JsonObject) resultsArray.get(0);
523         // JsonArray dataArray = (JsonArray) resObject.get("data");
524         // for (int i = 0; i < dataArray.size(); i ++){
525         // JsonObject rowObject = (JsonObject) dataArray.get(i);
526         // JsonArray rowArray = (JsonArray) rowObject.get("row");
527         // JsonObject nameObject = (JsonObject) rowArray.get(0);
528         // String name = nameObject.get("name").toString();
529         //// name = name.replace("\"", "");
530         // categoriesFromDbArrayList.add(name);
531         // }
532         //
533         //
534         // }
535         //
536         // return categoriesFromDbArrayList;
537         // }
538         //
539         public static void compareArrayLists(List<String> actualArraylList, List<String> expectedArrayList,
540                         String message) {
541
542                 ArrayList<String> actual = new ArrayList<String>(actualArraylList);
543                 ArrayList<String> expected = new ArrayList<String>(expectedArrayList);
544                 // assertEquals(message + " count got by rest API not match to " +
545                 // message + " expected count", expected.size(),actual.size());
546                 expected.removeAll(actual);
547                 assertEquals(message + " content got by rest API not match to " + message + " actual content", 0,
548                                 expected.size());
549         }
550
551         public static Object parseYamlConfig(String pattern) throws FileNotFoundException {
552
553                 Yaml yaml = new Yaml();
554                 Config config = getConfig();
555                 String configurationFile = config.getConfigurationFile();
556                 File file = new File(configurationFile);
557                 // File file = new
558                 // File("../catalog-be/src/main/resources/config/configuration.yaml");
559                 InputStream inputStream = new FileInputStream(file);
560                 Map<?, ?> map = (Map<?, ?>) yaml.load(inputStream);
561                 Object patternMap = (Object) map.get(pattern);
562
563                 return patternMap;
564         }
565
566         public static String getDepArtLabelFromConfig(ArtifactTypeEnum artifactTypeEnum) throws FileNotFoundException {
567
568                 @SuppressWarnings("unchecked")
569                 Map<String, Object> mapOfDepResArtTypesObjects = (Map<String, Object>) parseYamlConfig(
570                                 "deploymentResourceArtifacts");
571                 for (Map.Entry<String, Object> iter : mapOfDepResArtTypesObjects.entrySet()) {
572                         if (iter.getValue().toString().contains(artifactTypeEnum.getType())) {
573                                 return iter.getKey().toLowerCase();
574                         }
575                 }
576
577                 return "defaultLabelName";
578         }
579
580         
581         public static String multipleChar(String ch, int repeat) {
582                 return StringUtils.repeat(ch, repeat);
583         }
584         
585         public static List<String> getListOfDepResArtLabels(Boolean isLowerCase) throws FileNotFoundException {
586
587                 List<String> listOfResDepArtTypesFromConfig = new ArrayList<String>();
588                 @SuppressWarnings("unchecked")
589                 Map<String, Object> resourceDeploymentArtifacts = (Map<String, Object>) parseYamlConfig(
590                                 "deploymentResourceArtifacts");
591                 if (resourceDeploymentArtifacts != null) {
592
593                         if (isLowerCase) {
594                                 for (Map.Entry<String, Object> iter : resourceDeploymentArtifacts.entrySet()) {
595                                         listOfResDepArtTypesFromConfig.add(iter.getKey().toLowerCase());
596                                 }
597                         } else {
598
599                                 for (Map.Entry<String, Object> iter : resourceDeploymentArtifacts.entrySet()) {
600                                         listOfResDepArtTypesFromConfig.add(iter.getKey());
601                                 }
602                         }
603                 }
604                 return listOfResDepArtTypesFromConfig;
605         }
606
607         public static List<String> getListOfToscaArtLabels(Boolean isLowerCase) throws FileNotFoundException {
608
609                 List<String> listOfToscaArtTypesFromConfig = new ArrayList<String>();
610                 @SuppressWarnings("unchecked")
611                 Map<String, Object> toscaArtifacts = (Map<String, Object>) parseYamlConfig("toscaArtifacts");
612                 if (toscaArtifacts != null) {
613
614                         if (isLowerCase) {
615                                 for (Map.Entry<String, Object> iter : toscaArtifacts.entrySet()) {
616                                         listOfToscaArtTypesFromConfig.add(iter.getKey().toLowerCase());
617                                 }
618                         } else {
619                                 for (Map.Entry<String, Object> iter : toscaArtifacts.entrySet()) {
620                                         listOfToscaArtTypesFromConfig.add(iter.getKey());
621                                 }
622                         }
623                 }
624                 return listOfToscaArtTypesFromConfig;
625         }
626
627         //
628         // public static List<String> getListOfResDepArtTypes() throws
629         // FileNotFoundException {
630         //
631         // List<String> listOfResDepArtTypesFromConfig = new ArrayList<String>();
632         // @SuppressWarnings("unchecked")
633         // Map<String, Object> resourceDeploymentArtifacts = (Map<String, Object>)
634         // parseYamlConfig("resourceDeploymentArtifacts");
635         // for (Map.Entry<String, Object> iter :
636         // resourceDeploymentArtifacts.entrySet()) {
637         // listOfResDepArtTypesFromConfig.add(iter.getKey());
638         // }
639         //
640         // return listOfResDepArtTypesFromConfig;
641         // }
642         //
643         // public static List<String> getListOfDepResInstArtTypes() throws
644         // FileNotFoundException {
645         //
646         // List<String> listOfResInstDepArtTypesFromConfig = new
647         // ArrayList<String>();
648         // @SuppressWarnings("unchecked")
649         // Map<String, Object> resourceDeploymentArtifacts = (Map<String, Object>)
650         // parseYamlConfig("deploymentResourceInstanceArtifacts");
651         // for (Map.Entry<String, Object> iter :
652         // resourceDeploymentArtifacts.entrySet()) {
653         // listOfResInstDepArtTypesFromConfig.add(iter.getKey().toLowerCase());
654         // }
655         //
656         // return listOfResInstDepArtTypesFromConfig;
657         // }
658         //
659         public static List<String> getListOfResPlaceHoldersDepArtTypes() throws FileNotFoundException {
660                 List<String> listResDepArtTypesFromConfig = new ArrayList<String>();
661                 List<String> listOfResDepArtLabelsFromConfig = getListOfDepResArtLabels(false);
662                 assertNotNull("deployment artifact types list is null", listOfResDepArtLabelsFromConfig);
663                 Object parseYamlConfig = Utils.parseYamlConfig("deploymentResourceArtifacts");
664                 Map<String, Object> mapOfDepResArtTypesObjects = (Map<String, Object>) Utils
665                                 .parseYamlConfig("deploymentResourceArtifacts");
666
667                 // assertNotNull("deployment artifact types list is null",
668                 // mapOfDepResArtTypesObjects);
669                 if (listOfResDepArtLabelsFromConfig != null) {
670                         for (String resDepArtType : listOfResDepArtLabelsFromConfig) {
671                                 Object object = mapOfDepResArtTypesObjects.get(resDepArtType);
672                                 if (object instanceof Map<?, ?>) {
673                                         Map<String, Object> map = (Map<String, Object>) object;
674                                         listResDepArtTypesFromConfig.add((String) map.get("type"));
675                                 } else {
676                                         assertTrue("return object does not instance of map", false);
677                                 }
678                         }
679                 }
680                 return listResDepArtTypesFromConfig;
681         }
682
683         public static Long getEpochTimeFromUTC(String time) throws ParseException {
684             SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz");
685             java.util.Date date = df.parse(time);
686             long epoch = date.getTime();
687             return epoch;
688         }
689 }