Create 1.13.0 maven release
[aai/babel.git] / src / test / java / org / onap / aai / babel / xml / generator / TestModelGenerator.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * Copyright (c) 2017-2019 European Software Marketing Ltd.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.aai.babel.xml.generator;
23
24 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
25 import static org.junit.jupiter.api.Assertions.assertTrue;
26
27 import java.io.IOException;
28 import java.util.Collections;
29 import java.util.List;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
32 import org.onap.aai.babel.service.data.BabelArtifact;
33 import org.onap.aai.babel.testdata.CsarTest;
34 import org.onap.aai.babel.util.ArtifactTestUtils;
35 import org.onap.aai.babel.xml.generator.data.Artifact;
36
37 /**
38  * Direct tests of the @{link ModelGenerator} implementation class (to improve code coverage). Not all methods are
39  * tested here. Most use cases are covered by direct tests of @{link CsarToXmlConverter}.
40  */
41 public class TestModelGenerator {
42
43     static {
44         System.setProperty("APP_HOME", ".");
45     }
46
47     @BeforeEach
48     public void setup() {
49         new ArtifactTestUtils().setGeneratorSystemProperties();
50     }
51
52     @Test
53     public void testDefaultServiceVersion() throws XmlArtifactGenerationException, IOException {
54         assertDoesNotThrow(() -> {
55             Artifact ymlFile = new Artifact(null, null, null, null);
56             new ModelGenerator().generateArtifacts(CsarTest.SD_WAN_CSAR_FILE.getContent(),
57                     Collections.singletonList(ymlFile));
58         });
59     }
60
61     @Test
62     public void testSdncPropsParsed() throws XmlArtifactGenerationException, IOException {
63         Artifact ymlFile = new Artifact(null, null, null, null);
64         List<BabelArtifact> babelArtifactList = new ModelGenerator().generateArtifacts(CsarTest.PNF_VENDOR_CSAR.getContent(),
65             Collections.singletonList(ymlFile));
66         assertTrue(babelArtifactList.get(1).getPayload().contains("sdnc-model-name"));
67     }
68
69 }