summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-10-09 12:24:52 +0000
committerGerrit Code Review <gerrit@onap.org>2019-10-09 12:24:52 +0000
commite39c2cbf62f993dbe7843b3eb360c485ef445554 (patch)
treef518ae6f7de14fad3aa15c3f85b69b011073bb0d /bpmn
parent7a19f3d53a4983a3986ba6adba3f35bd7e54f254 (diff)
parentc84283411ffad8531cbdb1f45d3e2b38b088f848 (diff)
Merge "mso should not send content type http header to"
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java18
3 files changed, 24 insertions, 6 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
index 07f448e5e1..7d2fc10d0b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
@@ -55,7 +55,7 @@ public class SDNCClient {
BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
STOClient.setTargetUrl(targetUrl);
- HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
+ HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true);
STOClient.setHttpHeader(httpHeader);
LinkedHashMap<String, Object> output =
STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
@@ -67,7 +67,7 @@ public class SDNCClient {
String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
STOClient.setTargetUrl(url);
- HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
+ HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true);
STOClient.setHttpHeader(httpHeader);
LinkedHashMap<String, Object> output =
STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
@@ -87,7 +87,7 @@ public class SDNCClient {
String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString();
BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
STOClient.setTargetUrl(targetUrl);
- HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
+ HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), false);
STOClient.setHttpHeader(httpHeader);
LinkedHashMap<String, Object> output =
STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
index 1144648517..e7e4e25af2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
@@ -82,10 +82,12 @@ public class SdnCommonTasks {
* @param auth
* @return
*/
- public HttpHeaders getHttpHeaders(String auth) {
+ public HttpHeaders getHttpHeaders(String auth, boolean includeContentType) {
HttpHeaders httpHeader = new HttpHeaders();
httpHeader.set("Authorization", auth);
- httpHeader.setContentType(MediaType.APPLICATION_JSON);
+ if (includeContentType) {
+ httpHeader.setContentType(MediaType.APPLICATION_JSON);
+ }
List<MediaType> acceptMediaTypes = new ArrayList<>();
acceptMediaTypes.add(MediaType.APPLICATION_JSON);
httpHeader.setAccept(acceptMediaTypes);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
index 9c736b7634..a8816e1b04 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
@@ -21,6 +21,7 @@
package org.onap.so.client.sdn.common;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import java.util.LinkedHashMap;
import org.junit.Assert;
import org.junit.Rule;
@@ -29,6 +30,8 @@ import org.junit.rules.ExpectedException;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SdnCommonTasks;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
public class SdnCommonTasksTest {
@@ -53,7 +56,20 @@ public class SdnCommonTasksTest {
@Test
public void getHttpHeadersTest() {
- Assert.assertNotNull(sdnCommonTasks.getHttpHeaders(""));
+ HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", true);
+
+ assertEquals("auth", result.getFirst("Authorization"));
+ assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Content-Type"));
+ assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept"));
+ }
+
+ @Test
+ public void getHttpHeadersGetRequestTest() {
+ HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", false);
+
+ assertEquals("auth", result.getFirst("Authorization"));
+ assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept"));
+ assertFalse(result.containsKey("Content-Type"));
}
@Test