summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services
diff options
context:
space:
mode:
authorVodafone <onap@vodafone.com>2019-04-09 15:18:21 +0530
committerOren Kleks <orenkle@amdocs.com>2019-04-10 08:31:51 +0000
commitc4e0ca667a62902b8d681ee5ecb1dc60a1e2b83e (patch)
tree158022f9c7bde4106b3ae765520d4b946a4bbc7d /openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services
parentab5c816e1578d8f0dba231e0026e5175a84c31c3 (diff)
VSP Compliance Check for Compute Flavor-BE
Change-Id: Ife3eb83ab49e50fde1b0eb128e7e1abd5043432f Issue-ID: SDC-2051 Co-authored-by: jguistwite@iconectiv.com Signed-off-by: Vodafone <onap@vodafone.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/ExternalTesting.java10
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/services/ExternalTestingImpl.java44
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/test/java/org/openecomp/sdcrests/externaltesting/rest/services/ApiTests.java18
3 files changed, 61 insertions, 11 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/ExternalTesting.java b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/ExternalTesting.java
index 14c45fbdbe..21cab55dc0 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/ExternalTesting.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/ExternalTesting.java
@@ -17,6 +17,8 @@
package org.openecomp.sdcrests.externaltesting.rest;
import io.swagger.annotations.Api;
+import org.openecomp.core.externaltesting.api.ClientConfiguration;
+import org.openecomp.core.externaltesting.api.RemoteTestingEndpointDefinition;
import org.openecomp.core.externaltesting.api.VtpTestExecutionRequest;
import org.springframework.validation.annotation.Validated;
@@ -38,6 +40,10 @@ public interface ExternalTesting {
@Path("/config")
Response getConfig();
+ @PUT
+ @Path("/config")
+ Response setConfig(ClientConfiguration config);
+
@GET
@Path("/testcasetree")
Response getTestCasesAsTree();
@@ -46,6 +52,10 @@ public interface ExternalTesting {
@Path("/endpoints")
Response getEndpoints();
+ @PUT
+ @Path("/endpoints")
+ Response setEndpoints(List<RemoteTestingEndpointDefinition> endpoints);
+
@GET
@Path("/endpoints/{endpointId}/scenarios")
Response getScenarios(@PathParam("endpointId") String endpointId);
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/services/ExternalTestingImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/services/ExternalTestingImpl.java
index 206eb4986b..4e8134ff69 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/services/ExternalTestingImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/main/java/org/openecomp/sdcrests/externaltesting/rest/services/ExternalTestingImpl.java
@@ -24,6 +24,7 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdcrests.externaltesting.rest.ExternalTesting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import javax.inject.Named;
@@ -62,6 +63,22 @@ public class ExternalTestingImpl implements ExternalTesting {
}
/**
+ * To enable automated functional testing, allow
+ * a put for the client configuration.
+ * @return JSON response content.
+ */
+ @Override
+ public Response setConfig(ClientConfiguration config) {
+ try {
+ return Response.ok(testingManager.setConfig(config)).build();
+ }
+ catch (ExternalTestingException e) {
+ return convertTestingException(e);
+ }
+ }
+
+
+ /**
* Return the test tree structure created by the testing manager.
* @return JSON response content.
*/
@@ -83,8 +100,22 @@ public class ExternalTestingImpl implements ExternalTesting {
catch (ExternalTestingException e) {
return convertTestingException(e);
}
+ }
+ /**
+ * To enable automated functional testing, allow a put of the endpoints.
+ * @return JSON response content.
+ */
+ @Override
+ public Response setEndpoints(List<RemoteTestingEndpointDefinition> endpoints) {
+ try {
+ return Response.ok(testingManager.setEndpoints(endpoints)).build();
+ }
+ catch (ExternalTestingException e) {
+ return convertTestingException(e);
+ }
}
+
@Override
public Response getScenarios(String endpoint) {
try {
@@ -130,13 +161,12 @@ public class ExternalTestingImpl implements ExternalTesting {
public Response execute(List<VtpTestExecutionRequest> req, String requestId) {
try {
List<VtpTestExecutionResponse> responses = testingManager.execute(req, requestId);
- List<Integer> statuses = responses.stream().map(r-> Optional.ofNullable(r.getHttpStatus()).orElse(200)).distinct().collect(Collectors.toList());
+ List<Integer> statuses = responses.stream().map(r-> Optional.ofNullable(r.getHttpStatus()).orElse(HttpStatus.OK.value())).distinct().collect(Collectors.toList());
if (statuses.size() == 1) {
- // 1 status so use it...
- return Response.status(statuses.get(0)).entity(responses).build();
+ return Response.status(HttpStatus.OK.value()).entity(responses).build();
}
else {
- return Response.status(207).entity(responses).build();
+ return Response.status(HttpStatus.MULTI_STATUS.value()).entity(responses).build();
}
}
catch (ExternalTestingException e) {
@@ -156,9 +186,9 @@ public class ExternalTestingImpl implements ExternalTesting {
private Response convertTestingException(ExternalTestingException e) {
if (logger.isErrorEnabled()) {
- logger.error("testing exception {} {} {}", e.getTitle(), e.getCode(), e.getDetail(), e);
+ logger.error("testing exception {} {} {}", e.getMessageCode(), e.getHttpStatus(), e.getDetail(), e);
}
- TestErrorBody body = new TestErrorBody(e.getTitle(), e.getCode(), e.getDetail());
- return Response.status(e.getCode()).entity(body).build();
+ TestErrorBody body = new TestErrorBody(e.getMessageCode(), e.getHttpStatus(), e.getDetail());
+ return Response.status(e.getHttpStatus()).entity(body).build();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/test/java/org/openecomp/sdcrests/externaltesting/rest/services/ApiTests.java b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/test/java/org/openecomp/sdcrests/externaltesting/rest/services/ApiTests.java
index d9da7e9006..411be2f150 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/test/java/org/openecomp/sdcrests/externaltesting/rest/services/ApiTests.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/src/test/java/org/openecomp/sdcrests/externaltesting/rest/services/ApiTests.java
@@ -58,13 +58,23 @@ public class ApiTests {
Assert.assertNotNull(testing.getTestCasesAsTree());
List<VtpTestExecutionRequest> requests =
- Arrays.asList(new VtpTestExecutionRequest(), new VtpTestExecutionRequest());
+ Arrays.asList(new VtpTestExecutionRequest(), new VtpTestExecutionRequest());
Assert.assertNotNull(testing.execute(requests, "requestId"));
}
class ApiTestExternalTestingManager implements ExternalTestingManager {
@Override
- public String getConfig() {
+ public ClientConfiguration getConfig() {
+ throw new ExternalTestingException(EXPECTED, 500, EXPECTED);
+ }
+
+ @Override
+ public ClientConfiguration setConfig(ClientConfiguration config) {
+ throw new ExternalTestingException(EXPECTED, 500, EXPECTED);
+ }
+
+ @Override
+ public List<RemoteTestingEndpointDefinition> setEndpoints(List<RemoteTestingEndpointDefinition> endpoints) {
throw new ExternalTestingException(EXPECTED, 500, EXPECTED);
}
@@ -74,7 +84,7 @@ public class ApiTests {
}
@Override
- public List<VtpNameDescriptionPair> getEndpoints() {
+ public List<RemoteTestingEndpointDefinition> getEndpoints() {
throw new ExternalTestingException(EXPECTED, 500, EXPECTED);
}
@@ -177,7 +187,7 @@ public class ApiTests {
}
List<VtpTestExecutionRequest> requestsF =
- Arrays.asList(new VtpTestExecutionRequest(), new VtpTestExecutionRequest());
+ Arrays.asList(new VtpTestExecutionRequest(), new VtpTestExecutionRequest());
try {
testingF.execute(requestsF, null);