aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r--src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java27
-rw-r--r--src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java (renamed from src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java)26
2 files changed, 27 insertions, 26 deletions
diff --git a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
index 1b01f544b..caab61f18 100644
--- a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
+++ b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
@@ -36,6 +36,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.util.HttpConnectionManager;
@@ -55,7 +56,7 @@ public class DcaeDispatcherServicesTest {
private ClampProperties clampProperties;
@Mock
- DcaeHttpConnectionManager dcaeHttpConnectionManager;
+ HttpConnectionManager httpConnectionManager;
@InjectMocks
DcaeDispatcherServices dcaeDispatcherServices;
@@ -84,7 +85,7 @@ public class DcaeDispatcherServicesTest {
@Test
public void shouldReturnDcaeOperationSataus() throws IOException {
//given
- Mockito.when(dcaeHttpConnectionManager.doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null))
+ Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE"))
.thenReturn(STATUS_RESPONSE_PROCESSING);
//when
String operationStatus = dcaeDispatcherServices.getOperationStatus(DEPLOYMENT_STATUS_URL);
@@ -96,24 +97,24 @@ public class DcaeDispatcherServicesTest {
@Test
public void shouldTryMultipleTimesWhenProcessing() throws IOException, InterruptedException {
//given
- Mockito.when(dcaeHttpConnectionManager.doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET",
- null, null))
+ Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET",
+ null, null, "DCAE"))
.thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_ACTIVE);
//when
String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL);
//then
Assertions.assertThat(operationStatus).isEqualTo("succeeded");
- Mockito.verify(dcaeHttpConnectionManager, Mockito.times(3))
- .doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null);
+ Mockito.verify(httpConnectionManager, Mockito.times(3))
+ .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE");
}
@Test
public void shouldTryOnlyAsManyTimesAsConfigured() throws IOException, InterruptedException {
//given
- Mockito.when(dcaeHttpConnectionManager
- .doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null))
+ Mockito.when(httpConnectionManager
+ .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE"))
.thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING,
STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING);
//when
@@ -121,8 +122,8 @@ public class DcaeDispatcherServicesTest {
//then
Assertions.assertThat(operationStatus).isEqualTo("processing");
- Mockito.verify(dcaeHttpConnectionManager, Mockito.times(3))
- .doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null);
+ Mockito.verify(httpConnectionManager, Mockito.times(3))
+ .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE");
}
@@ -134,12 +135,12 @@ public class DcaeDispatcherServicesTest {
Mockito.when(clampProperties.getJsonTemplate("dcae.deployment.template"))
.thenReturn(new JsonObject());
- Mockito.when(dcaeHttpConnectionManager
- .doDcaeHttpQuery(DCAE_URL
+ Mockito.when(httpConnectionManager
+ .doGeneralHttpQuery(DCAE_URL
+ "/dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId",
"PUT",
"{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}",
- "application/json"))
+ "application/json", "DCAE"))
.thenReturn(DEPLOY_RESPONSE_STRING);
JsonObject blueprintInputJson = new JsonObject();
diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java
index 8e03153a2..42e9c7f63 100644
--- a/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java
@@ -45,7 +45,7 @@ import javax.ws.rs.BadRequestException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.DcaeHttpConnectionManager;
+import org.onap.clamp.util.HttpConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -59,7 +59,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@TestPropertySource(locations = "classpath:https/https-test.properties")
-public class DcaeHttpConnectionManagerItCase {
+public class HttpConnectionManagerItCase {
@Value("${server.port}")
private String httpsPort;
@@ -67,7 +67,7 @@ public class DcaeHttpConnectionManagerItCase {
private String httpPort;
@Autowired
- DcaeHttpConnectionManager dcaeHttpConnectionManager;
+ HttpConnectionManager httpConnectionManager;
private static TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@@ -109,8 +109,8 @@ public class DcaeHttpConnectionManagerItCase {
@Test
public void testHttpGet() throws Exception {
- String response = dcaeHttpConnectionManager
- .doDcaeHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null);
+ String response = httpConnectionManager
+ .doGeneralHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE");
assertNotNull(response);
// Should be a redirection so 302, so empty
assertTrue(response.isEmpty());
@@ -118,8 +118,8 @@ public class DcaeHttpConnectionManagerItCase {
@Test
public void testHttpsGet() throws Exception {
- String response = dcaeHttpConnectionManager
- .doDcaeHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null);
+ String response = httpConnectionManager
+ .doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE");
assertNotNull(response);
// Should contain something
assertTrue(!response.isEmpty());
@@ -127,22 +127,22 @@ public class DcaeHttpConnectionManagerItCase {
@Test(expected = BadRequestException.class)
public void testHttpsGet404() throws IOException {
- dcaeHttpConnectionManager.doDcaeHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
- "GET", null, null);
+ httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
+ "GET", null, null, "DCAE");
fail("Should have raised an BadRequestException");
}
@Test(expected = BadRequestException.class)
public void testHttpsPost404() throws IOException {
- dcaeHttpConnectionManager.doDcaeHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
- "POST", "", "application/json");
+ httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
+ "POST", "", "application/json", "DCAE");
fail("Should have raised an BadRequestException");
}
@Test(expected = BadRequestException.class)
public void testHttpException() throws IOException {
- dcaeHttpConnectionManager.doDcaeHttpQuery("http://localhost:" + this.httpsPort + "/designer/index.html", "GET",
- null, null);
+ httpConnectionManager.doGeneralHttpQuery("http://localhost:" + this.httpsPort + "/designer/index.html", "GET",
+ null, null, "DCAE");
fail("Should have raised an BadRequestException");
}
}