From dd89e148932ba0acbfc6ceb4b229b001b6b8dd33 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Thu, 28 Jan 2021 13:12:40 -0500 Subject: allow RestClient to configure custom headers allow RestClient to configure custom headers always load the first implementation on the classpath Issue-ID: SO-3495 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I9c433cdaed33a7db6182af259421676c088a1fae --- .../aaiclient/client/aai/AAIDSLQueryClientTest.java | 5 +++-- .../onap/aaiclient/client/aai/AAIRestClientTest.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'graph-inventory/aai-client/src/test') diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java index 36fc1db57c..68858de9a4 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java @@ -1,7 +1,8 @@ package org.onap.aaiclient.client.aai; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.net.URISyntaxException; +import org.javatuples.Pair; import org.junit.Test; public class AAIDSLQueryClientTest { @@ -12,6 +13,6 @@ public class AAIDSLQueryClientTest { public void verifyHeadersTest() throws URISyntaxException { AAIDSLQueryClient client = new AAIDSLQueryClient(); - assertEquals("V2", client.getClient().getAdditionalHeaders().get("X-DslApiVersion")); + assertTrue(client.getClient().getAdditionalHeaders().get("ALL").contains(Pair.with("X-DslApiVersion", "V2"))); } } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java index d0f7847726..9b34095a23 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java @@ -43,8 +43,9 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.HashMap; +import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.Response; +import org.javatuples.Pair; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -75,7 +76,7 @@ public class AAIRestClientTest { @Test public void failPatchOnComplexObject() throws URISyntaxException { - AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap()); + AAIRestClient client = new AAIRestClient(props, new URI(""), new MultivaluedHashMap<>()); this.thrown.expect(GraphInventoryPatchDepthExceededException.class); this.thrown.expectMessage(containsString("Object exceeds allowed depth for update action")); client.patch( @@ -84,7 +85,7 @@ public class AAIRestClientTest { @Test public void verifyPatchValidation() throws URISyntaxException { - AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap()); + AAIRestClient client = new AAIRestClient(props, new URI(""), new MultivaluedHashMap<>()); AAIRestClient spy = spy(client); GraphInventoryPatchConverter patchValidatorMock = mock(GraphInventoryPatchConverter.class); doReturn(patchValidatorMock).when(spy).getPatchConverter(); @@ -97,11 +98,13 @@ public class AAIRestClientTest { @Test public void verifyAdditionalHeadersTest() throws URISyntaxException { AAIRestClient client = new AAIRestClient(new DefaultAAIPropertiesImpl(wireMockRule.port()), new URI("/test"), - ImmutableMap.of("test", "value")); + new MultivaluedHashMap>( + ImmutableMap.of("ALL", Pair.with("test", "value"), "GET", Pair.with("get test", "value")))); wireMockRule.stubFor(get(urlPathEqualTo("/test")).willReturn(aResponse().withStatus(200))); client.get(); wireMockRule.verify(getRequestedFor(urlPathEqualTo("/test")).withHeader("X-FromAppId", equalTo("MSO")) - .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value"))); + .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value")) + .withHeader("get test", equalTo("value"))); } @@ -145,7 +148,7 @@ public class AAIRestClientTest { } }; - RestClient client = new AAIRestClient(props, new URI("/cached"), new HashMap()); + RestClient client = new AAIRestClient(props, new URI("/cached"), new MultivaluedHashMap<>()); Response response = client.get(); @@ -199,7 +202,7 @@ public class AAIRestClientTest { }; - RestClient client = new AAIRestClient(props, new URI("/cached/1"), new HashMap()); + RestClient client = new AAIRestClient(props, new URI("/cached/1"), new MultivaluedHashMap<>()); Response response = client.get(); -- cgit 1.2.3-korg