Containerization feature of SO
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / client / sdn / common / SdnCommonTasksTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.so.client.sdn.common;
22
23 import java.util.LinkedHashMap;
24
25 import org.junit.Assert;
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.rules.ExpectedException;
29 import org.onap.so.client.exception.BadResponseException;
30 import org.onap.so.client.exception.MapperException;
31 import org.onap.so.client.sdnc.SdnCommonTasks;
32
33
34 public class SdnCommonTasksTest{
35
36     
37     SdnCommonTasks sdnCommonTasks = new SdnCommonTasks();
38
39     @Rule
40     public ExpectedException expectedException = ExpectedException.none();
41
42     @Test
43     public void buildJsonRequestTest() throws MapperException {
44         String jsonStr = sdnCommonTasks.buildJsonRequest("");
45         Assert.assertNotNull(jsonStr);
46     }
47
48     @Test
49     public void buildJsonRequestTestException() throws MapperException {
50         expectedException.expect(MapperException.class);
51         sdnCommonTasks.buildJsonRequest(new Object());
52     }
53
54     @Test
55     public void getHttpHeadersTest() {
56         Assert.assertNotNull(sdnCommonTasks.getHttpHeaders(""));
57     }
58
59     @Test
60     public void validateSDNResponseTest() throws BadResponseException {
61         LinkedHashMap responseMap = new LinkedHashMap();
62         responseMap.put("response-code", "0");
63         responseMap.put("response-message", "success");
64         Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap));
65     }
66
67     @Test
68     public void validateSDNResponseTestException() throws BadResponseException {
69         expectedException.expect(BadResponseException.class);
70         LinkedHashMap responseMap = new LinkedHashMap();
71         Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap));
72     }
73
74     @Test
75     public void validateSDNResponseTestRespCodeNot200() throws BadResponseException {
76         expectedException.expect(BadResponseException.class);
77         LinkedHashMap responseMap = new LinkedHashMap();
78         responseMap.put("response-code", "300");
79         responseMap.put("response-message", "Failed");
80         Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap));
81     }
82
83 }