From d378c37fbd1ecec7b43394926f1ca32a695e07de Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 22 Mar 2021 15:33:06 +0000 Subject: Reformat openecomp-be Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1 --- .../externaltesting/api/ClientConfiguration.java | 10 +- .../api/ExternalTestingManager.java | 14 +- .../api/RemoteTestingEndpointDefinition.java | 36 ++--- .../core/externaltesting/api/TestErrorBody.java | 27 ++-- .../core/externaltesting/api/TestTreeNode.java | 31 ++-- .../api/VtpNameDescriptionPair.java | 19 ++- .../core/externaltesting/api/VtpTestCase.java | 30 ++-- .../core/externaltesting/api/VtpTestCaseInput.java | 28 ++-- .../externaltesting/api/VtpTestCaseOutput.java | 4 +- .../api/VtpTestExecutionRequest.java | 21 ++- .../api/VtpTestExecutionResponse.java | 52 +++---- .../errors/ExternalTestingException.java | 50 +++---- .../ExternalTestingInitializationException.java | 14 +- .../factory/ExternalTestingManagerFactory.java | 8 +- .../impl/ExternalTestingManagerImpl.java | 156 ++++++++++----------- .../externaltesting/impl/TestingAccessConfig.java | 7 +- 16 files changed, 240 insertions(+), 267 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-externaltesting-lib') diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ClientConfiguration.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ClientConfiguration.java index 9269e8bf22..285a5782cd 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ClientConfiguration.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ClientConfiguration.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.core.externaltesting.api; import lombok.Data; @Data public class ClientConfiguration { - /** - * Enable/disable state for the feature. Client can use this - * to show/hide menu items. - */ - private boolean enabled; + /** + * Enable/disable state for the feature. Client can use this to show/hide menu items. + */ + private boolean enabled; } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java index 21d09edc91..0cbaf41583 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java @@ -23,8 +23,7 @@ import java.util.Map; public interface ExternalTestingManager { /** - * Return the configuration of this feature that we want to - * expose to the client. Treated as a JSON blob for flexibility. + * Return the configuration of this feature that we want to expose to the client. Treated as a JSON blob for flexibility. */ ClientConfiguration getConfig(); @@ -34,8 +33,7 @@ public interface ExternalTestingManager { ClientConfiguration setConfig(ClientConfiguration config); /** - * Build a tree of all test cases for the client including all - * defined endpoints, scenarios, and test suites. + * Build a tree of all test cases for the client including all defined endpoints, scenarios, and test suites. * * @return test case tree. */ @@ -48,8 +46,7 @@ public interface ExternalTestingManager { /** - * For functional testing purposes, allow the endpoint configuration - * to be provisioned to the BE. + * For functional testing purposes, allow the endpoint configuration to be provisioned to the BE. */ List setEndpoints(List endpoints); @@ -84,8 +81,7 @@ public interface ExternalTestingManager { VtpTestCase getTestCase(String endpoint, String scenario, String testSuite, String testCaseName); /** - * Execute a collection of tests where the manager must distribute - * the tests to the appropriate endpoint and correlate the responses. + * Execute a collection of tests where the manager must distribute the tests to the appropriate endpoint and correlate the responses. * * @param requests collection of request items. * @param requestId optional request ID provided from client. @@ -96,7 +92,7 @@ public interface ExternalTestingManager { */ List execute(List requests, String vspId, String vspVersionId, - String requestId, Map fileMap); + String requestId, Map fileMap); /** diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/RemoteTestingEndpointDefinition.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/RemoteTestingEndpointDefinition.java index 0d5c30d593..22ebe9b465 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/RemoteTestingEndpointDefinition.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/RemoteTestingEndpointDefinition.java @@ -17,30 +17,30 @@ package org.openecomp.core.externaltesting.api; import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.Data; - import java.util.regex.Pattern; +import lombok.Data; @Data public class RemoteTestingEndpointDefinition { - private boolean enabled; - private String title; - private String url; - private String id; - private String apiKey; - private String scenarioFilter; - // a compact way to specify and endpoint to ease docker configuration. - @JsonIgnore - private String config; + private boolean enabled; + private String title; + private String url; + private String id; + private String apiKey; + private String scenarioFilter; + + // a compact way to specify and endpoint to ease docker configuration. + @JsonIgnore + private String config; - private Pattern scenarioFilterPattern; + private Pattern scenarioFilterPattern; - @JsonIgnore - public Pattern getScenarioFilterPattern() { - if ((scenarioFilterPattern == null) && (scenarioFilter != null)) { - scenarioFilterPattern = Pattern.compile(scenarioFilter); + @JsonIgnore + public Pattern getScenarioFilterPattern() { + if ((scenarioFilterPattern == null) && (scenarioFilter != null)) { + scenarioFilterPattern = Pattern.compile(scenarioFilter); + } + return scenarioFilterPattern; } - return scenarioFilterPattern; - } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java index d721f8997a..aa4d63c475 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java @@ -18,9 +18,8 @@ package org.openecomp.core.externaltesting.api; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * Error body to return to client per IETF RFC 7807. @@ -31,20 +30,20 @@ import java.io.Serializable; @Data public class TestErrorBody implements Serializable { - private static final long serialVersionUID = 3504501412736665763L; + private static final long serialVersionUID = 3504501412736665763L; - private String code; - private Integer httpStatus; - private String message; + private String code; + private Integer httpStatus; + private String message; - TestErrorBody() { + TestErrorBody() { - } + } - public TestErrorBody(String code, Integer httpStatus, String message) { - this(); - this.code = code; - this.httpStatus = httpStatus; - this.message = message; - } + public TestErrorBody(String code, Integer httpStatus, String message) { + this(); + this.code = code; + this.httpStatus = httpStatus; + this.message = message; + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java index 1b75772476..4965abffcd 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java @@ -17,34 +17,31 @@ package org.openecomp.core.externaltesting.api; import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.ArrayList; -import java.util.List; - /** - * Tree structure of tests. VTP does not provide an organized - * tree of tests. Here we define a tree node with tests and - * child nodes to represent our tree. + * Tree structure of tests. VTP does not provide an organized tree of tests. Here we define a tree node with tests and child nodes to represent our + * tree. */ @SuppressWarnings("unused") @JsonInclude(JsonInclude.Include.NON_EMPTY) @Data() -@EqualsAndHashCode(callSuper=true) +@EqualsAndHashCode(callSuper = true) public class TestTreeNode extends VtpNameDescriptionPair { - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List tests; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List tests; - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List children; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; - public TestTreeNode() { - super(); - } + public TestTreeNode() { + super(); + } - public TestTreeNode(String name, String description) { - super(name, description); - } + public TestTreeNode(String name, String description) { + super(name, description); + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java index 9a435de4ae..c34d4d4aea 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.core.externaltesting.api; import lombok.Data; @@ -23,16 +22,16 @@ import lombok.Data; */ @Data public class VtpNameDescriptionPair { - private String name; - private String description; - VtpNameDescriptionPair() { + private String name; + private String description; - } + VtpNameDescriptionPair() { + } - public VtpNameDescriptionPair(String name, String description) { - this(); - this.name = name; - this.description = description; - } + public VtpNameDescriptionPair(String name, String description) { + this(); + this.name = name; + this.description = description; + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java index ae39159f32..d8a81ae9fe 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java @@ -16,27 +16,25 @@ package org.openecomp.core.externaltesting.api; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class VtpTestCase { - private String scenario; - private String testCaseName; - private String testSuiteName; - private String description; - private String author; - private List inputs; - private List outputs; - - /** - * Extends VTP test case content with location where test case is defined. - * This value is populated by the SDC-BE for consumption by the front end. - * This allows the front end to tell the back end where to run the test. - */ - private String endpoint; + private String scenario; + private String testCaseName; + private String testSuiteName; + private String description; + private String author; + private List inputs; + private List outputs; + + /** + * Extends VTP test case content with location where test case is defined. This value is populated by the SDC-BE for consumption by the front end. + * This allows the front end to tell the back end where to run the test. + */ + private String endpoint; } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java index 5c6db8eb72..19d6303f39 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java @@ -16,27 +16,25 @@ package org.openecomp.core.externaltesting.api; +import java.util.Map; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Map; - @Data -@EqualsAndHashCode(callSuper=true) +@EqualsAndHashCode(callSuper = true) public class VtpTestCaseInput extends VtpNameDescriptionPair { - private String type; - private String defaultValue; - private boolean isOptional; - private Map metadata; + private String type; + private String defaultValue; + private boolean isOptional; + private Map metadata; - /** - * The VTP API has a field called isOptional, not just optional so - * we need to add getter and setter. - */ - @SuppressWarnings({"unused", "WeakerAccess"}) - public boolean getIsOptional() { - return isOptional; - } + /** + * The VTP API has a field called isOptional, not just optional so we need to add getter and setter. + */ + @SuppressWarnings({"unused", "WeakerAccess"}) + public boolean getIsOptional() { + return isOptional; + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java index 7d4ae84544..b3781b3978 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java @@ -24,8 +24,8 @@ import lombok.EqualsAndHashCode; @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "VtpTestSuite") @Data -@EqualsAndHashCode(callSuper=true) +@EqualsAndHashCode(callSuper = true) class VtpTestCaseOutput extends VtpNameDescriptionPair { - private String type; + private String type; } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java index 481fd46906..59f3b7d566 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java @@ -17,23 +17,22 @@ package org.openecomp.core.externaltesting.api; import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.Data; - import java.util.Map; +import lombok.Data; @Data public class VtpTestExecutionRequest { - private String scenario; - private String testSuiteName; - private String testCaseName; + private String scenario; + private String testSuiteName; + private String testCaseName; - @JsonInclude(value = JsonInclude.Include.NON_NULL) - private String profile; + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private String profile; - @JsonInclude(value = JsonInclude.Include.NON_NULL) - private Map parameters; + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private Map parameters; - @JsonInclude(value = JsonInclude.Include.NON_NULL) - private String endpoint; + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private String endpoint; } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java index add85210cb..c9756469ce 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java @@ -17,37 +17,37 @@ package org.openecomp.core.externaltesting.api; import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.Data; - import java.util.Map; +import lombok.Data; @Data public class VtpTestExecutionResponse { - private String scenario; - private String testCaseName; - private String testSuiteName; - private String executionId; - private Map parameters; - private Object results; - private String status; - private String startTime; // don't bother to convert various ISO8601 formats. - private String endTime; // don't bother to convert various ISO8601 formats. - /** - * In the event on an error, code provided. - */ - @JsonInclude(value= JsonInclude.Include.NON_NULL) - private String code; + private String scenario; + private String testCaseName; + private String testSuiteName; + private String executionId; + private Map parameters; + private Object results; + private String status; + private String startTime; // don't bother to convert various ISO8601 formats. + private String endTime; // don't bother to convert various ISO8601 formats. + + /** + * In the event on an error, code provided. + */ + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private String code; - /** - * Error message - */ - @JsonInclude(value= JsonInclude.Include.NON_NULL) - private String message; + /** + * Error message + */ + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private String message; - /** - * In the event of an unexpected status. - */ - @JsonInclude(value= JsonInclude.Include.NON_NULL) - private Integer httpStatus; + /** + * In the event of an unexpected status. + */ + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private Integer httpStatus; } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java index 3df64a40eb..731cf4ae54 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java @@ -21,31 +21,31 @@ import lombok.EqualsAndHashCode; import org.apache.commons.lang3.builder.ToStringBuilder; @Data -@EqualsAndHashCode(callSuper=false) +@EqualsAndHashCode(callSuper = false) public class ExternalTestingException extends RuntimeException { - private static final long serialVersionUID = -4357810130868566088L; - - private final String messageCode; - private final int httpStatus; - private final String detail; - - public ExternalTestingException(String messageCode, int httpStatus, String detail) { - super(messageCode); - this.messageCode = messageCode; - this.httpStatus = httpStatus; - this.detail = detail; - } - - public ExternalTestingException(String messageCode, int httpStatus, String detail, Throwable parent) { - super(messageCode, parent); - this.messageCode = messageCode; - this.httpStatus = httpStatus; - this.detail = detail; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } + private static final long serialVersionUID = -4357810130868566088L; + + private final String messageCode; + private final int httpStatus; + private final String detail; + + public ExternalTestingException(String messageCode, int httpStatus, String detail) { + super(messageCode); + this.messageCode = messageCode; + this.httpStatus = httpStatus; + this.detail = detail; + } + + public ExternalTestingException(String messageCode, int httpStatus, String detail, Throwable parent) { + super(messageCode, parent); + this.messageCode = messageCode; + this.httpStatus = httpStatus; + this.detail = detail; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java index 28f40199ca..a54409b1a8 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java @@ -21,13 +21,13 @@ import java.io.IOException; @SuppressWarnings("unused") public class ExternalTestingInitializationException extends IOException { - private static final long serialVersionUID = -2422448175010311433L; + private static final long serialVersionUID = -2422448175010311433L; - public ExternalTestingInitializationException(String message) { - super(message); - } + public ExternalTestingInitializationException(String message) { + super(message); + } - public ExternalTestingInitializationException(String message, Throwable cause) { - super(message, cause); - } + public ExternalTestingInitializationException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java index e84a4c86a1..05547799cc 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java @@ -16,15 +16,15 @@ package org.openecomp.core.externaltesting.factory; +import org.openecomp.core.externaltesting.api.ExternalTestingManager; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -import org.openecomp.core.externaltesting.api.ExternalTestingManager; @SuppressWarnings("unused") public abstract class ExternalTestingManagerFactory extends AbstractComponentFactory { - public static ExternalTestingManagerFactory getInstance() { - return AbstractFactory.getInstance(ExternalTestingManagerFactory.class); - } + public static ExternalTestingManagerFactory getInstance() { + return AbstractFactory.getInstance(ExternalTestingManagerFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java index dfabf31568..f115a98e5b 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java @@ -75,8 +75,8 @@ import org.springframework.web.util.UriComponentsBuilder; public class ExternalTestingManagerImpl implements ExternalTestingManager { - private Logger logger = LoggerFactory.getLogger(ExternalTestingManagerImpl.class); - + static final String VSP_ID = "vspId"; + static final String VSP_VERSION = "vspVersion"; private static final String FILE_URL_PREFIX = "file://"; private static final String HTTP_STATUS = "httpStatus"; private static final String CODE = "code"; @@ -84,7 +84,6 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { private static final String MESSAGE = "message"; private static final String DETAIL = "detail"; private static final String PATH = "path"; - private static final String VTP_SCENARIOS_URI = "%s/v1/vtp/scenarios"; private static final String VTP_TESTSUITE_URI = "%s/v1/vtp/scenarios/%s/testsuites"; private static final String VTP_TESTCASES_URI = "%s/v1/vtp/scenarios/%s/testcases"; @@ -92,23 +91,15 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { private static final String VTP_EXECUTIONS_URI = "%s/v1/vtp/executions"; private static final String VTP_EXECUTION_URI = "%s/v1/vtp/executions/%s"; private static final String VTP_EXECUTION_ID_URL = "%s/v1/vtp/executions?requestId=%s"; - - private static final String INVALIDATE_STATE_ERROR_CODE = "SDC-TEST-001"; private static final String NO_ACCESS_CONFIGURATION_DEFINED = "No access configuration defined"; - private static final String NO_SUCH_ENDPOINT_ERROR_CODE = "SDC-TEST-002"; private static final String ENDPOINT_ERROR_CODE = "SDC-TEST-003"; private static final String TESTING_HTTP_ERROR_CODE = "SDC-TEST-004"; private static final String SDC_RESOLVER_ERR = "SDC-TEST-005"; - - static final String VSP_ID = "vspId"; - static final String VSP_VERSION = "vspVersion"; - private static final String VSP_CSAR = "vsp"; private static final String VSP_HEAT = "vsp-zip"; - - + private Logger logger = LoggerFactory.getLogger(ExternalTestingManagerImpl.class); private VersioningManager versioningManager; private VendorSoftwareProductManager vendorSoftwareProductManager; private OrchestrationTemplateCandidateManager candidateManager; @@ -123,8 +114,8 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } ExternalTestingManagerImpl(VersioningManager versioningManager, - VendorSoftwareProductManager vendorSoftwareProductManager, - OrchestrationTemplateCandidateManager candidateManager) { + VendorSoftwareProductManager vendorSoftwareProductManager, + OrchestrationTemplateCandidateManager candidateManager) { this(); this.versioningManager = versioningManager; this.vendorSoftwareProductManager = vendorSoftwareProductManager; @@ -132,8 +123,8 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } /** - * Read the configuration from the yaml file for this bean. If we get an exception during load, - * don't force an error starting SDC but log a warning. Do no warm... + * Read the configuration from the yaml file for this bean. If we get an exception during load, don't force an error starting SDC but log a + * warning. Do no warm... */ @PostConstruct public void init() { @@ -173,9 +164,8 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } /** - * Load the configuration for this component. When the SDC onboarding backend - * runs, it gets a system property called config.location. We can use that - * to locate the config-externaltesting.yaml file. + * Load the configuration for this component. When the SDC onboarding backend runs, it gets a system property called config.location. We can use + * that to locate the config-externaltesting.yaml file. */ private void loadConfig() { String loc = System.getProperty("config.location"); @@ -190,7 +180,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } endpoints = - accessConfig.getEndpoints().stream().flatMap(this::mapEndpointString).collect(Collectors.toList()); + accessConfig.getEndpoints().stream().flatMap(this::mapEndpointString).collect(Collectors.toList()); if (logger.isInfoEnabled()) { String s = new ObjectMapper().writeValueAsString(endpoints); @@ -207,8 +197,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } /** - * Return the configuration of this feature that we want to - * expose to the client. Treated as a JSON blob for flexibility. + * Return the configuration of this feature that we want to expose to the client. Treated as a JSON blob for flexibility. */ @Override public ClientConfiguration getConfig() { @@ -224,9 +213,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } /** - * To allow for functional testing, we let a caller invoke - * a setConfig request to enable/disable the client. This - * new value is not persisted. + * To allow for functional testing, we let a caller invoke a setConfig request to enable/disable the client. This new value is not persisted. * * @return new client configuration */ @@ -240,8 +227,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } /** - * To allow for functional testing, we let a caller invoke - * a setEndpoints request to configure where the BE makes request to. + * To allow for functional testing, we let a caller invoke a setEndpoints request to configure where the BE makes request to. * * @return new endpoint definitions. */ @@ -273,14 +259,14 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { try { logger.debug("process endpoint {}", ep.getId()); getScenarios(ep.getId()).stream() - .filter(s -> ((ep.getScenarioFilter() == null) || ep.getScenarioFilterPattern().matcher(s.getName()) - .matches())).forEach(s -> { + .filter(s -> ((ep.getScenarioFilter() == null) || ep.getScenarioFilterPattern().matcher(s.getName()) + .matches())).forEach(s -> { addScenarioToTree(root, s); getTestSuites(ep.getId(), s.getName()).forEach(suite -> addSuiteToTree(root, s, suite)); getTestCases(ep.getId(), s.getName()).forEach(tc -> { try { VtpTestCase details = - getTestCase(ep.getId(), s.getName(), tc.getTestSuiteName(), tc.getTestCaseName()); + getTestCase(ep.getId(), s.getName(), tc.getTestSuiteName(), tc.getTestCaseName()); addTestCaseToTree(root, ep.getId(), s.getName(), tc.getTestSuiteName(), details); } catch (@SuppressWarnings("squid:S1166") ExternalTestingException ex) { // Not logging stack trace on purpose. VTP was throwing exceptions for certain test cases. @@ -310,19 +296,19 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { * @param tc test case to add. */ private void addTestCaseToTree(TestTreeNode root, String endpointName, String scenarioName, String testSuiteName, - VtpTestCase tc) { + VtpTestCase tc) { // return quickly. if (tc == null) { return; } findNamedChild(root, scenarioName) - .ifPresent(scenarioNode -> findNamedChild(scenarioNode, testSuiteName).ifPresent(suiteNode -> { - massageTestCaseForUI(tc, endpointName, scenarioName); - if (suiteNode.getTests() == null) { - suiteNode.setTests(new ArrayList<>()); - } - suiteNode.getTests().add(tc); - })); + .ifPresent(scenarioNode -> findNamedChild(scenarioNode, testSuiteName).ifPresent(suiteNode -> { + massageTestCaseForUI(tc, endpointName, scenarioName); + if (suiteNode.getTests() == null) { + suiteNode.setTests(new ArrayList<>()); + } + suiteNode.getTests().add(tc); + })); } private void massageTestCaseForUI(VtpTestCase testcase, String endpoint, String scenario) { @@ -341,7 +327,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { * @param suite test suite to add. */ private void addSuiteToTree(final TestTreeNode root, final VtpNameDescriptionPair scenario, - final VtpNameDescriptionPair suite) { + final VtpNameDescriptionPair suite) { findNamedChild(root, scenario.getName()).ifPresent(parent -> { if (parent.getChildren() == null) { parent.setChildren(new ArrayList<>()); @@ -387,7 +373,8 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { */ private List returnNameDescriptionPairFromUrl(String url) { ParameterizedTypeReference> t = - new ParameterizedTypeReference>() { }; + new ParameterizedTypeReference>() { + }; List rv = proxyGetRequestToExternalTestingSite(url, t); if (rv == null) { rv = new ArrayList<>(); @@ -407,18 +394,19 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { * Get the list of test suites for an endpoint for the given scenario. */ public List getTestSuites(final String endpoint, final String scenario) { - String url = buildEndpointUrl(VTP_TESTSUITE_URI, endpoint, new String[] {scenario}); + String url = buildEndpointUrl(VTP_TESTSUITE_URI, endpoint, new String[]{scenario}); return returnNameDescriptionPairFromUrl(url); } /** - * Get the list of test cases under a scenario. This is the VTP API. It would - * seem better to get the list of cases under a test suite but that is not supported. + * Get the list of test cases under a scenario. This is the VTP API. It would seem better to get the list of cases under a test suite but that + * is not supported. */ @Override public List getTestCases(String endpoint, String scenario) { - String url = buildEndpointUrl(VTP_TESTCASES_URI, endpoint, new String[] {scenario}); - ParameterizedTypeReference> t = new ParameterizedTypeReference>() { }; + String url = buildEndpointUrl(VTP_TESTCASES_URI, endpoint, new String[]{scenario}); + ParameterizedTypeReference> t = new ParameterizedTypeReference>() { + }; List rv = proxyGetRequestToExternalTestingSite(url, t); if (rv == null) { rv = new ArrayList<>(); @@ -431,8 +419,9 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { */ @Override public VtpTestCase getTestCase(String endpoint, String scenario, String testSuite, String testCaseName) { - String url = buildEndpointUrl(VTP_TESTCASE_URI, endpoint, new String[] {scenario, testSuite, testCaseName}); - ParameterizedTypeReference t = new ParameterizedTypeReference() { }; + String url = buildEndpointUrl(VTP_TESTCASE_URI, endpoint, new String[]{scenario, testSuite, testCaseName}); + ParameterizedTypeReference t = new ParameterizedTypeReference() { + }; return proxyGetRequestToExternalTestingSite(url, t); } @@ -445,9 +434,10 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { */ @Override public VtpTestExecutionResponse getExecution(String endpoint, String executionId) { - String url = buildEndpointUrl(VTP_EXECUTION_URI, endpoint, new String[] {executionId}); + String url = buildEndpointUrl(VTP_EXECUTION_URI, endpoint, new String[]{executionId}); ParameterizedTypeReference t = - new ParameterizedTypeReference() { }; + new ParameterizedTypeReference() { + }; return proxyGetRequestToExternalTestingSite(url, t); } @@ -461,19 +451,19 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { @Override public List execute(final List testsToRun, String vspId, - String vspVersionId, String requestId, Map fileMap) { + String vspVersionId, String requestId, Map fileMap) { if (endpoints == null) { throw new ExternalTestingException(INVALIDATE_STATE_ERROR_CODE, 500, NO_ACCESS_CONFIGURATION_DEFINED); } // partition the requests by endpoint. Map> partitions = - testsToRun.stream().collect(Collectors.groupingBy(VtpTestExecutionRequest::getEndpoint)); + testsToRun.stream().collect(Collectors.groupingBy(VtpTestExecutionRequest::getEndpoint)); // process each group and collect the results. return partitions.entrySet().stream().flatMap( - e -> doExecute(e.getKey(), e.getValue(), vspId, vspVersionId, requestId, fileMap).stream()) - .collect(Collectors.toList()); + e -> doExecute(e.getKey(), e.getValue(), vspId, vspVersionId, requestId, fileMap).stream()) + .collect(Collectors.toList()); } /** @@ -481,9 +471,10 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { */ @Override public List getExecutionIds(String endpoint, String requestId) { - String url = buildEndpointUrl(VTP_EXECUTION_ID_URL, endpoint, new String[] {requestId}); + String url = buildEndpointUrl(VTP_EXECUTION_ID_URL, endpoint, new String[]{requestId}); ParameterizedTypeReference> t = - new ParameterizedTypeReference>() { }; + new ParameterizedTypeReference>() { + }; List rv = proxyGetRequestToExternalTestingSite(url, t); if (rv == null) { rv = new ArrayList<>(); @@ -499,16 +490,17 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { * @return list of execution responses. */ private List doExecute(final String endpointName, - final List testsToRun, String vspId, String vspVersionId, String requestId, - Map fileMap) { + final List testsToRun, String vspId, String vspVersionId, + String requestId, + Map fileMap) { if (endpoints == null) { throw new ExternalTestingException(INVALIDATE_STATE_ERROR_CODE, 500, NO_ACCESS_CONFIGURATION_DEFINED); } RemoteTestingEndpointDefinition endpoint = - endpoints.stream().filter(e -> StringUtils.equals(endpointName, e.getId())).findFirst().orElseThrow( - () -> new ExternalTestingException(NO_SUCH_ENDPOINT_ERROR_CODE, 400, - "No endpoint named " + endpointName + " is defined")); + endpoints.stream().filter(e -> StringUtils.equals(endpointName, e.getId())).findFirst().orElseThrow( + () -> new ExternalTestingException(NO_SUCH_ENDPOINT_ERROR_CODE, 400, + "No endpoint named " + endpointName + " is defined")); // if the endpoint requires an API key, specify it in the headers. HttpHeaders headers = new HttpHeaders(); @@ -520,12 +512,11 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { // build the body. MultiValueMap body = new LinkedMultiValueMap<>(); - for (VtpTestExecutionRequest test : testsToRun) { // it will true only noramal validation not for certification if ((test.getParameters() != null) && (test.getParameters().containsKey(VSP_CSAR) || test.getParameters() - .containsKey( - VSP_HEAT))) { + .containsKey( + VSP_HEAT))) { attachArchiveContent(test, body, vspId, vspVersionId); } @@ -555,7 +546,8 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { builder = builder.queryParam("requestId", requestId); } ParameterizedTypeReference> t = - new ParameterizedTypeReference>() { }; + new ParameterizedTypeReference>() { + }; try { return proxyRequestToExternalTestingSite(builder.toUriString(), requestEntity, t); } catch (ExternalTestingException ex) { @@ -582,9 +574,9 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { private String buildEndpointUrl(String format, String endpointName, String[] args) { if (endpoints != null) { RemoteTestingEndpointDefinition ep = - endpoints.stream().filter(e -> e.isEnabled() && e.getId().equals(endpointName)).findFirst() - .orElseThrow(() -> new ExternalTestingException(NO_SUCH_ENDPOINT_ERROR_CODE, 500, - "No endpoint named " + endpointName + " is defined")); + endpoints.stream().filter(e -> e.isEnabled() && e.getId().equals(endpointName)).findFirst() + .orElseThrow(() -> new ExternalTestingException(NO_SUCH_ENDPOINT_ERROR_CODE, 500, + "No endpoint named " + endpointName + " is defined")); Object[] newArgs = ArrayUtils.add(args, 0, ep.getUrl()); return String.format(format, newArgs); @@ -614,7 +606,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { * @return instance of expected type */ private T proxyRequestToExternalTestingSite(String url, HttpEntity request, - ParameterizedTypeReference responseType) { + ParameterizedTypeReference responseType) { if (request != null) { logger.debug("POST request to {} with {} for {}", url, request, responseType.getType().getTypeName()); } else { @@ -636,9 +628,9 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { // make my own exception out of this. logger.warn("Unexpected HTTP Status from endpoint {}", ex.getRawStatusCode()); if ((ex.getResponseHeaders().getContentType() != null) && ( - (ex.getResponseHeaders().getContentType().isCompatibleWith(MediaType.APPLICATION_JSON)) - || (ex.getResponseHeaders().getContentType() - .isCompatibleWith(MediaType.parseMediaType("application/problem+json"))))) { + (ex.getResponseHeaders().getContentType().isCompatibleWith(MediaType.APPLICATION_JSON)) + || (ex.getResponseHeaders().getContentType() + .isCompatibleWith(MediaType.parseMediaType("application/problem+json"))))) { String s = ex.getResponseBodyAsString(); logger.warn("endpoint body content is {}", s); try { @@ -647,11 +639,11 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } catch (JsonParseException e) { logger.warn("unexpected JSON response", e); throw new ExternalTestingException(ENDPOINT_ERROR_CODE, ex.getStatusCode().value(), - ex.getResponseBodyAsString(), ex); + ex.getResponseBodyAsString(), ex); } } else { throw new ExternalTestingException(ENDPOINT_ERROR_CODE, ex.getStatusCode().value(), - ex.getResponseBodyAsString(), ex); + ex.getResponseBodyAsString(), ex); } } catch (ResourceAccessException ex) { throw new ExternalTestingException(ENDPOINT_ERROR_CODE, 500, ex.getMessage(), ex); @@ -675,8 +667,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } /** - * Errors from the endpoint could conform to the expected ETSI body or not. - * Here we try to handle various response body elements. + * Errors from the endpoint could conform to the expected ETSI body or not. Here we try to handle various response body elements. * * @param statusCode http status code in response. * @param o JSON object parsed from the http response body @@ -713,7 +704,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } void attachArchiveContent(VtpTestExecutionRequest test, MultiValueMap body, String vspId, - String vspVersionId) { + String vspVersionId) { try { extractMetadata(test, body, vspId, vspVersionId); } catch (IOException ex) { @@ -729,7 +720,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { * @param version VSP version */ private void extractMetadata(VtpTestExecutionRequest requestItem, MultiValueMap body, String vspId, - String version) throws IOException { + String version) throws IOException { Version ver = new Version(version); logger.debug("attempt to retrieve archive for VSP {} version {}", vspId, ver.getId()); @@ -742,12 +733,12 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { if (!ozip.isPresent()) { List versions = versioningManager.list(vspId); String knownVersions = versions.stream() - .map(v -> String.format("%d.%d: %s (%s)", v.getMajor(), v.getMinor(), - v.getStatus(), v.getId())).collect(Collectors.joining("\n")); + .map(v -> String.format("%d.%d: %s (%s)", v.getMajor(), v.getMinor(), + v.getStatus(), v.getId())).collect(Collectors.joining("\n")); String detail = String.format( - "Archive processing failed. Unable to find archive for VSP ID %s and Version %s. Known versions are:\n%s", - vspId, version, knownVersions); + "Archive processing failed. Unable to find archive for VSP ID %s and Version %s. Known versions are:\n%s", + vspId, version, knownVersions); throw new ExternalTestingException(SDC_RESOLVER_ERR, 500, detail); } @@ -758,8 +749,7 @@ public class ExternalTestingManagerImpl implements ExternalTestingManager { } private void processArchive(final VtpTestExecutionRequest test, final MultiValueMap body, - final byte[] zip) { - + final byte[] zip) { // VTP does not support concurrent executions of the same test with the same associated file name. // It writes files to /tmp and if we were to send two requests with the same file, the results diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java index b6bcb45516..ef5b2568eb 100644 --- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java +++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java @@ -16,16 +16,15 @@ package org.openecomp.core.externaltesting.impl; +import java.util.List; import lombok.Data; import org.openecomp.core.externaltesting.api.ClientConfiguration; -import java.util.List; - @SuppressWarnings("WeakerAccess") @Data public class TestingAccessConfig { - private ClientConfiguration client; - private List endpoints; + private ClientConfiguration client; + private List endpoints; } -- cgit 1.2.3-korg