From 3772c8513f618f9b76fc7bfa55fa140eb60f2a4b Mon Sep 17 00:00:00 2001 From: sebdet Date: Fri, 29 Mar 2019 11:52:02 +0100 Subject: Refactoring Small refactoring of the Http library Issue-ID: CLAMP-333 Change-Id: I90a5488241ab84636bc0cec5849e97c4f98f3a38 Signed-off-by: sebdet --- .../onap/clamp/clds/client/DcaeDispatcherServicesTest.java | 12 ++++++------ .../org/onap/clamp/clds/it/HttpConnectionManagerItCase.java | 10 +++++----- src/test/resources/application.properties | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src/test') 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 549c2d117..e6c634cb3 100644 --- a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java +++ b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java @@ -85,7 +85,7 @@ public class DcaeDispatcherServicesTest { @Test public void shouldReturnDcaeOperationSataus() throws IOException { //given - Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) + Mockito.when(httpConnectionManager.doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) .thenReturn(STATUS_RESPONSE_PROCESSING); //when String operationStatus = dcaeDispatcherServices.getOperationStatus(DEPLOYMENT_STATUS_URL); @@ -97,7 +97,7 @@ public class DcaeDispatcherServicesTest { @Test public void shouldTryMultipleTimesWhenProcessing() throws IOException, InterruptedException { //given - Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", + Mockito.when(httpConnectionManager.doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_ACTIVE); //when @@ -106,7 +106,7 @@ public class DcaeDispatcherServicesTest { //then Assertions.assertThat(operationStatus).isEqualTo("succeeded"); Mockito.verify(httpConnectionManager, Mockito.times(3)) - .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null); + .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null); } @@ -114,7 +114,7 @@ public class DcaeDispatcherServicesTest { public void shouldTryOnlyAsManyTimesAsConfigured() throws IOException, InterruptedException { //given Mockito.when(httpConnectionManager - .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) + .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING); //when @@ -123,7 +123,7 @@ public class DcaeDispatcherServicesTest { //then Assertions.assertThat(operationStatus).isEqualTo("processing"); Mockito.verify(httpConnectionManager, Mockito.times(3)) - .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null); + .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null); } @@ -136,7 +136,7 @@ public class DcaeDispatcherServicesTest { .thenReturn(new JsonObject()); Mockito.when(httpConnectionManager - .doGeneralHttpQuery(DCAE_URL + .doHttpRequest(DCAE_URL + "/dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId", "PUT", "{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}", diff --git a/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java index 4db0e5c27..4c23eca09 100644 --- a/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java @@ -110,7 +110,7 @@ public class HttpConnectionManagerItCase { @Test public void testHttpGet() throws Exception { String response = httpConnectionManager - .doGeneralHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); + .doHttpRequest("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); assertNotNull(response); // Should be a redirection so 302, so empty assertTrue(response.isEmpty()); @@ -119,7 +119,7 @@ public class HttpConnectionManagerItCase { @Test public void testHttpsGet() throws Exception { String response = httpConnectionManager - .doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); + .doHttpRequest("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); assertNotNull(response); // Should contain something assertTrue(!response.isEmpty()); @@ -127,21 +127,21 @@ public class HttpConnectionManagerItCase { @Test(expected = BadRequestException.class) public void testHttpsGet404() throws IOException { - httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html", + httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/designer/index1.html", "GET", null, null, "DCAE", null, null); fail("Should have raised an BadRequestException"); } @Test(expected = BadRequestException.class) public void testHttpsPost404() throws IOException { - httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html", + httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/designer/index1.html", "POST", "", "application/json", "DCAE", null, null); fail("Should have raised an BadRequestException"); } @Test(expected = BadRequestException.class) public void testHttpException() throws IOException { - httpConnectionManager.doGeneralHttpQuery("http://localhost:" + this.httpsPort + "/designer/index.html", "GET", + httpConnectionManager.doHttpRequest("http://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); fail("Should have raised an BadRequestException"); } diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 99d5da8b3..9f711e3e9 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -212,7 +212,6 @@ clamp.config.dcae.intentory.retry.limit=1 clamp.config.dcae.dispatcher.url=http://localhost:${docker.http-cache.port.host} clamp.config.dcae.dispatcher.retry.interval=100 clamp.config.dcae.dispatcher.retry.limit=1 -clamp.config.dcae.header.requestId = X-ECOMP-RequestID #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! clamp.config.security.permission.type.cl=permission-type-cl -- cgit 1.2.3-korg