9d1f6a5305a8f9962df27965221a8222c3fa7674
[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     private static AAIRequest request;
45     private static AAIService aaiService;
46
47     @BeforeClass
48     public static void setUp() throws Exception {
49         aaiService = new AAIService(
50                 AAIService.class.getResource(AAIService.AAICLIENT_PROPERTIES));
51         request = new EchoRequest();
52         LOG.info("\nEchoRequestTest.setUp\n");
53     }
54
55     @AfterClass
56     public static void tearDown() throws Exception {
57         request = null;
58         LOG.info("----------------------- EchoRequestTest.tearDown -----------------------");
59     }
60
61     @Test
62     public void runGetRequestUrlTest() {
63         LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
64
65         URL url;
66         try {
67             url = request.getRequestUrl("GET", null);
68             assertNotNull(url);
69         } catch (UnsupportedEncodingException | MalformedURLException exc) {
70             LOG.error("Failed test", exc);
71         }
72
73     }
74
75     @Test
76     public void runToJSONStringTest() {
77         LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
78
79         try {
80             String json = request.toJSONString();
81             assertNotNull(json);
82         } catch (Exception exc) {
83             LOG.error("Failed test", exc);
84         }
85
86     }
87
88     @Test
89     public void runGetArgsListTest() {
90         LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
91
92         try {
93             String[] args = request.getArgsList();
94             assertNotNull(args);
95         } catch (Exception exc) {
96             LOG.error("Failed test", exc);
97         }
98
99     }
100
101     @Test
102     public void runGetModelTest() {
103         LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
104
105         try {
106             Class<?  extends AAIDatum> clazz = request.getModelClass();
107             assertNotNull(clazz);
108         } catch (Exception exc) {
109             LOG.error("Failed test", exc);
110         }
111
112     }
113 }