diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2025-01-10 11:50:41 +0000 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2025-01-10 11:51:51 +0000 |
commit | b60fb4d0e5ad3603f967029a2682484cbdd81cec (patch) | |
tree | 5918b072b3219512bd8d60c777e7891bddaabbef /models-dao/src/test/java/org/onap | |
parent | 7cfbbcb1f16ab8b358c06a1f77fc94a203a53212 (diff) |
- fixing sonar issues on code to generate new models-* artifacts
with parent new dependencies.
Issue-ID: POLICY-5240
Change-Id: I41e01ededbc20c9b389be1167691aeb4e03cd0fb
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-dao/src/test/java/org/onap')
-rw-r--r-- | models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java | 12 | ||||
-rw-r--r-- | models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java | 51 |
2 files changed, 24 insertions, 39 deletions
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java b/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java index cae8cff0f..6458794de 100644 --- a/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java +++ b/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019, 2023 Nordix Foundation. + * Copyright (C) 2019, 2023, 2025 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -73,14 +73,6 @@ public class DummyConceptEntity extends PfConcept { this.description = source.description; } - public DummyConceptEntity(final Double doubleValue) { - this.key = new PfConceptKey(); - } - - public DummyConceptEntity(final PfConceptKey key, final Double doubleValue) { - this.key = key; - } - /** * Constructor. * @@ -114,7 +106,7 @@ public class DummyConceptEntity extends PfConcept { } @Override - public int compareTo(final PfConcept otherObj) { + public int compareTo(final @NonNull PfConcept otherObj) { Assertions.argumentNotNull(otherObj, "comparison object may not be null"); if (this == otherObj) { diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java index fb2155cfd..35080d81c 100644 --- a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java +++ b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021, 2023-2024 Nordix Foundation. + * Copyright (C) 2019-2021, 2023-2025 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ @@ -112,17 +112,7 @@ class EntityTest { @Test void testEntityTestAllOpsJpa() throws PfModelException { - final DaoParameters daoParameters = new DaoParameters(); - daoParameters.setPluginClass(DefaultPfDao.class.getName()); - daoParameters.setPersistenceUnit("DaoTest"); - - Properties jdbcProperties = new Properties(); - jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver"); - jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:EntityTest"); - jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "sa"); - jdbcProperties.setProperty("jakarta.persistence.jdbc.password", ""); - - daoParameters.setJdbcProperties(jdbcProperties); + final DaoParameters daoParameters = getDaoParameters(); pfDao = new PfDaoFactory().createPfDao(daoParameters); pfDao.init(daoParameters); @@ -133,24 +123,14 @@ class EntityTest { testVersionOps(); - testgetFilteredOps(); + testGetFilteredOps(); testgetFilteredOps3(); } @Test void testEntityTestBadVals() throws PfModelException { - final DaoParameters daoParameters = new DaoParameters(); - daoParameters.setPluginClass(DefaultPfDao.class.getName()); - daoParameters.setPersistenceUnit("DaoTest"); - - Properties jdbcProperties = new Properties(); - jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver"); - jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:EntityTest"); - jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "sa"); - jdbcProperties.setProperty("jakarta.persistence.jdbc.password", ""); - - daoParameters.setJdbcProperties(jdbcProperties); + final DaoParameters daoParameters = getDaoParameters(); pfDao = new PfDaoFactory().createPfDao(daoParameters); pfDao.init(daoParameters); @@ -192,6 +172,21 @@ class EntityTest { assertThatCode(() -> pfDao.size(null)).doesNotThrowAnyException(); } + private static DaoParameters getDaoParameters() { + final DaoParameters daoParameters = new DaoParameters(); + daoParameters.setPluginClass(DefaultPfDao.class.getName()); + daoParameters.setPersistenceUnit("DaoTest"); + + Properties jdbcProperties = new Properties(); + jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:EntityTest"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "sa"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.password", ""); + + daoParameters.setJdbcProperties(jdbcProperties); + return daoParameters; + } + private void testAllOps() { final PfConceptKey aKey0 = new PfConceptKey("A-KEY0", VERSION001); final PfConceptKey aKey1 = new PfConceptKey("A-KEY1", VERSION001); @@ -371,11 +366,9 @@ class EntityTest { tkeyInfoSetIn.add(tkeyInfo2); pfDao.createCollection(tkeyInfoSetIn); - tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class)); assertEquals(keyInfoSetIn, keyInfoSetOut); pfDao.delete(DummyTimestampEntity.class, atKey2); - tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class)); assertEquals(3, keyInfoSetOut.size()); assertEquals(1, pfDao.size(DummyTimestampEntity.class)); @@ -388,7 +381,7 @@ class EntityTest { final PfConceptKey owner1Key = new PfConceptKey("Owner1", VERSION001); final PfConceptKey owner2Key = new PfConceptKey("Owner2", VERSION001); final PfReferenceTimestampKey arKey0 = new PfReferenceTimestampKey(owner0Key, "AT-KEY0", TIMESTAMP0); - final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1);; + final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1); final PfReferenceTimestampKey arKey2 = new PfReferenceTimestampKey(owner2Key, "AT-KEY2", TIMESTAMP2); final DummyReferenceTimestampEntity rkeyInfo0 = new DummyReferenceTimestampEntity(arKey0); final DummyReferenceTimestampEntity rkeyInfo1 = new DummyReferenceTimestampEntity(arKey1); @@ -466,7 +459,7 @@ class EntityTest { assertEquals(0, pfDao.getAllVersions(DummyConceptEntity.class, null).size()); } - private void testgetFilteredOps() { + private void testGetFilteredOps() { final PfConceptKey aKey0 = new PfConceptKey("AAA0", VERSION001); final PfConceptKey aKey1 = new PfConceptKey("AAA0", VERSION002); final PfConceptKey aKey2 = new PfConceptKey("AAA0", VERSION003); @@ -540,7 +533,7 @@ class EntityTest { final PfConceptKey owner1Key = new PfConceptKey("Owner1", VERSION001); final PfConceptKey owner2Key = new PfConceptKey("Owner2", VERSION001); final PfReferenceTimestampKey arKey0 = new PfReferenceTimestampKey(owner0Key, "AT-KEY0", TIMESTAMP0); - final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1);; + final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1); final PfReferenceTimestampKey arKey2 = new PfReferenceTimestampKey(owner2Key, "AT-KEY2", TIMESTAMP2); final DummyReferenceTimestampEntity rkeyInfo0 = new DummyReferenceTimestampEntity(arKey0); final DummyReferenceTimestampEntity rkeyInfo1 = new DummyReferenceTimestampEntity(arKey1); |