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.assertTrue;
26 import java.util.ArrayList;
27 import java.util.List;
29 import org.junit.Before;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.mockito.Mockito;
33 import org.onap.aai.AAISetup;
34 import org.onap.aai.exceptions.AAIException;
35 import org.onap.aai.introspection.*;
36 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
38 public class CreateExampleTest extends AAISetup {
40 private static CreateExample createExample;
41 private Loader loader;
43 private static boolean classLoaded = false;
46 public static void setUp() {
51 public void createLoaderVersion() {
53 loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getAppRootVersion());
54 createExample = new CreateExample(loader, "edge-prop-names");
60 public void testGetExampleObject() throws AAIException {
61 Introspector introspector = loader.introspectorFromName("edge-prop-names");
62 Introspector res = createExample.getExampleObject();
63 assertEquals(introspector.getName(), res.getName());
67 public void testProcessPrimitiveString() throws AAIUnknownObjectException {
68 String propName = "direction";
69 Introspector introspector = loader.introspectorFromName("edge-prop-names");
70 createExample.processPrimitive(propName, introspector);
74 public void testProcessPrimitiveLong() throws AAIUnknownObjectException {
75 String propName = "vlan-id-inner";
76 Introspector introspector = loader.introspectorFromName("ctag-assignment");
77 createExample.processPrimitive(propName, introspector);
81 public void testProcessPrimitiveBoolean() throws AAIUnknownObjectException {
82 String propName = "in-maint";
83 Introspector introspector = loader.introspectorFromName("vserver");
84 createExample.processPrimitive(propName, introspector);
88 public void testProcessPrimitiveInteger() throws AAIUnknownObjectException {
89 String propName = "module-index";
90 Introspector introspector = loader.introspectorFromName("vf-module");
91 createExample.processPrimitive(propName, introspector);
95 public void testProcessPrimitiveList() throws AAIUnknownObjectException {
96 String propName = "ipaddress-v4-vig";
97 Introspector introspector = loader.introspectorFromName("vig-server");
98 createExample.processPrimitiveList(propName, introspector);
102 public void testProcessComplexObj() {
104 Introspector introspector = Mockito.mock(Introspector.class);
105 createExample.processComplexObj(introspector);
109 public void testModifyComplexList() {
111 List<Introspector> introList = new ArrayList<Introspector>();
112 List<Object> objList = new ArrayList<Object>();
113 Introspector introspector = Mockito.mock(Introspector.class);
114 createExample.modifyComplexList(introList, objList, introspector, introspector);
118 public void testCreateComplexObjIfNull() {
119 boolean res = createExample.createComplexObjIfNull();
124 public void testCreateComplexListSize() {
125 Introspector introspector = Mockito.mock(Introspector.class);
126 int res = createExample.createComplexListSize(introspector, introspector);
127 assertEquals(1, res);