aboutsummaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java7
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java8
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/TestEngineStats.java13
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java13
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java15
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java9
7 files changed, 51 insertions, 22 deletions
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
index 564e2d48c..3d008e992 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
@@ -274,11 +274,10 @@ public class AxContextAlbum extends AxConcept {
"scope is not defined"));
}
- try {
- Assertions.validateStringParameter(SCOPE_STRING, scope, SCOPE_REGEXP);
- } catch (final IllegalArgumentException e) {
+ String stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP);
+ if (stringCheckResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "scope invalid-" + e.getMessage()));
+ "scope invalid-" + stringCheckResult));
}
if (itemSchema.equals(AxArtifactKey.getNullKey())) {
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
index 5dad2e9e8..767b1d02e 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
@@ -234,11 +234,11 @@ public class AxContextSchema extends AxConcept {
"schema flavour is not defined"));
}
- try {
- Assertions.validateStringParameter(SCHEMA_FLAVOUR, schemaFlavour, SCHEMA_FLAVOUR_REGEXP);
- } catch (final IllegalArgumentException e) {
+ String flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour,
+ SCHEMA_FLAVOUR_REGEXP);
+ if (flavourValidationResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "schema flavour invalid-" + e.getMessage()));
+ "schema flavour invalid-" + flavourValidationResult));
}
if (schemaDefinition.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/TestEngineStats.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/TestEngineStats.java
index fb99e265b..8bd5756ab 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/TestEngineStats.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/TestEngineStats.java
@@ -38,6 +38,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestEngineStats {
+ private static final Object WAIT_LOCK = new Object();
@Test
public void testEngineStats() {
@@ -98,11 +99,15 @@ public class TestEngineStats {
stats.engineStart();
stats.setEventCount(4);
stats.executionEnter(new AxArtifactKey());
- try {
- Thread.sleep(10);
- } catch (final Exception e) {
- fail("test should not throw an exeption");
+
+ synchronized (WAIT_LOCK) {
+ try {
+ WAIT_LOCK.wait(10);
+ } catch (InterruptedException e) {
+ fail("test should not throw an exception");
+ }
}
+
stats.executionExit();
final double avExecutionTime = stats.getAverageExecutionTime();
assertTrue(avExecutionTime >= 2.0 && avExecutionTime < 10.0);
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
index 99642d1ae..ad86fb42c 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
@@ -271,11 +271,11 @@ public class AxLogic extends AxConcept {
"logic flavour is not defined"));
}
- try {
- Assertions.validateStringParameter(LOGIC_FLAVOUR_TOKEN, logicFlavour, LOGIC_FLAVOUR_REGEXP);
- } catch (final IllegalArgumentException e) {
+ String flavourValidationString = Assertions.getStringParameterValidationMessage(LOGIC_FLAVOUR_TOKEN,
+ logicFlavour, LOGIC_FLAVOUR_REGEXP);
+ if (flavourValidationString != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "logic flavour invalid-" + e.getMessage()));
+ "logic flavour invalid-" + flavourValidationString));
}
if (logic.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
index a03b49f13..3c43c6edd 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
@@ -49,6 +49,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
/**
* This class holds the definition of an Apex policy. A policy is made up of a tree of states, each represented by an
@@ -88,6 +90,9 @@ import org.onap.policy.apex.model.utilities.Assertions;
public class AxPolicy extends AxConcept {
private static final long serialVersionUID = -1775614096390365941L;
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(AxPolicy.class);
+
@EmbeddedId
@XmlElement(name = "policyKey", required = true)
private AxArtifactKey key;
@@ -364,7 +369,7 @@ public class AxPolicy extends AxConcept {
*/
private AxValidationResult validateStateTree(AxValidationResult result) {
try {
- // Cpnstructor validates policy state tree
+ // Constructor validates policy state tree
AxStateTree policyStateTree = getStateTree();
// Check for unused states
@@ -378,8 +383,10 @@ public class AxPolicy extends AxConcept {
+ " is not referenced in the policy execution tree"));
}
} catch (PolicyRuntimeException pre) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "state tree in policy is invalid"));
+ AxValidationMessage validationMessage = new AxValidationMessage(key, this.getClass(),
+ ValidationResult.WARNING, "state tree in policy is invalid");
+ LOGGER.trace(validationMessage.getMessage(), pre);
+ result.addValidationMessage(validationMessage);
}
return result;
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
index a3ecccebe..02a91a72c 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
@@ -20,6 +20,9 @@
package org.onap.policy.apex.model.utilities;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
/**
* The Class Assertions is a template class that is used as a shorthand for assertions in the source code.
*
@@ -27,6 +30,9 @@ package org.onap.policy.apex.model.utilities;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class Assertions {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(Assertions.class);
+
/**
* Private constructor used to prevent sub class instantiation.
*/
@@ -46,8 +52,13 @@ public final class Assertions {
try {
validateStringParameter(parameterName, parameterValue, pattern);
} catch (IllegalArgumentException e) {
- // This will cause a SONAR error but eliminates all SONAR messages in callers
- return e.getMessage();
+ String message = "parameter " + parameterName + " with value " + parameterValue
+ + " does not match regular expression " + pattern;
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace(message, e);
+ }
+
+ return message;
}
return null;
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
index ffebc405f..2e6e96d0b 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
@@ -24,6 +24,9 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
//CHECKSTYLE:OFF: checkstyle:IllegalImport
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
//CHECKSTYLE:ON: checkstyle:IllegalImport
@@ -38,6 +41,9 @@ import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
*/
@SuppressWarnings("restriction")
public class ClassBuilder {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ClassBuilder.class);
+
private final Class<?> clazz;
private final List<ClassBuilder> parameters = new ArrayList<>();
@@ -62,7 +68,8 @@ public class ClassBuilder {
} catch (ClassNotFoundException e) {
try {
return new ClassBuilder(Class.forName("java.lang." + className));
- } catch (Exception ignore) {
+ } catch (Exception classFindException) {
+ LOGGER.warn("class nout found", classFindException);
throw new IllegalArgumentException("Class '" + className
+ "' not found. Also looked for a class called 'java.lang." + className + "'", e);
}