2 * ============LICENSE_START=======================================================
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
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.so.client.sdn.common;
23 import java.util.LinkedHashMap;
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;
34 public class SdnCommonTasksTest{
37 SdnCommonTasks sdnCommonTasks = new SdnCommonTasks();
40 public ExpectedException expectedException = ExpectedException.none();
43 public void buildJsonRequestTest() throws MapperException {
44 String jsonStr = sdnCommonTasks.buildJsonRequest("");
45 Assert.assertNotNull(jsonStr);
49 public void buildJsonRequestTestException() throws MapperException {
50 expectedException.expect(MapperException.class);
51 sdnCommonTasks.buildJsonRequest(new Object());
55 public void getHttpHeadersTest() {
56 Assert.assertNotNull(sdnCommonTasks.getHttpHeaders(""));
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));
68 public void validateSDNResponseTestException() throws BadResponseException {
69 expectedException.expect(BadResponseException.class);
70 LinkedHashMap responseMap = new LinkedHashMap();
71 Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap));
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));