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.Arrays;
27 import java.util.Collection;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.junit.runners.Parameterized;
33 import org.junit.runners.Parameterized.Parameters;
35 @RunWith(Parameterized.class)
36 public class DefinitionPropertyTest {
37 Definition.Property theProperty = null;
40 String propertyReference;
44 * Parameters for the test cases all following same pattern.
47 public static Collection<String[]> testConditions() {
49 {"name1", "type1", "ref1",
50 "Property{propertyName='name1', propertyType='type1', propertyReference='ref1'}"},
51 {"name2", "type2", "ref2",
52 "Property{propertyName='name2', propertyType='type2', propertyReference='ref2'}"},
53 {"fake", "random", "bluff",
54 "Property{propertyName='fake', propertyType='random', propertyReference='bluff'}"}};
55 return (Arrays.asList(inputs));
59 * Constructor for the test cases all following same pattern.
61 public DefinitionPropertyTest(String propertyName, String propertyType,
62 String propertyReference, String result) {
64 this.propertyName = propertyName;
65 this.propertyType = propertyType;
66 this.propertyReference = propertyReference;
71 * Initialise the test object.
74 public void setUp() throws Exception {
75 theProperty = new Definition.Property();
79 * Perform the test on the test object.
82 public void testDefinitionProperty() {
83 theProperty.setPropertyName(this.propertyName);
84 theProperty.setPropertyType(this.propertyType);
85 theProperty.setPropertyReference(this.propertyReference);
86 assertThat(theProperty.toString(), is(this.result));
88 // other stuff that can be set but not necessarily
89 // included in the toString() output
90 theProperty.setHasType(true);
91 assertThat(theProperty.isHasType(), is(true));
93 theProperty.setRequired(true);
94 assertThat(theProperty.isRequired(), is(true));
96 theProperty.setHasPropertyReference(true);
97 assertThat(theProperty.isHasPropertyReference(), is(true));
99 theProperty.setPropertyReferenceObjectName("someName");
100 assertThat(theProperty.getPropertyReferenceObjectName(), is("someName"));
102 theProperty.setPropertyDescription("some description");
103 assertThat(theProperty.getPropertyDescription(), is("some description"));
105 theProperty.setHasPropertyDescription(true);
106 assertThat(theProperty.isHasPropertyDescription(), is(true));