AAI-2279 coverage of schema-service/aai-schema-gen
[aai/schema-service.git] / aai-schema-gen / src / test / java / org / onap / aai / schemagen / swagger / ApiHttpVerbResponseTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.aai.schemagen.swagger;
22
23 import static org.hamcrest.CoreMatchers.is;
24 import static org.hamcrest.MatcherAssert.assertThat;
25
26 import java.util.Arrays;
27 import java.util.Collection;
28
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;
34
35 @RunWith(Parameterized.class)
36 public class ApiHttpVerbResponseTest {
37     Api.HttpVerb.Response theResponse = null;
38     String responseCode;
39     String description;
40     String result;
41
42     /**
43      * Parameters for the test cases all following same pattern.
44      */
45     @Parameters
46     public static Collection<String[]> testConditions() {
47         String inputs[][] = {{"200", "OK", "Response{responseCode='200', description='OK'}"},
48             {"400", "Bad Request", "Response{responseCode='400', description='Bad Request'}"},
49             {"500", "Internal Server Error",
50                 "Response{responseCode='500', description='Internal Server Error'}"},
51             {"fake", "random message",
52                 "Response{responseCode='fake', description='random message'}"}};
53         return (Arrays.asList(inputs));
54     }
55
56     /**
57      * Constructor for the test cases all following same pattern.
58      */
59     public ApiHttpVerbResponseTest(String responseCode, String description, String result) {
60         super();
61         this.responseCode = responseCode;
62         this.description = description;
63         this.result = result;
64     }
65
66     /**
67      * Initialise the test object.
68      */
69     @Before
70     public void setUp() throws Exception {
71         theResponse = new Api.HttpVerb.Response();
72     }
73
74     /**
75      * Perform the test on the test object.
76      */
77     @Test
78     public void testApiHttpVerbResponse() {
79         theResponse.setResponseCode(this.responseCode);
80         theResponse.setDescription(this.description);
81         assertThat(theResponse.toString(), is(this.result));
82     }
83
84 }