44a0e20363450b9308e5362606cdc6330f677f2e
[sdc.git] /
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.common.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 enableFabricConfigurationTagging() {
46       manager.enable(ToggleableFeature.FABRIC_CONFIGURATION);
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 testFabricConfigurationOnlyOnePortTrue() throws IOException {
75     inputFilesPath =
76         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/input";
77     outputFilesPath =
78         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/output";
79     initTranslatorAndTranslate();
80     testTranslation();
81   }
82   
83   @Test
84   public void testFabricConfigurationAllFalse() throws IOException {
85     inputFilesPath =
86         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/input";
87     outputFilesPath =
88         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/output";
89     initTranslatorAndTranslate();
90     testTranslation();
91   }
92   
93   @Test
94   public void testFabricConfigurationPropertyNull() throws IOException {
95     inputFilesPath =
96         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/input";
97     outputFilesPath =
98         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/output";
99     initTranslatorAndTranslate();
100     testTranslation();
101   }
102   
103   @Test
104   public void testFabricConfigurationWithoutProperty() throws IOException {
105     inputFilesPath =
106         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/input";
107     outputFilesPath =
108         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/output";
109     initTranslatorAndTranslate();
110     testTranslation();
111   }
112   
113   @Test
114   public void testFabricConfiguration2Ports() throws IOException {
115     inputFilesPath =
116         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/input";
117     outputFilesPath =
118         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/output";
119     initTranslatorAndTranslate();
120     testTranslation();
121   }
122   
123   
124   @AfterClass
125   public static void disableFabricConfiguration() {
126       manager.disable(ToggleableFeature.FABRIC_CONFIGURATION);
127       manager = null;
128       TestFeatureManagerProvider.setFeatureManager(null);
129   }
130
131   
132   
133 }