6e1653137a7d82a9f136eb6060d1a4289ffd3959
[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.Before;
24 import org.junit.Test;
25 import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
26
27 import java.io.IOException;
28
29 import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_PORT_POSITIVE;
30 import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_POSITIVE;
31
32 public class ResourceTranslationNovaServerImplTest extends BaseResourceTranslationTest {
33
34   @Override
35   @Before
36   public void setUp() throws IOException {
37     // do not delete this function. it prevents the superclass setup from running
38   }
39
40   @Test
41   public void testTranslate() throws Exception {
42     inputFilesPath = "/mock/heat/resources/OS_Nova_Server/inputs";
43     outputFilesPath = "/mock/heat/resources/OS_Nova_Server/expectedoutputfiles";
44     initTranslatorAndTranslate();
45     testTranslation();
46     validateComputeTemplateConsolidationData(ConsolidationDataValidationType.VALIDATE_VOLUME,
47         TEST_VOLUME_POSITIVE);
48     validateComputeTemplateConsolidationData(ConsolidationDataValidationType.VALIDATE_PORT,
49         TEST_PORT_POSITIVE);
50   }
51
52   @Test
53   public void testTranslateWithOnlyPorts() throws Exception {
54     inputFilesPath = "/mock/heat/resources/Port/inputfiles";
55     outputFilesPath = "/mock/heat/resources/Port/expectedoutputfiles";
56     initTranslatorAndTranslate();
57     testTranslation();
58     validateComputeTemplateConsolidationData(ConsolidationDataValidationType.VALIDATE_PORT,
59         TEST_PORT_POSITIVE);
60   }
61   
62   @Test
63   public void testFabricConfigurationOnlyOnePortTrue() throws IOException {
64     inputFilesPath =
65         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/input";
66     outputFilesPath =
67         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/one_port_true/output";
68     initTranslatorAndTranslate();
69     testTranslation();
70   }
71   
72   @Test
73   public void testFabricConfigurationAllFalse() throws IOException {
74     inputFilesPath =
75         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/input";
76     outputFilesPath =
77         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/all_false/output";
78     initTranslatorAndTranslate();
79     testTranslation();
80   }
81   
82   @Test
83   public void testFabricConfigurationPropertyNull() throws IOException {
84     inputFilesPath =
85         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/input";
86     outputFilesPath =
87         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/property_null/output";
88     initTranslatorAndTranslate();
89     testTranslation();
90   }
91   
92   @Test
93   public void testFabricConfigurationWithoutProperty() throws IOException {
94     inputFilesPath =
95         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/input";
96     outputFilesPath =
97         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/without_property/output";
98     initTranslatorAndTranslate();
99     testTranslation();
100   }
101   
102   @Test
103   public void testFabricConfiguration2Ports() throws IOException {
104     inputFilesPath =
105         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/input";
106     outputFilesPath =
107         "/mock/services/heattotosca/novaservertranslation/fabricConfiguration/2ports/output";
108     initTranslatorAndTranslate();
109     testTranslation();
110   }
111   
112   
113 }