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.Test;
33 import org.mockito.Mockito;
34 import org.onap.aai.AAISetup;
35 import org.onap.aai.exceptions.AAIException;
36 import org.onap.aai.introspection.Introspector;
37 import org.onap.aai.introspection.Loader;
38 import org.onap.aai.introspection.ModelType;
39 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
41 public class CreateExampleTest extends AAISetup {
43 private static CreateExample createExample;
44 private Loader loader;
46 private static boolean classLoaded = false;
49 public static void setUp() {
54 public void createLoaderVersion() {
56 loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getAppRootVersion());
57 createExample = new CreateExample(loader, "edge-prop-names");
63 public void testGetExampleObject() throws AAIException {
64 Introspector introspector = loader.introspectorFromName("edge-prop-names");
65 Introspector res = createExample.getExampleObject();
66 assertEquals(introspector.getName(), res.getName());
70 public void testProcessPrimitiveString() throws AAIUnknownObjectException {
71 String propName = "direction";
72 Introspector introspector = loader.introspectorFromName("edge-prop-names");
73 createExample.processPrimitive(propName, introspector);
74 assertEquals(introspector.getName(), "edge-prop-names");
78 public void testProcessPrimitiveLong() throws AAIUnknownObjectException {
79 String propName = "vlan-id-inner";
80 Introspector introspector = loader.introspectorFromName("ctag-assignment");
81 createExample.processPrimitive(propName, introspector);
82 assertEquals(introspector.getName(), "ctag-assignment");
86 public void testProcessPrimitiveBoolean() throws AAIUnknownObjectException {
87 String propName = "in-maint";
88 Introspector introspector = loader.introspectorFromName("vserver");
89 createExample.processPrimitive(propName, introspector);
90 assertEquals(introspector.getName(), "vserver");
94 public void testProcessPrimitiveInteger() throws AAIUnknownObjectException {
95 String propName = "module-index";
96 Introspector introspector = loader.introspectorFromName("vf-module");
97 createExample.processPrimitive(propName, introspector);
98 assertEquals(introspector.getName(), "vf-module");
102 public void testProcessPrimitiveList() throws AAIUnknownObjectException {
103 String propName = "ipaddress-v4-vig";
104 Introspector introspector = loader.introspectorFromName("vig-server");
105 assertEquals(introspector.getName(), "vig-server");
109 public void testProcessComplexObj() {
111 Introspector introspector = Mockito.mock(Introspector.class);
112 createExample.processComplexObj(introspector);
113 assertNotNull(introspector);
117 public void testModifyComplexList() {
119 List<Introspector> introList = new ArrayList<Introspector>();
120 List<Object> objList = new ArrayList<Object>();
121 Introspector introspector = Mockito.mock(Introspector.class);
122 createExample.modifyComplexList(introList, objList, introspector, introspector);
123 assertNotNull(introspector);
127 public void testCreateComplexObjIfNull() {
128 boolean res = createExample.createComplexObjIfNull();
133 public void testCreateComplexListSize() {
134 Introspector introspector = Mockito.mock(Introspector.class);
135 int res = createExample.createComplexListSize(introspector, introspector);
136 assertEquals(1, res);