summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
diff options
context:
space:
mode:
authorkaty.rotman <katy.rotman@amdocs.com>2018-02-21 10:18:53 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-02-21 14:00:36 +0000
commit4cc47ac3abe00eda7c04b9955e56dafc819e2657 (patch)
tree884ceaf250ec3b39879a28607107d6b4c46291d5 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
parent71331569b6e5fe1de2d2b964014f0e980364bcd0 (diff)
Heat Resource Validator code +tests
Change-Id: Ic1e10c15fbbc01580311057e71edf05506bd9e8f Issue-ID: SDC-994 Signed-off-by: katy.rotman <katy.rotman@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java50
1 files changed, 23 insertions, 27 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
index dbd13ed8e0..e9a265d7bc 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -326,44 +326,40 @@ public class HeatValidationService {
}
/**
- *
+ * This method verifies whether the propertyValue contains a single parent port
* @param fileName on which the validation is currently run
- * @param globalContext gloabl validation context
+ * @param globalContext global validation context
* @param heatResourceValidationContext heat resource validation context
* @param propertyValue the value which is examined
* @return whether the vlan has single parent port
*/
public static boolean hasSingleParentPort(String fileName, GlobalValidationContext globalContext,
- HeatResourceValidationContext heatResourceValidationContext,
- Object propertyValue) {
- boolean hasSingleParentPort;
- if (propertyValue instanceof List && ((List) propertyValue).size() == 1) {
- final Object listValue = ((List) propertyValue).get(0);
-
- final Set<String> getParamValues =
- HeatStructureUtil.getReferencedValuesByFunctionName(fileName, "get_param",
- listValue, globalContext);
- hasSingleParentPort = getParamValues.isEmpty() || (getParamValues.size() == 1) &&
- validateGetParamValueOfType(getParamValues, heatResourceValidationContext,
- DefinedHeatParameterTypes.STRING.getType());
- } else {
- hasSingleParentPort = false;
+ HeatResourceValidationContext heatResourceValidationContext,
+ Object propertyValue) {
+ final boolean isList = propertyValue instanceof List;
+ if (!isList || ((List) propertyValue).size() != 1) {
+ return false;
}
- return hasSingleParentPort;
+
+ final Object listValue = ((List) propertyValue).get(0);
+
+ final Set<String> getParamValues =
+ HeatStructureUtil.getReferencedValuesByFunctionName(fileName, "get_param",
+ listValue, globalContext);
+
+ return getParamValues.isEmpty() || (getParamValues.size() == 1) &&
+ validateGetParamValueOfType(getParamValues, heatResourceValidationContext,
+ DefinedHeatParameterTypes.STRING.getType());
+
}
+
private static boolean validateGetParamValueOfType(Set<String> values,
HeatResourceValidationContext
- heatResourceValidationContext,String type) {
- Optional<String> value = values.stream().findAny();
- boolean isString = false;
- if (value.isPresent()) {
- isString =
- Objects.equals(heatResourceValidationContext.getHeatOrchestrationTemplate
- ().getParameters().get(value.get()).getType(), type);
- }
+ heatResourceValidationContext, String type) {
- return isString;
+ return values.stream().anyMatch(e -> Objects.equals(
+ heatResourceValidationContext.getHeatOrchestrationTemplate().getParameters().get(e).getType(), type));
}
}