summaryrefslogtreecommitdiffstats
path: root/integrity-audit/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-06-17 08:37:15 -0400
committerJim Hahn <jrh3@att.com>2020-06-17 11:45:16 -0400
commit611f63a4bb71d677cf2665b1794e91148ba42a51 (patch)
treec6f82e5ffcd10712e0279c40bf8e59ed49f2332e /integrity-audit/src
parent3bd6679bd7d8f67b4827a610c25ed9671b74d89c (diff)
Cleanup various sonar issues in policy-common
Addressed the following issues: - unused imports - unused method parameters - use assertEquals, assertSame instead of assertTrue - provide the parametrized type for this generic Also fixed some checkstyle issues: - removed blank lines between "import" groups Issue-ID: POLICY-2650 Change-Id: I004bb650ac10c49ccd0fc405f6959896fec39f9b Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-audit/src')
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java11
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java7
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java5
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java4
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java10
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java1
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java12
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java3
8 files changed, 18 insertions, 35 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
index 80177b30..28e8e387 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -48,7 +48,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*
*/
public class DbDao {
- private static final Logger logger = FlexLogger.getLogger(DbDao.class.getName());
+ private static final Logger logger = FlexLogger.getLogger();
private String resourceName;
private String persistenceUnit;
@@ -505,17 +505,16 @@ public class DbDao {
// if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
// found, create a new entry
- Query iaequery = em.createQuery(SELECT_STRING);
+ TypedQuery<IntegrityAuditEntity> iaequery = em.createQuery(SELECT_STRING, IntegrityAuditEntity.class);
iaequery.setParameter("rn", resourceName);
iaequery.setParameter("pu", persistenceUnit);
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
+ List<IntegrityAuditEntity> iaeList = iaequery.getResultList();
IntegrityAuditEntity iae;
if (!iaeList.isEmpty()) {
// ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
+ iae = iaeList.get(0);
} else {
// If it does not exist
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
index c1046828..a1d2116f 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 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.
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Date;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
index 99cf4b2a..ad154d33 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -30,12 +30,10 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.policy.common.ia.jpa.IaTestEntity;
import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
@@ -419,7 +417,6 @@ public class DbAuditCompareEntriesTest extends IntegrityAuditTestBase {
/*
* Tests that comparison algorithm works for each entity in the database
*/
- @Ignore
@Test
public void testCompareAllDbEntities() throws Exception {
logger.info("testCompareAllDbEntities: Entering");
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
index 220b0635..4728fe84 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -26,11 +26,9 @@ import static org.junit.Assert.assertFalse;
import java.util.List;
import java.util.Properties;
-
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
index ef21e831..79dfeb18 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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,26 +25,18 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-/*
- * All JUnits are designed to run in the local development environment
- * where they have write privileges and can execute time-sensitive
- * tasks.
- */
-
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-
import javax.persistence.PersistenceUnitUtil;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java
index fda7e4a2..5944443e 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.IOException;
-
import org.junit.AfterClass;
import org.junit.Test;
import org.onap.policy.common.utils.resources.TextFileUtils;
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
index c9ff6854..9550017e 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -21,10 +21,10 @@
package org.onap.policy.common.ia;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
-
import org.junit.Test;
public class IntegrityAuditTest {
@@ -41,7 +41,7 @@ public class IntegrityAuditTest {
StringBuilder badParams = new StringBuilder();
IntegrityAudit.parmsAreBad(null, SOMETHING, null, badParams);
- assertFalse("".equals(badParams.toString()));
+ assertNotEquals("", badParams.toString());
assertTrue(badParams.toString().contains(RESOURCE_NAME));
assertTrue(badParams.toString().contains(PROPERTIES));
@@ -51,14 +51,14 @@ public class IntegrityAuditTest {
props.put(IntegrityAuditProperties.DB_DRIVER, "test_db_driver");
IntegrityAudit.parmsAreBad(null, SOMETHING, props, badParams);
- assertFalse("".equals(badParams.toString()));
+ assertNotEquals("", badParams.toString());
assertTrue(badParams.toString().contains(RESOURCE_NAME));
assertFalse(badParams.toString().contains(PROPERTIES));
// Try with 0 null params
badParams = new StringBuilder();
IntegrityAudit.parmsAreBad("someting", SOMETHING, props, badParams);
- assertFalse("".equals(badParams.toString()));
+ assertNotEquals("", badParams.toString());
assertFalse(badParams.toString().contains(RESOURCE_NAME));
assertFalse(badParams.toString().contains(PROPERTIES));
@@ -66,7 +66,7 @@ public class IntegrityAuditTest {
props.put(IntegrityAuditProperties.NODE_TYPE, "bogus");
badParams = new StringBuilder();
IntegrityAudit.parmsAreBad("someting", SOMETHING, props, badParams);
- assertFalse("".equals(badParams.toString()));
+ assertNotEquals("", badParams.toString());
assertTrue(badParams.toString().contains("nodeType"));
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
index 4a4824c5..2ca83050 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -22,7 +22,6 @@ package org.onap.policy.common.ia.jpa;
import java.io.Serializable;
import java.util.Date;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;