Improve CCSDK adaptors Sonar coverage
[ccsdk/sli/adaptors.git] / aai-service / provider / src / test / java / org / onap / ccsdk / sli / adaptors / aai / EchoRequestTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.sli.adaptors.aai;
23
24 import static org.junit.Assert.assertNotNull;
25
26 import java.io.UnsupportedEncodingException;
27 import java.net.MalformedURLException;
28 import java.net.URL;
29
30 import org.junit.AfterClass;
31 import org.junit.BeforeClass;
32 import org.junit.FixMethodOrder;
33 import org.junit.Test;
34 import org.junit.runners.MethodSorters;
35 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
40 public class EchoRequestTest {
41
42         private static final Logger LOG = LoggerFactory.getLogger(EchoRequestTest.class);
43
44         protected static AAIRequest request;
45
46         @BeforeClass
47         public static void setUp() throws Exception {
48                 request = new EchoRequest();
49                 LOG.info("\nEchoRequestTest.setUp\n");
50         }
51
52         @AfterClass
53         public static void tearDown() throws Exception {
54                 request = null;
55                 LOG.info("----------------------- EchoRequestTest.tearDown -----------------------");
56         }
57
58         @Test
59         public void runGetRequestUrlTest() {
60                 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
61
62                 URL url;
63                 try {
64                         url = request.getRequestUrl("GET", null);
65                         assertNotNull(url);
66                 } catch (UnsupportedEncodingException | MalformedURLException exc) {
67                         LOG.error("Failed test", exc);
68                 }
69
70         }
71
72         @Test
73         public void runToJSONStringTest() {
74                 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
75
76                 try {
77                         String json = request.toJSONString();
78                         assertNotNull(json);
79                 } catch (Exception exc) {
80                         LOG.error("Failed test", exc);
81                 }
82
83         }
84
85         @Test
86         public void runGetArgsListTest() {
87                 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
88
89                 try {
90                         String[] args = request.getArgsList();
91                         assertNotNull(args);
92                 } catch (Exception exc) {
93                         LOG.error("Failed test", exc);
94                 }
95
96         }
97
98         @Test
99         public void runGetModelTest() {
100                 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
101
102                 try {
103                         Class<?  extends AAIDatum> clazz = request.getModelClass();
104                         assertNotNull(clazz);
105                 } catch (Exception exc) {
106                         LOG.error("Failed test", exc);
107                 }
108
109         }
110 }