[AAI] Remove Robby Maharajh & Harish Kajur as committers
[aai/schema-service.git] / aai-schema-gen / src / test / java / org / onap / aai / schemagen / genxsd / XSDJavaTypeTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
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 package org.onap.aai.schemagen.genxsd;
21
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.w3c.dom.Element;
25
26 import java.util.HashMap;
27
28 import static org.hamcrest.CoreMatchers.equalTo;
29 import static org.junit.Assert.assertThat;
30
31 public class XSDJavaTypeTest extends XSDElementTest {
32
33         @Before
34         public void setUp() throws Exception {
35                 super.setUp();
36         }
37
38         @Test
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");
48
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());
53                 }
54                 for(String key : map.keySet()) {
55                         assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
56                 }
57         }
58
59         @Test
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");
69
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());
74                 }
75                 for(String key : map.keySet()) {
76                         assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
77                 }
78         }
79
80         @Test
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);
90
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());
95                 }
96                 for(String key : map.keySet()) {
97                         assertThat(map.get(key),equalTo(target.get(key)));
98                 }
99         }
100
101 }