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=========================================================
21 package org.onap.aai.schemagen.genxsd;
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.junit.Assert.assertThat;
26 import java.util.HashMap;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.w3c.dom.Element;
32 public class XSDJavaTypeTest extends XSDElementTest {
35 public void setUp() throws Exception {
40 public void testXSDJavaTypeElement() {
41 HashMap<String, String> map = new HashMap<String, String>();
42 HashMap<String, String> target = new HashMap<String, String>();
43 target.put("Customer", "global-customer-id");
44 target.put("Business", "customers");
45 target.put("Inventory", "business");
46 target.put("Customers", "customer");
47 target.put("ServiceSubscriptions", "service-subscription");
48 target.put("ServiceSubscription", "service-type");
50 for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
51 XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
52 XSDJavaType javaType = new XSDJavaType(javaTypeElement);
53 map.put(javaType.name(), javaType.getItemName());
55 for (String key : map.keySet()) {
56 assertThat("For key: " + key, map.get(key), equalTo(target.get(key)));
61 public void testGetItemName() {
62 HashMap<String, String> map = new HashMap<String, String>();
63 HashMap<String, String> target = new HashMap<String, String>();
64 target.put("Customer", "global-customer-id");
65 target.put("Business", "customers");
66 target.put("Inventory", "business");
67 target.put("Customers", "customer");
68 target.put("ServiceSubscriptions", "service-subscription");
69 target.put("ServiceSubscription", "service-type");
71 for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
72 XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
73 XSDJavaType javaType = new XSDJavaType(javaTypeElement);
74 map.put(javaType.name(), javaType.getItemName());
76 for (String key : map.keySet()) {
77 assertThat("For key: " + key, map.get(key), equalTo(target.get(key)));
82 public void testGetArrayType() {
83 HashMap<String, String> map = new HashMap<String, String>();
84 HashMap<String, String> target = new HashMap<String, String>();
85 target.put("Customer", null);
86 target.put("Business", null);
87 target.put("Inventory", null);
88 target.put("Customers", "customer");
89 target.put("ServiceSubscriptions", "service-subscription");
90 target.put("ServiceSubscription", null);
92 for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
93 XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
94 XSDJavaType javaType = new XSDJavaType(javaTypeElement);
95 map.put(javaType.name(), javaType.getArrayType());
97 for (String key : map.keySet()) {
98 assertThat(map.get(key), equalTo(target.get(key)));