aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-04-22 11:22:29 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-27 05:51:54 +0000
commit3c80616437c89c14b3734a3876b48faafd2129e9 (patch)
treef36ee300c907befd3781cda1cf336acf263bbe91 /catalog-be
parent8ddc6c9609581167a35404289e5015097346fea9 (diff)
Add null test to ComponentBusinessLogic
- Added test in `getFilteredComponentInstanceProperties` for null value - Removed nested `if` statements in `isMatchingComplexPropertyByRecursively` Issue-ID: SDC-2907 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: I13a47b0dfe7aa6dec845a856c58bba8be5c1eead
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 83e4cf4c65..0d25bb02c4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -22,7 +22,10 @@
package org.openecomp.sdc.be.components.impl;
+import com.sun.org.apache.xpath.internal.operations.Bool;
import fj.data.Either;
+import java.util.function.BooleanSupplier;
+import java.util.function.Supplier;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -689,7 +692,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.debug("The exception {} occured during filtered instance properties fetching. the containing component is {}. ", e, componentId);
response = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
} finally{
- if (response.isLeft()){
+ if (response != null && response.isLeft()){
toscaOperationFacade.commit();
} else {
toscaOperationFacade.rollback();
@@ -792,18 +795,16 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
currentProperty = getDataTypeByNameRes.left().value();
dataTypeProperties = currentProperty.getProperties();
- if(CollectionUtils.isNotEmpty(dataTypeProperties)){
- if (isMatchingComplexProperty(propertyNameFragment, searchByFragment, dataTypeProperties)){
- return true;
- }
- }
- dataTypeProperties = currentProperty.getDerivedFrom().getProperties();
- if(CollectionUtils.isNotEmpty(dataTypeProperties)){
- if (isMatchingComplexProperty(propertyNameFragment, searchByFragment, dataTypeProperties)){
- return true;
- }
- }
- return false;
+ boolean dataPropertiesNotNull = CollectionUtils.isNotEmpty(dataTypeProperties);
+ BooleanSupplier dataMatchesComplexProperty = () -> isMatchingComplexProperty(propertyNameFragment,
+ searchByFragment, dataTypeProperties);
+ BooleanSupplier parentPropertiesNotNull = () -> CollectionUtils
+ .isNotEmpty(currentProperty.getDerivedFrom().getProperties());
+ BooleanSupplier parentDataMatchesComplexProperty = () -> isMatchingComplexProperty(propertyNameFragment,
+ searchByFragment, currentProperty.getDerivedFrom().getProperties());
+
+ return ((dataPropertiesNotNull && dataMatchesComplexProperty.getAsBoolean())
+ || (parentPropertiesNotNull.getAsBoolean() && parentDataMatchesComplexProperty.getAsBoolean()));
}
private boolean isMatchingComplexProperty(String propertyNameFragment, boolean searchByFragment, List<PropertyDefinition> dataTypeProperties) {