summaryrefslogtreecommitdiffstats
path: root/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java')
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java56
1 files changed, 29 insertions, 27 deletions
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
index 4592de819..a5e757213 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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. See the License for the specific language governing permissions and limitations under
- * the License.
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -22,7 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
-import org.mockito.Mockito;
import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -37,80 +39,80 @@ import org.springframework.web.client.RestTemplate;
@PowerMockIgnore("javax.net.ssl.*")
@PrepareForTest({AbstractConfigRestClientAdapter.class})
public class SSLClientServiceTest {
-
+
ConfigRestAdaptorService configRestAdaptorService;
-
+
RestTemplate mockRestTemplate = mock(RestTemplate.class);
-
+
String path = "path";
-
+
@Before
public void before() throws Exception {
whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);
-
+
String propertyDir = "src/test/resources";
configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);
}
-
+
@Test
public void testGetResource() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.getResource("aai", path, String.class);
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test
public void testPostResource() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.postResource("aai", path, null, String.class);
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test
public void testExchange() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testGetResourceError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response);
-
+
configRestAdaptorService.getResource("aai", path, String.class);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testPostResourceError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any()))
.thenReturn(response);
-
+
configRestAdaptorService.postResource("aai", path, null, String.class);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testExchangeError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");
}
}