diff options
author | Samuel Liard <samuel.liard@gmail.com> | 2021-10-05 18:11:08 +0200 |
---|---|---|
committer | Samuel Liard <samuel.liard@gmail.com> | 2021-10-05 18:32:57 +0200 |
commit | 41921e717d71352d3c623d137875d37b64460774 (patch) | |
tree | c92f7d530d3da47222c721a39b76d0a3a8e2284b /sparkybe-onap-service/src/test | |
parent | 28fd048dcd052449ac2f8da76ccb9255f33fa387 (diff) |
Fix sonar issues :
Remove all printStackTrace
Fix Security Hotspots
Issue-ID: AAI-3362
Signed-off-by: sliard <samuel.liard@gmail.com>
Change-Id: Ic4f7c854f4ec9a42b9cdee89f544abd12b873a72
Diffstat (limited to 'sparkybe-onap-service/src/test')
6 files changed, 21 insertions, 11 deletions
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/NetworkTransactionTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/NetworkTransactionTest.java index dd7983c..be023d8 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/NetworkTransactionTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/NetworkTransactionTest.java @@ -22,6 +22,7 @@ package org.onap.aai.sparky.dal; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -62,7 +63,6 @@ public class NetworkTransactionTest { networkTransaction.setOperationType(HttpMethod.PUT); assertNotNull(networkTransaction.getOperationType()); networkTransaction.setTaskAgeInMs(); - assertNotNull(networkTransaction.getTaskAgeInMs()); networkTransaction.setEntityType("searchedNodeClass"); assertNotNull(networkTransaction.getEntityType()); networkTransaction.setLink("/etc/aaiEntityNodeDescriptors.json"); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityTypeSummaryTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityTypeSummaryTest.java index 68c9e91..1c3b5f4 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityTypeSummaryTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityTypeSummaryTest.java @@ -21,6 +21,7 @@ package org.onap.aai.sparky.search; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.ArrayList; @@ -48,7 +49,7 @@ public class EntityTypeSummaryTest { public void updateValues() { entityTypeSummaryBucket.setTotalChartHits(8); - assertNotNull(entityTypeSummaryBucket.getTotalChartHits()); + assertEquals(8,entityTypeSummaryBucket.getTotalChartHits()); entityTypeSummaryBucket.setBuckets(bucketList); assertNotNull(entityTypeSummaryBucket.getBuckets()); entityTypeSummaryBucket.addBucket(bucket); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java index 42ea4a5..ecda59c 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java @@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import static org.junit.Assert.*; +import static org.junit.Assert.assertNull; public class EcompSsoTest { @@ -53,7 +54,7 @@ public class EcompSsoTest { Mockito.when(portalRestCentralServiceImpl.getUserRoles(Mockito.anyString())) .thenReturn(new ArrayList<EcompRole>()); - assertNotNull(ecompSso.validateUserAccess("ui_view")); + assertFalse(ecompSso.validateUserAccess("ui_view")); } @Test @@ -67,6 +68,7 @@ public class EcompSsoTest { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Mockito.when(request.getCookies()).thenReturn(cookies); Cookie result = EcompSso.getCookie(request, testCookieName + "1"); + assertNotNull(result); assertEquals(cookie1.getName(), result.getName()); assertEquals(cookie1.getValue(), result.getValue()); assertNull(EcompSso.getCookie(request, testCookieName + "3")); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/SyncControllerConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/SyncControllerConfigTest.java index d94e8c4..94529c7 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/SyncControllerConfigTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/SyncControllerConfigTest.java @@ -45,11 +45,6 @@ public class SyncControllerConfigTest { @Test public void updateValues() { - - - - - syncControllerConfig.setNumInternalSyncWorkers(3); assertEquals(3,syncControllerConfig.getNumInternalSyncWorkers()); syncControllerConfig.setNumSyncElasticWorkers(5); @@ -72,7 +67,7 @@ public class SyncControllerConfigTest { assertTrue(syncControllerConfig.isRunOnceSyncEnabled()); syncControllerConfig.setPeriodicSyncEnabled(true); assertTrue(syncControllerConfig.isPeriodicSyncEnabled()); - assertNotNull(syncControllerConfig.getSyncFrequencyInMs()); + assertEquals(259200000,syncControllerConfig.getSyncFrequencyInMs()); assertNotNull(syncControllerConfig.getTargetSyncTime()); assertNotNull(syncControllerConfig.getNextSyncTime()); syncControllerConfig.setTimeZoneOfSyncStartTimeStamp("UTC+00:00"); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/TestSyncController.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/TestSyncController.java index 9e1e9e8..ae40e06 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/TestSyncController.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/TestSyncController.java @@ -68,7 +68,7 @@ public class TestSyncController implements SyncController { Thread.sleep(10000L); } catch (InterruptedException e) { // TODO Auto-generated catch block - e.printStackTrace(); + Thread.currentThread().interrupt(); } System.out.println("Sync done with thread = " + Thread.currentThread().getName() diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java index 6263e28..e24d164 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java @@ -21,6 +21,7 @@ package org.onap.aai.sparky.util; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -58,7 +59,7 @@ public class NodeUtilsTest { assertNotNull(nodeUtils.buildDepthPadding(2)); - assertNotNull(nodeUtils.isNumeric("234")); + assertTrue(nodeUtils.isNumeric("234")); assertNull(nodeUtils.calculateEditAttributeUri(null)); assertNotNull(nodeUtils.generateUniqueShaDigest("unique-101")); assertNull(nodeUtils.getNodeFieldAsText(jsonNode,"")); @@ -77,4 +78,15 @@ public class NodeUtilsTest { } + + @Test + public void extractOxmVersionFromPath() { + assertEquals("8",NodeUtils.extractOxmVersionFromPath("test_oxm_v8.xml")); + assertEquals("9",NodeUtils.extractOxmVersionFromPath("test_oxm_v9.xml")); + assertEquals("11",NodeUtils.extractOxmVersionFromPath("test_oxm_v11.xml")); + assertEquals("11",NodeUtils.extractOxmVersionFromPath("test_oxm_v11.json")); + assertEquals("11",NodeUtils.extractOxmVersionFromPath("test_oxm_v11other.json")); + assertEquals("11",NodeUtils.extractOxmVersionFromPath("/path_v10/test_oxm_v11.xml")); + assertEquals("11",NodeUtils.extractOxmVersionFromPath("\\pathv10\\test_oxm_v11.xml")); + } } |