2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.babel.parser;
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.junit.Assert.assertThat;
27 import java.io.IOException;
28 import java.util.HashMap;
29 import java.util.List;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.aai.babel.csar.extractor.InvalidArchiveException;
34 import org.onap.aai.babel.testdata.CsarTest;
35 import org.onap.aai.babel.util.ArtifactTestUtils;
36 import org.onap.aai.babel.xml.generator.api.AaiArtifactGenerator;
37 import org.onap.aai.babel.xml.generator.data.AdditionalParams;
38 import org.onap.aai.babel.xml.generator.data.Artifact;
39 import org.onap.aai.babel.xml.generator.data.GenerationData;
42 * Direct tests of the {@link AaiArtifactGenerator} to improve code coverage.
44 public class TestToscaParser {
47 if (System.getProperty("APP_HOME") == null) {
48 System.setProperty("APP_HOME", ".");
54 new ArtifactTestUtils().setGeneratorSystemProperties();
58 public void testParserWithCsarFile() throws IOException, InvalidArchiveException {
59 List<Artifact> ymlFiles = CsarTest.VNF_VENDOR_CSAR.extractArtifacts();
60 Map<String, String> additionalParams = new HashMap<>();
61 additionalParams.put(AdditionalParams.SERVICE_VERSION.getName(), "1.0");
63 AaiArtifactGenerator generator = new AaiArtifactGenerator();
65 generator.generateArtifact(CsarTest.VNF_VENDOR_CSAR.getContent(), ymlFiles, additionalParams);
67 assertThat(data.getErrorData().size(), is(equalTo(0)));
68 assertThat(data.getResultData().size(), is(equalTo(2)));