summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/so
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-interactions/model-impl/so
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-interactions/model-impl/so')
-rw-r--r--models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java78
-rw-r--r--models-interactions/model-impl/so/src/test/resources/logback-test.xml38
2 files changed, 41 insertions, 75 deletions
diff --git a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java
index 3fa3332b3..9c3a4ec33 100644
--- a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java
+++ b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modifications 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.
@@ -25,11 +26,13 @@ import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class SoRequestDetails implements Serializable {
private static final long serialVersionUID = -3283942659786236032L;
@@ -60,81 +63,6 @@ public class SoRequestDetails implements Serializable {
}
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SoRequestDetails other = (SoRequestDetails) obj;
- if (cloudConfiguration == null) {
- if (other.cloudConfiguration != null) {
- return false;
- }
- } else if (!cloudConfiguration.equals(other.cloudConfiguration)) {
- return false;
- }
- if (configurationParameters == null) {
- if (other.configurationParameters != null) {
- return false;
- }
- } else if (!configurationParameters.equals(other.configurationParameters)) {
- return false;
- }
- if (modelInfo == null) {
- if (other.modelInfo != null) {
- return false;
- }
- } else if (!modelInfo.equals(other.modelInfo)) {
- return false;
- }
- if (relatedInstanceList == null) {
- if (other.relatedInstanceList != null) {
- return false;
- }
- } else if (!relatedInstanceList.equals(other.relatedInstanceList)) {
- return false;
- }
- if (requestInfo == null) {
- if (other.requestInfo != null) {
- return false;
- }
- } else if (!requestInfo.equals(other.requestInfo)) {
- return false;
- }
- if (requestParameters == null) {
- if (other.requestParameters != null) {
- return false;
- }
- } else if (!requestParameters.equals(other.requestParameters)) {
- return false;
- }
- if (subscriberInfo == null) {
- return other.subscriberInfo == null;
- } else {
- return subscriberInfo.equals(other.subscriberInfo);
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode());
- result = prime * result + ((configurationParameters == null) ? 0 : configurationParameters.hashCode());
- result = prime * result + ((modelInfo == null) ? 0 : modelInfo.hashCode());
- result = prime * result + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode());
- result = prime * result + ((requestInfo == null) ? 0 : requestInfo.hashCode());
- result = prime * result + ((requestParameters == null) ? 0 : requestParameters.hashCode());
- result = prime * result + ((subscriberInfo == null) ? 0 : subscriberInfo.hashCode());
- return result;
- }
-
- @Override
public String toString() {
return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration
+ ", requestInfo=" + requestInfo + ", subscriberInfo=" + subscriberInfo
diff --git a/models-interactions/model-impl/so/src/test/resources/logback-test.xml b/models-interactions/model-impl/so/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..855706304
--- /dev/null
+++ b/models-interactions/model-impl/so/src/test/resources/logback-test.xml
@@ -0,0 +1,38 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ 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.
+ You may obtain a copy of the License at
+
+ 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=========================================================
+-->
+
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+
+ <contextName>ModelImplSo</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/pf_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>