aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java')
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java80
1 files changed, 41 insertions, 39 deletions
diff --git a/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
index 5d63759..ca4fb3b 100644
--- a/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
@@ -4,11 +4,13 @@
* ================================================================================
* Copyright © 2018 IBM Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2021 Orange.
+ * ================================================================================
* 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.
@@ -17,20 +19,10 @@
* ============LICENSE_END=========================================================
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
+ *
*******************************************************************************/
-package org.onap.dmaap.mr.client.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import java.util.Properties;
-
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
+package org.onap.dmaap.mr.client.impl;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
@@ -40,6 +32,16 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
public class DMaapClientUtilTest {
@Mock
Response response;
@@ -47,56 +49,56 @@ public class DMaapClientUtilTest {
Builder builder;
@Mock
WebTarget target;
- private ClientConfig config=null;
+ private ClientConfig config = null;
@Before
- public void setup(){
+ public void setup() {
MockitoAnnotations.initMocks(this);
}
-
+
@Test
public void testGetTarget() {
- WebTarget actual = DmaapClientUtil.getTarget(getClientConfig(),"testpath");
-
+ WebTarget actual = DmaapClientUtil.getTarget(getClientConfig(), "testpath");
+
assertEquals("testpath", actual.getUri().getPath());
}
-
+
@Test
public void testGetTargetWithParams() {
- WebTarget actual = DmaapClientUtil.getTarget(getClientConfig(),"testpath", "testuser", "testpassword");
-
+ WebTarget actual = DmaapClientUtil.getTarget(getClientConfig(), "testpath", "testuser", "testpassword");
+
assertEquals("testpath", actual.getUri().getPath());
}
-
+
@Test
public void testGetResponsewtCambriaAuth() {
- Mockito.when(target.request()).thenReturn(builder);
- Mockito.when(builder.header("X-CambriaAuth", "testuser")).thenReturn(builder);
- Mockito.when(builder.header("X-CambriaDate", "testpassword")).thenReturn(builder);
- Mockito.when(builder.get()).thenReturn(response);
-
+ Mockito.when(target.request()).thenReturn(builder);
+ Mockito.when(builder.header("X-CambriaAuth", "testuser")).thenReturn(builder);
+ Mockito.when(builder.header("X-CambriaDate", "testpassword")).thenReturn(builder);
+ Mockito.when(builder.get()).thenReturn(response);
+
Response actual = DmaapClientUtil.getResponsewtCambriaAuth(target, "testuser", "testpassword");
assertEquals(response, actual);
verify(target).request();
verify(builder, times(2)).header((String) any(), any());
}
-
+
@Test
public void testSetHttpClientProperties() {
- Properties properties = new Properties();
- properties.setProperty(ClientProperties.PROXY_URI, "http://localhost:1234");
- ClientConfig cConfig = DmaapClientUtil.getClientConfig(properties);
+ Properties properties = new Properties();
+ properties.setProperty(ClientProperties.PROXY_URI, "http://localhost:1234");
+ ClientConfig cConfig = DmaapClientUtil.getClientConfig(properties);
- assertEquals(cConfig.getConnectorProvider().getClass().getSimpleName(), "ApacheConnectorProvider");
+ assertEquals("ApacheConnectorProvider", cConfig.getConnectorProvider().getClass().getSimpleName());
}
- private ClientConfig getClientConfig(){
- if(config==null){
- config=DmaapClientUtil.getClientConfig(null);
- }
- return config;
-
- }
+ private ClientConfig getClientConfig() {
+ if (config == null) {
+ config = DmaapClientUtil.getClientConfig(null);
+ }
+ return config;
+
+ }
}