push addional code
[sdc.git] / openecomp-be / lib / openecomp-heat-lib / src / test / java / org / openecomp / sdc / heat / datatypes / model / EnvironmentTest.java
1 package org.openecomp.sdc.heat.datatypes.model;
2
3 import org.openecomp.core.utilities.yaml.YamlUtil;
4 import org.junit.Test;
5
6 import java.io.InputStream;
7
8 public class EnvironmentTest {
9
10   @Test
11   public void testYamlToServiceTemplateObj() {
12     YamlUtil yamlUtil = new YamlUtil();
13     InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/envSettings.env");
14     Environment envVars = yamlUtil.yamlToObject(yamlFile, Environment.class);
15     envVars.toString();
16   }
17
18   @Test
19   public void test() {
20     String heatResourceName = "server_abc_0u";
21     String novaServerPrefix = "server_";
22     if (heatResourceName.startsWith(novaServerPrefix)) {
23       heatResourceName = heatResourceName.substring(novaServerPrefix.length());
24     }
25     int lastIndexOfUnderscore = heatResourceName.lastIndexOf("_");
26     if (heatResourceName.length() == lastIndexOfUnderscore) {
27       System.out.println(heatResourceName);
28     } else {
29       String heatResourceNameSuffix = heatResourceName.substring(lastIndexOfUnderscore + 1);
30       try {
31         Integer.parseInt(heatResourceNameSuffix);
32         System.out.println(heatResourceName.substring(0, lastIndexOfUnderscore));
33       } catch (NumberFormatException ignored) {
34         System.out.println(heatResourceName);
35       }
36     }
37   }
38 }