summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/aai/validation/exception/ValidationServiceError.java68
-rw-r--r--src/main/java/org/onap/aai/validation/ruledriven/RuleDrivenValidator.java5
2 files changed, 39 insertions, 34 deletions
diff --git a/src/main/java/org/onap/aai/validation/exception/ValidationServiceError.java b/src/main/java/org/onap/aai/validation/exception/ValidationServiceError.java
index 45d79d4..421d866 100644
--- a/src/main/java/org/onap/aai/validation/exception/ValidationServiceError.java
+++ b/src/main/java/org/onap/aai/validation/exception/ValidationServiceError.java
@@ -1,37 +1,41 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
* 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
+ * 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.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END=====================================================
+ * ============LICENSE_END=========================================================
*/
+
package org.onap.aai.validation.exception;
import java.text.MessageFormat;
/**
- * Error text formatting
+ * Error text formatting.
*
*/
public enum ValidationServiceError {
- //@formatter:off
+ //@formatter:off
// Rule Configuration exceptions. Range 100..199
RULES_FILE_ERROR("VS-100", "Error reading rules configuration file(s) {0}"),
RULE_UNEXPECTED_TOKEN("VS-101", "Token {0} unexpected in rules configuration file."),
- RULES_NOT_DEFINED("VS-102", "Event type {0} has no rule definitions."),
-
+ RULES_NOT_DEFINED("VS-102", "Entity type {0} (Event type {1}) has no rule definitions."),
+
// Rule exceptions. Range 200..299
RULE_EXECUTION_ERROR("VS-201", "Error executing rule {0} with arguments {1}"),
@@ -78,26 +82,26 @@ public enum ValidationServiceError {
//@formatter:on
- private String id;
- private String message;
-
- private ValidationServiceError(String id, String message) {
- this.id = id;
- this.message = message;
- }
-
- public String getId() {
- return this.id;
- }
-
- /**
- * @param args
- * to be formatted
- * @return the formatted error message
- */
- public String getMessage(Object... args) {
- MessageFormat formatter = new MessageFormat("");
- formatter.applyPattern(this.message);
- return formatter.format(args);
- }
+ private String id;
+ private String message;
+
+ private ValidationServiceError(String id, String message) {
+ this.id = id;
+ this.message = message;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @param args
+ * to be formatted
+ * @return the formatted error message
+ */
+ public String getMessage(Object... args) {
+ MessageFormat formatter = new MessageFormat("");
+ formatter.applyPattern(this.message);
+ return formatter.format(args);
+ }
}
diff --git a/src/main/java/org/onap/aai/validation/ruledriven/RuleDrivenValidator.java b/src/main/java/org/onap/aai/validation/ruledriven/RuleDrivenValidator.java
index 5ca7025..1c6dff7 100644
--- a/src/main/java/org/onap/aai/validation/ruledriven/RuleDrivenValidator.java
+++ b/src/main/java/org/onap/aai/validation/ruledriven/RuleDrivenValidator.java
@@ -133,8 +133,9 @@ public class RuleDrivenValidator implements Validator {
Entity entity = getEventReader().getEntity(event);
Optional<String> eventType = eventReader.getEventType(event);
- List<Rule> rules = getRulesToApply(entity, eventType).orElseThrow(
- () -> new ValidationServiceException(ValidationServiceError.RULES_NOT_DEFINED, eventType.orElse(null)));
+ List<Rule> rules = getRulesToApply(entity, eventType)
+ .orElseThrow(() -> new ValidationServiceException(ValidationServiceError.RULES_NOT_DEFINED,
+ entity.getType(), eventType.orElse(null)));
ValidationResult validationResult = new ValidationResultBuilder(eventReader, event).build();
Violation.Builder builder = new Violation.Builder(entity);