aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/att-sdc-validation-impl/src/test/java/com/att/sdc/validation/impl/validators/AttValetGroupAssignmentResourceValidatorTest.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java39
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java5
15 files changed, 89 insertions, 40 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/att-sdc-validation-impl/src/test/java/com/att/sdc/validation/impl/validators/AttValetGroupAssignmentResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/att-sdc-validation-impl/src/test/java/com/att/sdc/validation/impl/validators/AttValetGroupAssignmentResourceValidatorTest.java
index 76e10215e3..acb54f4140 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/att-sdc-validation-impl/src/test/java/com/att/sdc/validation/impl/validators/AttValetGroupAssignmentResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/att-sdc-validation-impl/src/test/java/com/att/sdc/validation/impl/validators/AttValetGroupAssignmentResourceValidatorTest.java
@@ -1,8 +1,6 @@
package com.att.sdc.validation.impl.validators;
import com.att.sdc.validation.datatypes.AttHeatResourceTypes;
-import com.att.sdc.validation.datatypes.AttValetGroupTypeValues;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.api.ValidationManager;
import org.openecomp.core.validation.factory.ValidationManagerFactory;
import org.openecomp.core.validation.types.GlobalValidationContext;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
index 8bb95afacd..e3464db8d8 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
@@ -24,6 +24,8 @@ import org.openecomp.config.ConfigurationUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -38,6 +40,8 @@ import java.util.stream.Collectors;
public class HeatTreeManagerTest {
+ private Logger logger = LoggerFactory.getLogger(HeatTreeManagerTest.class);
+
@Test
public void testHeatTreeCreation() {
@@ -66,7 +70,7 @@ public class HeatTreeManagerTest {
try {
return FileUtils.toByteArray(new FileInputStream(file));
} catch (IOException e) {
- e.printStackTrace();
+ logger.debug("",e);
}
return new byte[0];
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 485b4204c7..39362c7e10 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
@@ -225,6 +225,7 @@ public class HeatValidationService {
throw new Exception("The file '" + nestedFileName + "' has no content");
}
} catch (Exception exception) {
+ logger.debug("",exception);
mdcDataDebugMessage.debugExitMessage("file", parentFileName);
return;
}
@@ -242,6 +243,7 @@ public class HeatValidationService {
throw new Exception("The file '" + parentFileName + "' has no content");
}
} catch (Exception exception) {
+ logger.debug("",exception);
mdcDataDebugMessage.debugExitMessage("file", parentFileName);
return;
}
@@ -374,6 +376,7 @@ public class HeatValidationService {
}
} catch (Exception exception) {
+ logger.debug("",exception);
logger.warn("HEAT Validator will not be executed on file " + nestedFileName
+ " due to illegal HEAT format");
@@ -462,6 +465,7 @@ public class HeatValidationService {
throw new Exception("The file '" + resourceType + "' has no content");
}
} catch (Exception exception) {
+ logger.debug("",exception);
return;
}
nestedOutputMap = nestedHeatOrchestrationTemplate.getOutputs();
@@ -511,6 +515,7 @@ public class HeatValidationService {
throw new Exception("The file '" + envFileName + "' has no content");
}
} catch (Exception exception) {
+ logger.debug("",exception);
mdcDataDebugMessage.debugExitMessage("env file", envFileName);
return null;
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
index 39556795c7..7d90726dd1 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
@@ -48,7 +48,7 @@ import java.util.Optional;
public class ContrailValidator implements Validator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
protected static Logger logger = (Logger) LoggerFactory.getLogger(ContrailValidator.class);
@Override
@@ -59,6 +59,7 @@ public class ContrailValidator implements Validator {
try {
manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
} catch (Exception exception) {
+ logger.debug("",exception);
return;
}
Map<String, FileData.Type> fileTypeMap = ManifestUtil.getFileTypeMap(manifestContent);
@@ -148,6 +149,7 @@ public class ContrailValidator implements Validator {
heatOrchestrationTemplate =
new YamlUtil().yamlToObject(fileContent, HeatOrchestrationTemplate.class);
} catch (Exception ignored) {
+ logger.debug("",ignored);
// the HeatValidator should handle file that is failing to parse
mdcDataDebugMessage.debugExitMessage("file", fileName);
return Optional.empty();
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
index 2531150eab..569f2bb760 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.validation.impl.validators;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -11,12 +10,14 @@ import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.util.ValidationUtil;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
@@ -29,6 +30,8 @@ public class ForbiddenResourceGuideLineValidator implements Validator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static Set<String> forbiddenResources = new HashSet<>();
+ private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+
@Override
public void init(Map<String, Object> properties) {
Map<String, Map<String, Object>> forbiddenResourcesMap =
@@ -62,6 +65,7 @@ public class ForbiddenResourceGuideLineValidator implements Validator {
try {
manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
} catch (Exception exception) {
+ log.debug("",exception);
return;
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
index 2712dab11c..1fda0ed783 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
@@ -27,7 +27,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
public class HeatResourceValidator extends ResourceBaseValidator {
@@ -48,7 +47,7 @@ public class HeatResourceValidator extends ResourceBaseValidator {
try {
manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
} catch (Exception exception) {
-
+ logger.debug("",exception);
}
Set<String> baseFiles = ManifestUtil.getBaseFiles(manifestContent);
String baseFileName = CollectionUtils.isEmpty(baseFiles) ? null : baseFiles.iterator().next();
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
index ddc1bb49b9..5297453369 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
@@ -55,7 +55,7 @@ import java.util.Objects;
import java.util.Set;
public class HeatValidator implements Validator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
protected static Logger logger = (Logger) LoggerFactory.getLogger(HeatValidator.class);
private static void validateAllRequiredArtifactsExist(String fileName,
@@ -244,7 +244,7 @@ public class HeatValidator implements Validator {
if (CollectionUtils.isNotEmpty(parametersNames)) {
for (Map.Entry<String, Object> envEntry : envContent.getParameters().entrySet()) {
String envParameter = envEntry.getKey();
- if (!parametersNames.contains(envParameter)) {
+ if (parametersNames != null && !parametersNames.contains(envParameter)) {
globalContext.addMessage(envFile, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
Messages.ENV_INCLUDES_PARAMETER_NOT_IN_HEAT.getErrorMessage(), envFile,
@@ -278,7 +278,7 @@ public class HeatValidator implements Validator {
Map<String, Parameter> parametersMap = heatOrchestrationTemplate.getParameters() == null ? null
: heatOrchestrationTemplate.getParameters();
- if (MapUtils.isNotEmpty(parametersMap)) {
+ if (parametersMap != null && MapUtils.isNotEmpty(parametersMap)) {
for (Map.Entry<String, Parameter> parameterEntry : parametersMap.entrySet()) {
Parameter parameter = parameterEntry.getValue();
String parameterType = parameter.getType();
@@ -343,6 +343,7 @@ public class HeatValidator implements Validator {
try {
manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
} catch (Exception exception) {
+ logger.debug("",exception);
return;
}
String baseFileName;
@@ -370,7 +371,8 @@ public class HeatValidator implements Validator {
Set<String> manifestArtifacts = ManifestUtil.getArtifacts(manifestContent);
globalContext.getFiles().stream()
- .filter(fileName -> manifestArtifacts.contains(fileName) && !artifacts.contains(fileName))
+ .filter(fileName -> isManifestArtifact(manifestArtifacts, fileName) &&
+ isNotArtifact(artifacts, fileName))
.forEach(fileName -> globalContext.addMessage(fileName, ErrorLevel.WARNING,
Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage(),
LoggerTragetServiceName.CHECK_FOR_ORPHAN_ARTIFACTS,
@@ -380,6 +382,14 @@ public class HeatValidator implements Validator {
}
+ private boolean isManifestArtifact(Set<String> manifestArtifacts, String fileName) {
+ return manifestArtifacts.contains(fileName);
+ }
+
+ private boolean isNotArtifact(Set<String> artifacts, String fileName) {
+ return !artifacts.contains(fileName);
+ }
+
private void validate(String fileName, String envFileName, String baseFileName,
Set<String> artifacts, Set<String> securityGroupsNamesFromBaseFileOutputs,
GlobalValidationContext globalContext) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
index 43cafb494c..79c4dc2d96 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
@@ -45,7 +45,7 @@ import java.util.Optional;
public class ManifestValidator implements Validator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static Logger logger = (Logger) LoggerFactory.getLogger(YamlValidator.class);
@Override
@@ -65,6 +65,7 @@ public class ManifestValidator implements Validator {
throw new Exception("The manifest file '" + SdcCommon.MANIFEST_NAME + "' has no content");
}
} catch (Exception re) {
+ logger.debug("",re);
globalContext.addMessage(SdcCommon.MANIFEST_NAME, ErrorLevel.ERROR,
Messages.INVALID_MANIFEST_FILE.getErrorMessage(),
LoggerTragetServiceName.VALIDATE_MANIFEST_CONTENT,
@@ -80,7 +81,7 @@ public class ManifestValidator implements Validator {
LoggerTragetServiceName.VALIDATE_FILE_IN_ZIP, LoggerErrorDescription.MISSING_FILE));
globalContext.getFileContextMap().keySet().stream().filter(name ->
- !manifestFiles.contains(name) && !SdcCommon.MANIFEST_NAME.equals(name)
+ isNotManifestFiles(manifestFiles, name) && isNotManifestName(name)
).forEach(name ->
globalContext.addMessage(name, ErrorLevel.WARNING,
Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage(),
@@ -90,6 +91,14 @@ public class ManifestValidator implements Validator {
mdcDataDebugMessage.debugExitMessage(null, null);
}
+ private boolean isNotManifestFiles(List<String> manifestFiles, String name) {
+ return !manifestFiles.contains(name);
+ }
+
+ private boolean isNotManifestName(String name) {
+ return !SdcCommon.MANIFEST_NAME.equals(name);
+ }
+
private List<String> getManifestFileList(ManifestContent manifestContent,
GlobalValidationContext context) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
index f3af7d7e48..04771e023e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
@@ -1,6 +1,8 @@
package org.openecomp.sdc.validation.impl.validators;
import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
@@ -26,7 +28,8 @@ import java.util.Set;
* Created by TALIO on 2/15/2017.
*/
public class SharedResourceGuideLineValidator implements Validator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@Override
public void validate(GlobalValidationContext globalContext) {
@@ -34,6 +37,7 @@ public class SharedResourceGuideLineValidator implements Validator {
try {
manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
} catch (Exception exception) {
+ log.debug("",exception);
return;
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
index 445e1c2e3d..0fded4f58e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
@@ -39,7 +39,7 @@ import java.util.Map;
import java.util.Optional;
public class YamlValidator implements Validator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final Logger logger = (Logger) LoggerFactory.getLogger(YamlValidator.class);
@Override
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
index 5dc42c9b9a..d05f2813ff 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
@@ -90,25 +90,26 @@ public class NovaServerResourceValidator implements ResourceValidator {
return;
}
- for (Object serverGroupValue : schedulerHintsMap.values()) {
- if(!(serverGroupValue instanceof Map)){
- continue;
- }
- Map<String, Object> currentServerMap = (Map<String, Object>) serverGroupValue;
- String serverResourceName =
- currentServerMap == null ? null : (String) currentServerMap
- .get(ResourceReferenceFunctions.GET_RESOURCE.getFunction());
- Resource serverResource =
- serverResourceName == null || resourcesMap == null ? null
- : resourcesMap.get(serverResourceName);
-
- if (serverResource != null && !serverResource.getType()
- .equals(HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource())) {
- globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.SERVER_NOT_DEFINED_FROM_NOVA.getErrorMessage(),
- serverResourceName, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_SERVER_GROUP_EXISTENCE,
- LoggerErrorDescription.SERVER_NOT_DEFINED_NOVA);
+ if (schedulerHintsMap != null) {
+ for (Object serverGroupValue : schedulerHintsMap.values()) {
+ if (!(serverGroupValue instanceof Map)) {
+ continue;
+ }
+ Map<String, Object> currentServerMap = (Map<String, Object>) serverGroupValue;
+ String serverResourceName = (String) currentServerMap
+ .get(ResourceReferenceFunctions.GET_RESOURCE.getFunction());
+ Resource serverResource =
+ serverResourceName == null || resourcesMap == null ? null
+ : resourcesMap.get(serverResourceName);
+
+ if (serverResource != null && !serverResource.getType()
+ .equals(HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource())) {
+ globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(Messages.SERVER_NOT_DEFINED_FROM_NOVA.getErrorMessage(),
+ serverResourceName, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_SERVER_GROUP_EXISTENCE,
+ LoggerErrorDescription.SERVER_NOT_DEFINED_NOVA);
+ }
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
index 6016ba0cb8..299eabf4e5 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
@@ -564,11 +564,12 @@ public class NovaServerNamingConventionGuideLineValidator implements ResourceVal
private String getVmName(String nameToGetVmNameFrom, String stringToGetIndexOf) {
int vmIndex =
nameToGetVmNameFrom == null ? -1 : nameToGetVmNameFrom.indexOf(stringToGetIndexOf);
- String vmName = vmIndex < 0 ? null
- : trimNonAlphaNumericCharactersFromEndOfString(nameToGetVmNameFrom.substring(0, vmIndex));
-
+ String vmName = null;
+ if (nameToGetVmNameFrom != null) {
+ vmName = vmIndex < 0 ? null
+ : trimNonAlphaNumericCharactersFromEndOfString(nameToGetVmNameFrom.substring(0, vmIndex));
+ }
return vmName;
-
}
private boolean isVmNameSync(List<String> namesToCompare) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
index 1a5b373833..f5d01d90e8 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
@@ -53,6 +53,7 @@ public class ResourceBaseValidator implements Validator {
try {
manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
} catch (Exception exception) {
+ logger.debug("",exception);
return;
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
index 3702e9253f..fa1946f987 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
@@ -15,6 +15,8 @@ import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.validation.ResourceValidator;
import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.Validator;
@@ -36,6 +38,9 @@ import java.util.Objects;
*/
public class ValidationTestUtil {
+ private final static Logger log = (Logger) LoggerFactory.getLogger(ValidationTestUtil.class
+ .getName());
+
public static GlobalValidationContext createGlobalContextFromPath(String path) {
GlobalValidationContext globalValidationContext = new GlobalValidationContext();
Map<String, byte[]> contentMap = getContentMapByPath(path);
@@ -71,7 +76,7 @@ public class ValidationTestUtil {
fileContent = FileUtils.toByteArray(fis);
contentMap.put(file.getName(), fileContent);
} catch (IOException e) {
- e.printStackTrace();
+ log.debug("",e);
}
}
return contentMap;
@@ -178,6 +183,7 @@ public class ValidationTestUtil {
CommonMethods.newInstance(validatorConf.getImplementationClass(), Validator.class);
validator.init(validatorConf.getProperties());
} catch (IllegalArgumentException iae) {
+ log.debug("",iae);
return null;
}
return validator;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java
index 3dcc7da876..41300f3852 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java
@@ -17,6 +17,8 @@ import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -37,6 +39,7 @@ import static java.util.Objects.nonNull;
public class ValidationUtil {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private final static Logger log = (Logger) LoggerFactory.getLogger(ValidationUtil.class.getName());
public static void removeExposedResourcesCalledByGetResource(String fileName,
Set<String> actualExposedResources,
@@ -138,6 +141,7 @@ public class ValidationUtil {
throw new Exception("The file '" + envFileName + "' has no content");
}
} catch (Exception exception) {
+ log.debug("",exception);
mdcDataDebugMessage.debugExitMessage("file", envFileName);
return null;
}
@@ -186,6 +190,7 @@ public class ValidationUtil {
try {
manifestContent = JsonUtil.json2Object(manifest.get(), ManifestContent.class);
} catch (Exception exception) {
+ log.debug("",exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.VALIDATE_MANIFEST_CONTENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_MANIFEST);