2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.aai.util;
22 import static org.hamcrest.CoreMatchers.is;
23 import static org.junit.Assert.*;
27 import org.hamcrest.CoreMatchers;
28 import org.junit.Before;
29 import org.junit.Test;
31 import org.onap.aai.introspection.Version;
32 import org.onap.aai.util.genxsd.HTMLfromOXM;
33 import org.onap.aai.util.genxsd.HTMLfromOXMTest;
34 import org.onap.aai.util.genxsd.XSDElementTest;
35 import org.onap.aai.util.genxsd.YAMLfromOXM;
36 import org.onap.aai.util.genxsd.YAMLfromOXMTest;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
41 public class GenerateXsdTest {
42 private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class");
43 private String testXML;
46 public void setUp() throws Exception {
47 //PowerMockito.mockStatic(GenerateXsd.class);
48 XSDElementTest x = new XSDElementTest();
50 testXML = x.getTestXML();
54 public void test_generateSwaggerFromOxmFile( ) {
55 Version v = Version.v11;
56 String apiVersion = v.toString();
57 String fileContent = null;
58 File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
60 YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
61 fileContent = swagger.process();
62 } catch(Exception e) {
65 logger.debug(fileContent);
66 assertThat(fileContent, is(new YAMLfromOXMTest().YAMLresult()));
70 public void test_generateXSDFromOxmFile( ) {
72 Version v = Version.v11;
73 String fileContent = null;
75 HTMLfromOXM xsd = new HTMLfromOXM(testXML, v);
76 fileContent = xsd.process();
77 } catch(Exception e) {
80 logger.debug(fileContent);
81 assertThat(fileContent, is(new HTMLfromOXMTest().HTMLresult()));
85 public void testGetAPIVersion() {
86 GenerateXsd.apiVersion=Version.v11.name();
87 assertThat(GenerateXsd.getAPIVersion(),is("v11"));
91 public void testGetYamlDir() {
92 assertThat(GenerateXsd.getYamlDir(),is("../aai-schema/src/main/resources/aai_swagger_yaml"));
96 public void testGetResponsesUrl() {
97 assertNull(GenerateXsd.getResponsesUrl());