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.introspection.generator;
22 import org.junit.Before;
23 import org.junit.BeforeClass;
24 import org.junit.Test;
25 import org.mockito.Mockito;
26 import org.onap.aai.AAISetup;
27 import org.onap.aai.exceptions.AAIException;
28 import org.onap.aai.introspection.*;
29 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
31 import java.util.ArrayList;
32 import java.util.List;
34 import static org.junit.Assert.assertEquals;
35 import static org.junit.Assert.assertTrue;
36 public class CreateExampleTest extends AAISetup {
38 private static CreateExample createExample;
39 private Loader loader;
41 private static boolean classLoaded = false;
45 public static void setUp() {
52 public void createLoaderVersion(){
54 loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getAppRootVersion());
55 createExample = new CreateExample(loader, "edge-prop-names");
61 public void testGetExampleObject() throws AAIException {
62 Introspector introspector = loader.introspectorFromName("edge-prop-names");
63 Introspector res = createExample.getExampleObject();
64 assertEquals(introspector.getName(), res.getName());
68 public void testProcessPrimitiveString() throws AAIUnknownObjectException {
69 String propName = "direction";
70 Introspector introspector = loader.introspectorFromName("edge-prop-names");
71 createExample.processPrimitive(propName, introspector);
75 public void testProcessPrimitiveLong() throws AAIUnknownObjectException {
76 String propName = "vlan-id-inner";
77 Introspector introspector = loader.introspectorFromName("ctag-assignment");
78 createExample.processPrimitive(propName, introspector);
82 public void testProcessPrimitiveBoolean() throws AAIUnknownObjectException {
83 String propName = "in-maint";
84 Introspector introspector = loader.introspectorFromName("vserver");
85 createExample.processPrimitive(propName, introspector);
89 public void testProcessPrimitiveInteger() throws AAIUnknownObjectException {
90 String propName = "module-index";
91 Introspector introspector = loader.introspectorFromName("vf-module");
92 createExample.processPrimitive(propName, introspector);
96 public void testProcessPrimitiveList() throws AAIUnknownObjectException {
97 String propName = "ipaddress-v4-vig";
98 Introspector introspector = loader.introspectorFromName("vig-server");
99 createExample.processPrimitiveList(propName, introspector);
103 public void testProcessComplexObj() {
105 Introspector introspector = Mockito.mock(Introspector.class);
106 createExample.processComplexObj(introspector);
110 public void testModifyComplexList() {
112 List<Introspector> introList = new ArrayList<Introspector>();
113 List<Object> objList = new ArrayList<Object>();
114 Introspector introspector = Mockito.mock(Introspector.class);
115 createExample.modifyComplexList(introList, objList, introspector, introspector);
119 public void testCreateComplexObjIfNull() {
120 boolean res = createExample.createComplexObjIfNull();
125 public void testCreateComplexListSize() {
126 Introspector introspector = Mockito.mock(Introspector.class);
127 int res = createExample.createComplexListSize(introspector, introspector);
128 assertEquals(1, res);