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.introspection.generator;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
27 import java.util.ArrayList;
28 import java.util.List;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.junit.Ignore;
33 import org.junit.Test;
34 import org.mockito.Mockito;
35 import org.onap.aai.AAISetup;
36 import org.onap.aai.exceptions.AAIException;
37 import org.onap.aai.introspection.Introspector;
38 import org.onap.aai.introspection.Loader;
39 import org.onap.aai.introspection.ModelType;
40 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
43 public class CreateExampleTest extends AAISetup {
45 private static CreateExample createExample;
46 private Loader loader;
48 private static boolean classLoaded = false;
51 public static void setUp() {
56 public void createLoaderVersion() {
58 loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getAppRootVersion());
59 createExample = new CreateExample(loader, "edge-prop-names");
65 public void testGetExampleObject() throws AAIException {
66 Introspector introspector = loader.introspectorFromName("edge-prop-names");
67 Introspector res = createExample.getExampleObject();
68 assertEquals(introspector.getName(), res.getName());
72 public void testProcessPrimitiveString() throws AAIUnknownObjectException {
73 String propName = "direction";
74 Introspector introspector = loader.introspectorFromName("edge-prop-names");
75 createExample.processPrimitive(propName, introspector);
76 assertEquals(introspector.getName(), "edge-prop-names");
80 public void testProcessPrimitiveLong() throws AAIUnknownObjectException {
81 String propName = "vlan-id-inner";
82 Introspector introspector = loader.introspectorFromName("ctag-assignment");
83 createExample.processPrimitive(propName, introspector);
84 assertEquals(introspector.getName(), "ctag-assignment");
88 public void testProcessPrimitiveBoolean() throws AAIUnknownObjectException {
89 String propName = "in-maint";
90 Introspector introspector = loader.introspectorFromName("vserver");
91 createExample.processPrimitive(propName, introspector);
92 assertEquals(introspector.getName(), "vserver");
96 public void testProcessPrimitiveInteger() throws AAIUnknownObjectException {
97 String propName = "module-index";
98 Introspector introspector = loader.introspectorFromName("vf-module");
99 createExample.processPrimitive(propName, introspector);
100 assertEquals(introspector.getName(), "vf-module");
104 public void testProcessPrimitiveList() throws AAIUnknownObjectException {
105 String propName = "ipaddress-v4-vig";
106 Introspector introspector = loader.introspectorFromName("vig-server");
107 assertEquals(introspector.getName(), "vig-server");
111 public void testProcessComplexObj() {
113 Introspector introspector = Mockito.mock(Introspector.class);
114 createExample.processComplexObj(introspector);
115 assertNotNull(introspector);
119 public void testModifyComplexList() {
121 List<Introspector> introList = new ArrayList<Introspector>();
122 List<Object> objList = new ArrayList<Object>();
123 Introspector introspector = Mockito.mock(Introspector.class);
124 createExample.modifyComplexList(introList, objList, introspector, introspector);
125 assertNotNull(introspector);
129 public void testCreateComplexObjIfNull() {
130 boolean res = createExample.createComplexObjIfNull();
135 public void testCreateComplexListSize() {
136 Introspector introspector = Mockito.mock(Introspector.class);
137 int res = createExample.createComplexListSize(introspector, introspector);
138 assertEquals(1, res);