43f49a09b02d70b1a265f4cbd70f1a024fb99163
[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.Assert.assertTrue;
25
26 import java.io.IOException;
27 import java.util.Collections;
28 import java.util.List;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.aai.babel.service.data.BabelArtifact;
32 import org.onap.aai.babel.testdata.CsarTest;
33 import org.onap.aai.babel.util.ArtifactTestUtils;
34 import org.onap.aai.babel.xml.generator.data.Artifact;
35
36 /**
37  * Direct tests of the @{link ModelGenerator} implementation class (to improve code coverage). Not all methods are
38  * tested here. Most use cases are covered by direct tests of @{link CsarToXmlConverter}.
39  */
40 public class TestModelGenerator {
41
42     static {
43         System.setProperty("APP_HOME", ".");
44     }
45
46     @Before
47     public void setup() {
48         new ArtifactTestUtils().setGeneratorSystemProperties();
49     }
50
51     @Test(expected = Test.None.class /* no exception expected */)
52     public void testDefaultServiceVersion() throws XmlArtifactGenerationException, IOException {
53         Artifact ymlFile = new Artifact(null, null, null, null);
54         new ModelGenerator().generateArtifacts(CsarTest.SD_WAN_CSAR_FILE.getContent(),
55                 Collections.singletonList(ymlFile));
56     }
57
58     @Test
59     public void testSdncPropsParsed() throws XmlArtifactGenerationException, IOException {
60         Artifact ymlFile = new Artifact(null, null, null, null);
61         List<BabelArtifact> babelArtifactList = new ModelGenerator().generateArtifacts(CsarTest.PNF_VENDOR_CSAR.getContent(),
62             Collections.singletonList(ymlFile));
63         assertTrue(babelArtifactList.get(1).getPayload().contains("sdnc-model-name"));
64     }
65
66 }