re base code
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / test / java / org / openecomp / sdc / translator / services / heattotosca / impl / functiontranslation / FunctionTranslationGetAttrImplTest.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.translator.services.heattotosca.impl.functiontranslation;
18
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants;
22 import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest;
23
24 import java.io.IOException;
25
26 public class FunctionTranslationGetAttrImplTest extends BaseResourceTranslationTest {
27
28   @Override
29   @Before
30   public void setUp() throws IOException {
31     // do not delete this function. it prevents the superclass setup from running
32   }
33
34   @Test
35   public void testTranslateGetAtt() throws Exception {
36     inputFilesPath =
37         "/mock/services/heattotosca/getAttr/getAttrUC/inputfiles";
38     outputFilesPath =
39         "/mock/services/heattotosca/getAttr/getAttrUC/expectedoutputfiles";
40     initTranslatorAndTranslate();
41     testTranslation();
42     validateGetAttribute(TestConstants.TEST_GET_ATTR_FOR_MORE_THAN_ONE_ATTR_IN_ATTR_LIST);
43   }
44
45   @Test
46   public void testTranslateGetAttUnsupportedResource() throws Exception {
47     inputFilesPath =
48         "/mock/services/heattotosca/getAttr/getAttrUnsupportedResource/inputfiles";
49     outputFilesPath =
50         "/mock/services/heattotosca/getAttr/getAttrUnsupportedResource/expectedoutputfiles";
51     initTranslatorAndTranslate();
52     testTranslation();
53     validateGetAttribute(TestConstants.TEST_IGNORE_GET_ATTR_FROM_OUTPUT);
54   }
55
56   @Test
57   public void testTranslateGetAttUnsupportedAttr() throws Exception {
58     inputFilesPath =
59         "/mock/services/heattotosca/getAttr/getAttrUnsupportedAttr/inputfiles";
60     outputFilesPath =
61         "/mock/services/heattotosca/getAttr/getAttrUnsupportedAttr/expectedoutputfiles";
62     initTranslatorAndTranslate();
63     testTranslation();
64     validateGetAttribute(TestConstants.TEST_GET_ATTR_FOR_NOT_SUPPORTED_ATTR_IN_ATTR_LIST);
65   }
66
67   @Test
68   public void testTranslateGetAttNestedAttr() throws Exception {
69     inputFilesPath =
70         "/mock/services/heattotosca/getAttrNestedAtt/inputfiles";
71     outputFilesPath =
72         "/mock/services/heattotosca/getAttrNestedAtt/expectedoutputfiles";
73     initTranslatorAndTranslate();
74     testTranslation();
75   }
76
77   @Test
78   public void testTranslateGetAttDynamicParam() throws Exception {
79     inputFilesPath =
80         "/mock/services/heattotosca/getAttrDynamicParam/inputfiles";
81     outputFilesPath =
82         "/mock/services/heattotosca/getAttrDynamicParam/expectedoutputfiles";
83     initTranslatorAndTranslate();
84     testTranslation();
85     validateGetAttribute(TestConstants.TEST_OUTPUT_GET_ATTR);
86   }
87
88   @Test
89   public void testTranslateGetAttOnlyResourceName() throws Exception {
90     inputFilesPath =
91         "/mock/services/heattotosca/getAttr/getAttrOnlyResourceName/inputfiles";
92     outputFilesPath =
93         "/mock/services/heattotosca/getAttr/getAttrOnlyResourceName/expectedoutputfiles";
94     initTranslatorAndTranslate();
95     testTranslation();
96     validateGetAttribute(TestConstants.TEST_GET_ATTR_FOR_ONLY_RESOURCE_NAME);
97   }
98
99   @Test
100   public void testTranslateGetAttNonePortOrCompute() throws Exception {
101     inputFilesPath =
102         "/mock/services/heattotosca/buildconsolidationdata/getattribute/noneToPortOrCompute/inputs";
103     outputFilesPath =
104         "/mock/services/heattotosca/buildconsolidationdata/getattribute/noneToPortOrCompute/expectedoutputfiles";
105     initTranslatorAndTranslate();
106     testTranslation();
107     validateGetAttribute(TestConstants.TEST_GET_ATTR_FOR_NONE_TO_PORT_OR_COMPUTE);
108   }
109
110   @Test
111   public void testTranslateDynamicGetAttrWithEmptyMapDefaultValue() throws IOException {
112     inputFilesPath =
113         "/mock/services/heattotosca/getAttrDynamicParamEmptyMap/inputs";
114     outputFilesPath =
115         "/mock/services/heattotosca/getAttrDynamicParamEmptyMap/expectedoutputfiles";
116     initTranslatorAndTranslate();
117     testTranslation();
118   }
119
120 }