summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-05-04 13:58:39 -0400
committerOjas Dubey <Ojas.Dubey@amdocs.com>2020-05-05 12:13:48 +0000
commit8e039ab3f81af2d1452f1b2db06588883529a428 (patch)
treeaf04ec201a37d1af41bf1de8485e3ffd74a9b5e3 /catalog-be/src/main/java
parentefec7c5f7abb24da6d8ab93a71ee725e1c1f438f (diff)
Add tests for the presence of Optional values
Issue-ID: SDC-3012 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: I56cbf7fb5bd04ad2fbc496231d6abe72066124fe
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java38
1 files changed, 24 insertions, 14 deletions
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 fccc034baa..021e6b49e4 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
@@ -183,23 +183,33 @@ public class NodeFilterValidator {
private Either<Boolean, ResponseFormat> validatePropertyData(UIConstraint uiConstraint,
Optional<? extends PropertyDefinition> sourceSelectedProperty,
Optional<? extends PropertyDefinition> targetComponentInstanceProperty) {
- final PropertyDefinition sourcePropDefinition = sourceSelectedProperty.get();
- final String sourceType = sourcePropDefinition.getType();
- final PropertyDefinition targetPropDefinition = targetComponentInstanceProperty.get();
- final String targetType = targetPropDefinition.getType();
- if (sourceType.equals(targetType)) {
- if (schemableTypes.contains(sourceType)) {
- final SchemaDefinition sourceSchemaDefinition = sourcePropDefinition.getSchema();
- final SchemaDefinition targetSchemaDefinition = targetPropDefinition.getSchema();
- if (!sourceSchemaDefinition.equals(targetSchemaDefinition)) {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_SCHEMA_MISMATCH,
- uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
+ if (sourceSelectedProperty.isPresent() && targetComponentInstanceProperty.isPresent()) {
+ final PropertyDefinition sourcePropDefinition = sourceSelectedProperty.get();
+ final String sourceType = sourcePropDefinition.getType();
+ final PropertyDefinition targetPropDefinition = targetComponentInstanceProperty.get();
+ final String targetType = targetPropDefinition.getType();
+ if (sourceType.equals(targetType)) {
+ if (schemableTypes.contains(sourceType)) {
+ final SchemaDefinition sourceSchemaDefinition = sourcePropDefinition.getSchema();
+ final SchemaDefinition targetSchemaDefinition = targetPropDefinition.getSchema();
+ if (!sourceSchemaDefinition.equals(targetSchemaDefinition)) {
+ return Either
+ .right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_SCHEMA_MISMATCH,
+ uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
+ }
}
+ return Either.left(Boolean.TRUE);
+ } else {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_PROPERTY_TYPE_MISMATCH,
+ uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
}
- return Either.left(Boolean.TRUE);
} else {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_PROPERTY_TYPE_MISMATCH,
- uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
+ LOGGER.debug(
+ "Null value passed to `validatePropertyData` - sourceSelectedProperty: '{}' - targetComponentInstanceProperty: '{}'",
+ sourceSelectedProperty, targetComponentInstanceProperty);
+ return Either.right(componentsUtils
+ .getResponseFormat(ActionStatus.GENERAL_ERROR, uiConstraint.getServicePropertyName(),
+ uiConstraint.getValue().toString()));
}
}