Toggle
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / test / java / org / openecomp / sdc / translator / services / heattotosca / impl / resourcetranslation / ResourceTranslationNovaServerImplTest.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.translator.services.heattotosca.impl.resourcetranslation;
22
23 import org.junit.AfterClass;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.openecomp.sdc.be.togglz.ToggleableFeature;
28 import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
29 import org.togglz.testing.TestFeatureManagerProvider;
30
31 import java.io.IOException;
32
33 import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_PORT_POSITIVE;
34 import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_POSITIVE;
35
36 public class ResourceTranslationNovaServerImplTest extends BaseResourceTranslationTest {
37
38   @Override
39   @Before
40   public void setUp() throws IOException {
41     // do not delete this function. it prevents the superclass setup from running
42   }
43   
44   @BeforeClass
45   public static void setUpClass() {
46       manager.enable(ToggleableFeature.DEFAULT_FEATURE);
47       TestFeatureManagerProvider.setFeatureManager(manager);
48   }
49
50
51   @Test
52   public void testTranslate() throws Exception {
53     inputFilesPath = "/mock/heat/resources/OS_Nova_Server/inputs";
54     outputFilesPath = "/mock/heat/resources/OS_Nova_Server/expectedoutputfiles";
55     initTranslatorAndTranslate();
56     testTranslation();
57     validateComputeTemplateConsolidationData(ConsolidationDataValidationType.VALIDATE_VOLUME,
58         TEST_VOLUME_POSITIVE);
59     validateComputeTemplateConsolidationData(ConsolidationDataValidationType.VALIDATE_PORT,
60         TEST_PORT_POSITIVE);
61   }
62
63   @Test
64   public void testTranslateWithOnlyPorts() throws Exception {
65     inputFilesPath = "/mock/heat/resources/Port/inputfiles";
66     outputFilesPath = "/mock/heat/resources/Port/expectedoutputfiles";
67     initTranslatorAndTranslate();
68     testTranslation();
69     validateComputeTemplateConsolidationData(ConsolidationDataValidationType.VALIDATE_PORT,
70         TEST_PORT_POSITIVE);
71   }
72   
73   @Test
74   public void testFabricConfigurationOnlyOnePortTrueAttrFlag() throws IOException {
75     inputFilesPath =
76         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/attr_flag/input";
77     outputFilesPath =
78         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/attr_flag/output";
79     initTranslatorAndTranslate();
80     testTranslation();
81   }
82
83   @Test
84   public void testFabricConfigurationOnlyOnePortTrueBindingProfile() throws IOException {
85       inputFilesPath =
86               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/binding_profile/input";
87       outputFilesPath =
88               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/binding_profile/output";
89       initTranslatorAndTranslate();
90       testTranslation();
91   }
92   
93   @Test
94   public void testFabricConfigurationAllFalseAttrFlag() throws IOException {
95     inputFilesPath =
96         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/attr_flag/input";
97     outputFilesPath =
98         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/attr_flag/output";
99     initTranslatorAndTranslate();
100     testTranslation();
101   }
102
103   @Test
104    public void testFabricConfigurationAllFalseBindingProfile() throws IOException {
105        inputFilesPath =
106                "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/binding_profile/input";
107        outputFilesPath =
108                "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/binding_profile/output";
109        initTranslatorAndTranslate();
110        testTranslation();
111    }
112   
113   @Test
114   public void testFabricConfigurationPropertyNullAttrFlag() throws IOException {
115     inputFilesPath =
116         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/attr_flag/input";
117     outputFilesPath =
118         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/attr_flag/output";
119     initTranslatorAndTranslate();
120     testTranslation();
121   }
122
123   @Test
124    public void testFabricConfigurationPropertyNullBindingProfile() throws IOException {
125      inputFilesPath =
126              "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/binding_profile/input";
127      outputFilesPath =
128              "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/binding_profile/output";
129      initTranslatorAndTranslate();
130      testTranslation();
131    }
132   
133   @Test
134   public void testFabricConfigurationWithoutPropertyAttrFlag() throws IOException {
135     inputFilesPath =
136         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/attr_flag/input";
137     outputFilesPath =
138         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/attr_flag/output";
139     initTranslatorAndTranslate();
140     testTranslation();
141   }
142
143   @Test
144   public void testFabricConfigurationWithoutPropertyBindingProfile() throws IOException {
145       inputFilesPath =
146               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/binding_profile/input";
147       outputFilesPath =
148               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/binding_profile/output";
149       initTranslatorAndTranslate();
150       testTranslation();
151   }
152
153   @Test
154   public void testFabricConfiguration2PortsAttrFlag() throws IOException {
155     inputFilesPath =
156         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/attr_flag/input";
157     outputFilesPath =
158         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/attr_flag/output";
159     initTranslatorAndTranslate();
160     testTranslation();
161   }
162
163   @Test
164   public void testFabricConfiguration2PortsWithBindingProfile() throws IOException {
165     inputFilesPath =
166             "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/binding_profile/input";
167     outputFilesPath =
168             "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/binding_profile/output";
169     initTranslatorAndTranslate();
170     testTranslation();
171   }
172   
173   
174   @AfterClass
175   public static void tearDownClass() {
176       manager.disable(ToggleableFeature.DEFAULT_FEATURE);
177       manager = null;
178       TestFeatureManagerProvider.setFeatureManager(null);
179   }
180
181   @Test
182   public void testFabricConfigurationMixedBothPropertiesTrue() throws IOException {
183       inputFilesPath =
184               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_both_properties_true/input";
185       outputFilesPath =
186               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_both_properties_true/output";
187       initTranslatorAndTranslate();
188       testTranslation();
189   }
190
191   @Test
192   public void testFabricConfigurationMixedOnePropertyTrue() throws IOException {
193       inputFilesPath =
194               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_one_property_true/input";
195       outputFilesPath =
196               "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_one_property_true/output";
197       initTranslatorAndTranslate();
198       testTranslation();
199   }
200
201     @Test
202     public void testFabricConfigurationMixedBothPropertiesFalse() throws IOException {
203         inputFilesPath =
204                 "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_both_properties_false/input";
205         outputFilesPath =
206                 "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_both_properties_false/output";
207         initTranslatorAndTranslate();
208         testTranslation();
209     }
210
211     @Test
212     public void testFabricConfigurationMixedBindingProfileIsNotMap() throws IOException {
213         inputFilesPath =
214                 "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_binding_profile_is_not_map/input";
215         outputFilesPath =
216                 "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_binding_profile_is_not_map/output";
217         initTranslatorAndTranslate();
218         testTranslation();
219     }
220
221     @Test
222     public void testFabricConfigurationMixedBindingProfileIsNull() throws IOException {
223         inputFilesPath =
224                 "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_binding_profile_is_null/input";
225         outputFilesPath =
226                 "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/mixed_binding_profile_is_null/output";
227         initTranslatorAndTranslate();
228         testTranslation();
229     }
230
231 }