2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2019 Huawei Technologies (Australia) Pty Ltd. 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.schemagen.swagger;
23 import static org.hamcrest.CoreMatchers.is;
24 import static org.hamcrest.MatcherAssert.assertThat;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.Collection;
29 import java.util.List;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.junit.runners.Parameterized;
35 import org.junit.runners.Parameterized.Parameters;
37 @RunWith(Parameterized.class)
38 public class DefinitionTest {
39 Definition theDefinition = null;
40 String definitionName;
41 String definitionDescription;
45 * Parameters for the test cases all following same pattern.
48 public static Collection<String[]> testConditions() {
49 String inputs[][] = {{"name1", "desc1",
50 "Definition{definitionName='name1', definitionDescription='desc1', propertyList=[]}"},
52 "Definition{definitionName='name2', definitionDescription='desc2', propertyList=[]}"},
54 "Definition{definitionName='fake', definitionDescription='random', propertyList=[]}"}};
55 return (Arrays.asList(inputs));
59 * Constructor for the test cases all following same pattern.
61 public DefinitionTest(String definitionName, String definitionDescription, String result) {
63 this.definitionName = definitionName;
64 this.definitionDescription = definitionDescription;
69 * Initialise the test object.
72 public void setUp() throws Exception {
73 theDefinition = new Definition();
77 * Perform the test on the test object.
80 public void testDefinitionProperty() {
81 theDefinition.setDefinitionName(this.definitionName);
82 theDefinition.setDefinitionDescription(this.definitionDescription);
84 List<Definition.Property> tmpList1 = new ArrayList<Definition.Property>();
85 theDefinition.setPropertyList(tmpList1);
86 assertThat(theDefinition.toString(), is(this.result));
88 // other stuff that can be set but not necessarily
89 // included in the toString() output
90 theDefinition.setHasDescription(true);
91 assertThat(theDefinition.isHasDescription(), is(true));
93 theDefinition.setSchemaPropertyList(tmpList1);
94 assertThat(theDefinition.getSchemaPropertyList(), is(tmpList1));
96 theDefinition.setRegularPropertyList(tmpList1);
97 assertThat(theDefinition.getRegularPropertyList(), is(tmpList1));