summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-09 08:58:47 -0400
committerRob Daugherty <rd472p@att.com>2018-08-10 17:38:04 +0000
commit0396b699b3a56c5a35edb373e73a1221086cac0c (patch)
treef7ccb0bf1a194ac89362a5c3eab1d016c91f7c1f /bpmn/so-bpmn-tasks/src/test/java
parenta6ed83b5ad7340dd8f6c642abe965423bdaa8f43 (diff)
ParameterizedTypeReference now passed in
An argument must be added other wise we cannot return anything other than a linkedhashmap because of type erasure. https://stackoverflow.com/questions/21987295/using-spring-resttemplate-in-generic-method-with-generic-parameter Issue-ID: SO-820 Change-Id: I96b5bf9db8389beacfcd79e7a80ee22b3d470a27 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java
new file mode 100644
index 0000000000..a564d8a21d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java
@@ -0,0 +1,50 @@
+package org.onap.so.client.sdnc;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.springframework.core.ParameterizedTypeReference;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+import wiremock.org.apache.http.entity.ContentType;
+public class BaseClientTest {
+
+
+ @Rule
+ public WireMockRule wm = new WireMockRule(options().dynamicPort());
+
+ @Test
+ public void verifyString() {
+ BaseClient<String, String> client = new BaseClient<>();
+ String response = "{\"hello\" : \"world\"}";
+ client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(wm.port()).build().toString());
+ wm.stubFor(get(urlEqualTo("/test"))
+ .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
+
+ String result = client.get("", new ParameterizedTypeReference<String>() {});
+ assertThat(result, equalTo(response));
+ }
+
+ @Test
+ public void verifyMap() {
+ BaseClient<String, Map<String, Object>> client = new BaseClient<>();
+ String response = "{\"hello\" : \"world\"}";
+ client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(wm.port()).build().toString());
+ wm.stubFor(get(urlEqualTo("/test"))
+ .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
+
+ Map<String, Object> result = client.get("", new ParameterizedTypeReference<Map<String, Object>>() {});
+ assertThat("world", equalTo(result.get("hello")));
+ }
+}