Reduce the number of problems in aai-common by removing unused imports
[aai/aai-common.git] / aai-schema-ingest / src / test / java / org / onap / aai / validation / nodes / NodeValidatorSchemaIncompleteTest.java
1 /** 
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-18 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.onap.aai.validation.nodes;
22
23 import java.io.ByteArrayOutputStream;
24 import java.io.IOException;
25 import java.io.OutputStream;
26 import java.io.OutputStreamWriter;
27
28 import javax.xml.transform.OutputKeys;
29 import javax.xml.transform.Transformer;
30 import javax.xml.transform.TransformerException;
31 import javax.xml.transform.TransformerFactory;
32 import javax.xml.transform.dom.DOMSource;
33 import javax.xml.transform.stream.StreamResult;
34
35 import org.junit.Ignore;
36 import org.junit.Rule;
37 import org.junit.Test;
38 import org.junit.rules.ExpectedException;
39 import org.junit.runner.RunWith;
40 import org.onap.aai.config.NodesConfiguration;
41 import org.onap.aai.nodes.NodeIngestor;
42 import org.onap.aai.setup.SchemaVersion;
43 import org.onap.aai.testutils.SchemaIncompleteTranslator;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.boot.test.context.SpringBootTest;
46 import org.springframework.test.context.ContextConfiguration;
47 import org.springframework.test.context.TestPropertySource;
48 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
49 import org.w3c.dom.Document;
50
51 @RunWith(SpringJUnit4ClassRunner.class)
52 @ContextConfiguration(classes = {SchemaIncompleteTranslator.class, NodesConfiguration.class})
53
54 @TestPropertySource(
55         properties = {
56                 "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
57 @SpringBootTest
58 @Ignore
59 public class NodeValidatorSchemaIncompleteTest {
60     @Autowired
61     NodeIngestor ni;
62
63     // set thrown.expect to whatever a specific test needs
64     // this establishes a default of expecting no exceptions to be thrown
65     @Rule
66     public ExpectedException thrown = ExpectedException.none();
67
68     // Throws a NullPointerException because a JavaType is referenced, but not defined
69     @Test
70     public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException {
71         thrown.expect(NullPointerException.class);
72
73         // TODO Change for Exception
74         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
75         printDocument(ni.getSchema(new SchemaVersion("v12")), buffer);
76     }
77
78     public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException {
79         TransformerFactory tf = TransformerFactory.newInstance();
80         Transformer transformer = tf.newTransformer();
81         transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
82         transformer.setOutputProperty(OutputKeys.METHOD, "xml");
83         transformer.setOutputProperty(OutputKeys.INDENT, "yes");
84         transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
85         transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
86
87         transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, "UTF-8")));
88     }
89 }