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.BeforeClass;
23 import org.junit.Test;
24 import org.mockito.Mockito;
25 import org.onap.aai.AAISetup;
26 import org.onap.aai.exceptions.AAIException;
27 import org.onap.aai.introspection.*;
28 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
30 import java.util.ArrayList;
31 import java.util.List;
33 import static org.junit.Assert.assertEquals;
34 import static org.junit.Assert.assertTrue;
36 public class CreateExampleTest extends AAISetup {
38 private static CreateExample createExample;
39 private static Loader loader;
42 public static void setUp() {
43 loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v11);
44 createExample = new CreateExample(loader, "edge-prop-names");
48 public void testGetExampleObject() throws AAIException {
49 Introspector introspector = loader.introspectorFromName("edge-prop-names");
50 Introspector res = createExample.getExampleObject();
51 assertEquals(introspector.getName(), res.getName());
55 public void testProcessPrimitiveString() throws AAIUnknownObjectException {
56 String propName = "direction";
57 Introspector introspector = loader.introspectorFromName("edge-prop-names");
58 createExample.processPrimitive(propName, introspector);
62 public void testProcessPrimitiveLong() throws AAIUnknownObjectException {
63 String propName = "vlan-id-inner";
64 Introspector introspector = loader.introspectorFromName("ctag-assignment");
65 createExample.processPrimitive(propName, introspector);
69 public void testProcessPrimitiveBoolean() throws AAIUnknownObjectException {
70 String propName = "in-maint";
71 Introspector introspector = loader.introspectorFromName("vserver");
72 createExample.processPrimitive(propName, introspector);
76 public void testProcessPrimitiveInteger() throws AAIUnknownObjectException {
77 String propName = "module-index";
78 Introspector introspector = loader.introspectorFromName("vf-module");
79 createExample.processPrimitive(propName, introspector);
83 public void testProcessPrimitiveList() throws AAIUnknownObjectException {
84 String propName = "ipaddress-v4-vig";
85 Introspector introspector = loader.introspectorFromName("vig-server");
86 createExample.processPrimitiveList(propName, introspector);
90 public void testProcessComplexObj() {
92 Introspector introspector = Mockito.mock(Introspector.class);
93 createExample.processComplexObj(introspector);
97 public void testModifyComplexList() {
99 List<Introspector> introList = new ArrayList<Introspector>();
100 List<Object> objList = new ArrayList<Object>();
101 Introspector introspector = Mockito.mock(Introspector.class);
102 createExample.modifyComplexList(introList, objList, introspector, introspector);
106 public void testCreateComplexObjIfNull() {
107 boolean res = createExample.createComplexObjIfNull();
112 public void testCreateComplexListSize() {
113 Introspector introspector = Mockito.mock(Introspector.class);
114 int res = createExample.createComplexListSize(introspector, introspector);
115 assertEquals(1, res);