aboutsummaryrefslogtreecommitdiffstats
path: root/models-base/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-07 13:58:09 -0400
committerJim Hahn <jrh3@att.com>2020-04-07 17:15:07 -0400
commit9b3ff5f270572a6760ff07dda9577cdadb53b088 (patch)
treeeacd325199fbb72fddaba94a057178a19e9c3360 /models-base/src
parent3000fdca611c32b7001c553621660b8ea0d2eb49 (diff)
Address sonar issues in models
Addressed the following sonar issues: - use RE2 instead of java.util Pattern for "+" and "*" - don't use deprecated methods - for Date(long), sonar appeared not to parse the argument's type correctly. Modified the code slightly to make sonar happy - duplicate blocks of code - either log or throw - missing assert in junit - for SDNR & VFC, eliminated threads, as they are unnecessary - duplicate code block in different branches - useless assignments - redeclaring abstract methods - cyclomatic complexity - used lombok in some cases (e.g., EqualsAndHashCode) - assert argument order - actually deleted ControlLoopTargetType, because it is not needed and sonar complains regardless of which order is used - add private constructor to utility classes - use StandardCharsets instead of literals Also: - added logback-test.xml to SO to eliminate the voluminous output from the junit test Issue-ID: POLICY-2305 Change-Id: I586c331781bedbd54a115a71847d04d293689445 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-base/src')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java5
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java4
2 files changed, 7 insertions, 2 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index b94900430..97522c4d9 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -21,6 +21,7 @@
package org.onap.policy.models.base;
+import com.google.re2j.Pattern;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -73,6 +74,8 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
implements PfConceptGetter<C>, PfAuthorative<List<Map<String, A>>> {
private static final long serialVersionUID = -324211738823208318L;
+ private static final Pattern KEY_ID_PATTERN = Pattern.compile(PfKey.KEY_ID_REGEXP);
+
@EmbeddedId
private PfConceptKey key;
@@ -183,7 +186,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
for (Entry<String, A> incomingConceptEntry : incomingConceptMap.entrySet()) {
PfConceptKey conceptKey = new PfConceptKey();
- if (incomingConceptEntry.getKey().matches(PfKey.KEY_ID_REGEXP)) {
+ if (KEY_ID_PATTERN.matches(incomingConceptEntry.getKey())) {
conceptKey = new PfConceptKey(incomingConceptEntry.getKey());
} else {
conceptKey.setName(incomingConceptEntry.getKey());
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
index a2f11290d..5be9b5f58 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
@@ -3,6 +3,7 @@
* ONAP Policy Model
* ================================================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +63,8 @@ public class PfTimestampKey extends PfKeyImpl {
*/
public PfTimestampKey(@NonNull final PfTimestampKey copyConcept) {
super(copyConcept);
- this.timeStamp = new Date(copyConcept.getTimeStamp().getTime());
+ long millis = copyConcept.getTimeStamp().getTime();
+ this.timeStamp = new Date(millis);
}
/**