aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSORESTClient
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-10-11 13:55:37 -0400
committerRob Daugherty <rd472p@att.com>2018-10-12 10:10:16 -0400
commit6ba0a22bc952232d14d2d24c5f73a42aae2791a9 (patch)
tree9046e63bccb77ca3e2df4ae7ceab44cc238dd074 /bpmn/MSORESTClient
parent58c1d90a787979e507f559d7075aac8a1428df42 (diff)
Dynamic Cloud Owner Support
added in cloud configuration object to request params Fix Bean scanning so it picks up the resttemplate removed unnecessary RestTemplate Bean configurations corrected typo in CloudConfiguration class updated gr api test cases with dynamic cloud owner updated groovy files to allow for dynamic cloud owner values updated GR API layer to include cloud owner added enum for default cloud owner add cloud owner variable to camunda in mapping removed references to att-aic from BBInputSetup updated aai schema dependency to 1.3.1 from 1.3.0 Fixed incorrect type AAIUri and updated logging in the method. use existing service instance id instead of generating Pass cloudOwner to process to propagate to subprocesses. NOTE: our aai-schema dependency is 1.3.1-SNAPSHOT to be compatible with the cloud owner changes here. The releaesed 1.3.0 version is NOT compatible. Change-Id: I43b46774b77981d1c8bfe7c7a79b9434889e62ae Issue-ID: SO-1128 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com> Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/MSORESTClient')
-rw-r--r--bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java9
-rw-r--r--bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java94
2 files changed, 41 insertions, 62 deletions
diff --git a/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java b/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java
index fc6266d917..c9dd6303bc 100644
--- a/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java
+++ b/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java
@@ -351,15 +351,6 @@ public class RESTClient {
}
/**
- * Alias for httpGet().
- *
- * @see RESTClient#httpGet()
- */
- public APIResponse get() throws RESTException {
- return httpGet();
- }
-
- /**
* Sends an http GET request using the parameters and headers previously
* set.
*
diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java
index 17ede2f2ff..a79f0aa536 100644
--- a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java
+++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,11 +49,11 @@ public class RESTClientTest {
private JSONObject jsonResponse;
private String jsonObjectAsString;
private String jsonResponseAsString;
-
+
@Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
-
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
+
+
@Before
public void before() throws Exception {
jsonPayload = new JSONObject();
@@ -62,135 +62,123 @@ public class RESTClientTest {
jsonObjectAsString = jsonPayload.toString();
jsonResponse = new JSONObject();
jsonResponse.put("response", "responseValue");
- jsonResponseAsString = jsonResponse.toString();
+ jsonResponseAsString = jsonResponse.toString();
restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example", "localhost", wireMockRule.port());
- }
-
+ }
+
@Test
public void testHeadersParameters() throws Exception {
restClient.setHeader("name", "value");
restClient.setParameter("name", "value");
- assertEquals("[value]", restClient.getParameters().get("name").toString());
+ assertEquals("[value]", restClient.getParameters().get("name").toString());
assertEquals("[value]", restClient.getHeaders().get("name").toString());
restClient.setHeader("name", "value2");
assertEquals("[value2]", restClient.getHeaders().get("name").toString());
restClient.setParameter("name", "value2");
assertEquals("[value2]", restClient.getParameters().get("name").toString());
- restClient.addParameter("name", "value");
+ restClient.addParameter("name", "value");
assertEquals(1, restClient.getParameters().size());
- restClient.addAuthorizationHeader("token");
- assertEquals("[token]", restClient.getHeaders().get("Authorization").toString());
+ restClient.addAuthorizationHeader("token");
+ assertEquals("[token]", restClient.getHeaders().get("Authorization").toString());
assertEquals("http://localhost:" + wireMockRule.port() + "/example", restClient.getURL());
restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example1");
assertEquals("http://localhost:" + wireMockRule.port() + "/example1", restClient.getURL());
}
-
+
@Test
public void testHttpPost() throws Exception {
RESTClient restClientMock = mock(RESTClient.class);
restClientMock = spy(restClient);
wireMockRule.stubFor(post(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClientMock.httpPost(jsonObjectAsString);
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
verify(restClientMock, times(2)).getURL();
- }
-
+ }
+
@Test
public void testPost() throws Exception {
wireMockRule.stubFor(post(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClient.post();
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
+ }
+
@Test
public void testHttpPut() throws Exception {
wireMockRule.stubFor(put(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
restClient.setParameter("name", "value");
APIResponse apiResponse = restClient.httpPut(jsonObjectAsString);
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
-
- }
-
+
+ }
+
@Test
public void testHttpPatch() throws Exception {
wireMockRule.stubFor(patch(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClient.httpPatch(jsonObjectAsString);
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
+ }
@Test
public void testPatch_withParameter() throws Exception {
wireMockRule.stubFor(patch(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
restClient.setParameter("name", "value");
APIResponse apiResponse = restClient.patch(jsonObjectAsString);
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
+ }
+
@Test
public void testHttpDelete_withPayload() throws Exception {
wireMockRule.stubFor(delete(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClient.httpDelete(jsonObjectAsString);
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
+ }
+
@Test
public void testHttpDelete() throws Exception {
wireMockRule.stubFor(delete(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClient.httpDelete();
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
+ }
+
@Test
public void testDelete() throws Exception {
wireMockRule.stubFor(delete(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClient.delete();
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
+ }
+
@Test
public void testHttpGet() throws Exception {
wireMockRule.stubFor(get(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
APIResponse apiResponse = restClient.httpGet();
assertEquals(200, apiResponse.getStatusCode());
assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
- @Test
- public void testGet_withParameter() throws Exception {
- wireMockRule.stubFor(get(urlPathMatching("/example/*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString)));
- restClient.setParameter("name", "value");
- restClient.setParameter("type", "valueType");
- APIResponse apiResponse = restClient.get();
- assertEquals(200, apiResponse.getStatusCode());
- assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString());
- assertEquals("application/json", apiResponse.getFirstHeader("Content-Type"));
- }
-
+ }
+
}