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.genxsd;
22 import static org.hamcrest.CoreMatchers.equalTo;
23 import static org.junit.Assert.*;
25 import java.util.HashMap;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.w3c.dom.Element;
31 public class XSDJavaTypeTest extends XSDElementTest {
34 public void setUp() throws Exception {
39 public void testXSDJavaTypeElement() {
40 HashMap<String,String> map = new HashMap<String,String>();
41 HashMap<String,String> target = new HashMap<String,String>();
42 target.put("Customer", "global-customer-id");
43 target.put("Business", "customers");
44 target.put("Inventory", "business");
45 target.put("Customers","customer");
46 target.put("ServiceSubscriptions", "service-subscription");
47 target.put("ServiceSubscription", "service-type");
49 for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
50 XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
51 XSDJavaType javaType = new XSDJavaType(javaTypeElement);
52 map.put(javaType.name(),javaType.getItemName());
54 for(String key : map.keySet()) {
55 assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
60 public void testGetItemName() {
61 HashMap<String,String> map = new HashMap<String,String>();
62 HashMap<String,String> target = new HashMap<String,String>();
63 target.put("Customer", "global-customer-id");
64 target.put("Business", "customers");
65 target.put("Inventory", "business");
66 target.put("Customers","customer");
67 target.put("ServiceSubscriptions", "service-subscription");
68 target.put("ServiceSubscription", "service-type");
70 for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
71 XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
72 XSDJavaType javaType = new XSDJavaType(javaTypeElement);
73 map.put(javaType.name(),javaType.getItemName());
75 for(String key : map.keySet()) {
76 assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
81 public void testGetArrayType() {
82 HashMap<String,String> map = new HashMap<String,String>();
83 HashMap<String,String> target = new HashMap<String,String>();
84 target.put("Customer", null);
85 target.put("Business", null);
86 target.put("Inventory", null);
87 target.put("Customers","customer");
88 target.put("ServiceSubscriptions", "service-subscription");
89 target.put("ServiceSubscription", null);
91 for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
92 XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
93 XSDJavaType javaType = new XSDJavaType(javaTypeElement);
94 map.put(javaType.name(),javaType.getArrayType());
96 for(String key : map.keySet()) {
97 assertThat(map.get(key),equalTo(target.get(key)));