summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2020-06-15 17:23:42 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-06-21 07:12:09 +0000
commitb0140364e491df1009cf00e50c0207d2e9ca3453 (patch)
tree17b65d348c09a79b3a226885bfd2cd5583d2dda7 /catalog-be/src/main
parent50c930a4095964a77611900401eff85f001c4aed (diff)
Add Node Filter Servlets Unit Tests
Issue-ID: SDC-3117 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I84e728f21290a59c7674f97d5977b945b93ef546
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java31
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java12
3 files changed, 20 insertions, 25 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 544f030d91..85453e33d2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -120,7 +120,7 @@ public abstract class BaseBusinessLogic {
protected IGroupInstanceOperation groupInstanceOperation;
protected InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
protected PolicyTypeOperation policyTypeOperation;
- protected ArtifactsOperations artifactToscaOperation;
+ protected ArtifactsOperations artifactToscaOperation;
protected UserValidations userValidations;
DataTypeValidatorConverter dataTypeValidatorConverter = DataTypeValidatorConverter.getInstance();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
index 3c770d15aa..27daaf2aae 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
@@ -7,9 +7,9 @@
* 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.
@@ -96,22 +96,21 @@ public class NodeFilterValidator {
final List<String> uiConstraints,
final NodeFilterConstraintAction action) {
try {
- for (final String uiConstraint : uiConstraints) {
- if (NodeFilterConstraintAction.ADD != action && NodeFilterConstraintAction.UPDATE != action) {
- break;
- }
- final UIConstraint constraint = new ConstraintConvertor().convert(uiConstraint);
- if (ConstraintConvertor.PROPERTY_CONSTRAINT.equals(constraint.getSourceType())) {
- final Either<Boolean, ResponseFormat> booleanResponseFormatEither =
+ if (NodeFilterConstraintAction.ADD == action || NodeFilterConstraintAction.UPDATE == action) {
+ for (final String uiConstraint : uiConstraints) {
+ final UIConstraint constraint = new ConstraintConvertor().convert(uiConstraint);
+ if (ConstraintConvertor.PROPERTY_CONSTRAINT.equals(constraint.getSourceType())) {
+ final Either<Boolean, ResponseFormat> booleanResponseFormatEither =
validatePropertyConstraint(parentComponent, componentInstanceId, constraint);
- if (booleanResponseFormatEither.isRight()) {
- return booleanResponseFormatEither;
- }
- } else if (ConstraintConvertor.STATIC_CONSTRAINT.equals(constraint.getSourceType())) {
- final Either<Boolean, ResponseFormat> booleanResponseFormatEither =
+ if (booleanResponseFormatEither.isRight()) {
+ return booleanResponseFormatEither;
+ }
+ } else if (ConstraintConvertor.STATIC_CONSTRAINT.equals(constraint.getSourceType())) {
+ final Either<Boolean, ResponseFormat> booleanResponseFormatEither =
validateStaticValueAndOperator(parentComponent, componentInstanceId, constraint);
- if (booleanResponseFormatEither.isRight()) {
- return booleanResponseFormatEither;
+ if (booleanResponseFormatEither.isRight()) {
+ return booleanResponseFormatEither;
+ }
}
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java
index 4a43ab23a6..7141379fe3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java
@@ -145,9 +145,9 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet {
LOGGER.debug(FAILED_TO_PARSE_COMPONENT);
return buildErrorResponse(convertResponse.right().value());
}
- final Optional<CINodeFilterDataDefinition> actionResponse;
final String constraint = new ConstraintConvertor().convert(uiConstraint);
- actionResponse = componentNodeFilterBusinessLogic
+
+ final Optional<CINodeFilterDataDefinition> actionResponse = componentNodeFilterBusinessLogic
.addNodeFilter(componentId.toLowerCase(), componentInstanceId, NodeFilterConstraintAction.ADD,
uiConstraint.getServicePropertyName(), constraint, true, componentTypeEnum);
@@ -163,7 +163,6 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError(NODE_FILTER_CREATION);
LOGGER.error(CREATE_NODE_FILTER_WITH_AN_ERROR, e);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
-
}
}
@@ -214,10 +213,8 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet {
LOGGER.debug("failed to parse data");
return buildErrorResponse(convertResponse.right().value());
}
- final Optional<CINodeFilterDataDefinition> actionResponse;
final List<String> constraints = new ConstraintConvertor().convertToList(uiConstraints);
-
- actionResponse = componentNodeFilterBusinessLogic
+ final Optional<CINodeFilterDataDefinition> actionResponse = componentNodeFilterBusinessLogic
.updateNodeFilter(componentId.toLowerCase(), componentInstanceId, constraints,
true, componentTypeEnum);
@@ -262,8 +259,7 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet {
componentNodeFilterBusinessLogic.validateUser(userId);
try {
- final Optional<CINodeFilterDataDefinition> actionResponse;
- actionResponse = componentNodeFilterBusinessLogic
+ final Optional<CINodeFilterDataDefinition>actionResponse = componentNodeFilterBusinessLogic
.deleteNodeFilter(componentId.toLowerCase(), componentInstanceId, NodeFilterConstraintAction.DELETE,
null, index, true, ComponentTypeEnum.findByParamName(componentType));