summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-09-30 17:31:34 -0400
committerJim Hahn <jrh3@att.com>2020-09-30 17:33:25 -0400
commit2a72226cf71344b12cb53e67782855dfba9e9d01 (patch)
tree7cdad66f6119ef331aa9efa9bf49273231a72122 /utils
parentd90d84f9e98de9772949a691dc1c5f2e26967f5f (diff)
Fix more sonars in policy/common
Addressed the following sonar issues: - extract common test methods Issue-ID: POLICY-2650 Change-Id: I0b27c83d7bbe3d5fe83859b189c37507aabe7489 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/properties/BeanConfiguratorTest.java56
1 files changed, 23 insertions, 33 deletions
diff --git a/utils/src/test/java/org/onap/policy/common/utils/properties/BeanConfiguratorTest.java b/utils/src/test/java/org/onap/policy/common/utils/properties/BeanConfiguratorTest.java
index 5fb92f8e..7da4eccd 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/properties/BeanConfiguratorTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/properties/BeanConfiguratorTest.java
@@ -951,18 +951,8 @@ public class BeanConfiguratorTest {
@Test(expected = PropertyInvalidException.class)
public void testCheckDefaultValue_Empty_EmptyOk_Invalid() throws PropertyException {
- class Config {
-
- @Property(name = THE_VALUE, defaultValue = "", accept = "empty")
- private long value;
-
- @SuppressWarnings("unused")
- public void setValue(long value) {
- this.value = value;
- }
- }
- beancfg.configureFromProperties(new Config(), props);
+ beancfg.configureFromProperties(new PrimLongDefaultBlankAcceptEmptyConfig(), props);
}
@Test
@@ -996,18 +986,8 @@ public class BeanConfiguratorTest {
@Test(expected = PropertyMissingException.class)
public void testIsEmptyOkPropertyString_False() throws PropertyException {
- class Config {
- @Property(name = THE_VALUE, defaultValue = "", accept = "")
- private long value;
-
- @SuppressWarnings("unused")
- public void setValue(long value) {
- this.value = value;
- }
- }
-
- beancfg.configureFromProperties(new Config(), props);
+ beancfg.configureFromProperties(new PrimLongDefaultBlankAcceptBlankConfig(), props);
}
@Test
@@ -1031,18 +1011,8 @@ public class BeanConfiguratorTest {
@Test(expected = PropertyMissingException.class)
public void testIsEmptyOkProperty_False() throws PropertyException {
- class Config {
-
- @Property(name = THE_VALUE, defaultValue = "", accept = "")
- private long value;
- @SuppressWarnings("unused")
- public void setValue(long value) {
- this.value = value;
- }
- }
-
- beancfg.configureFromProperties(new Config(), props);
+ beancfg.configureFromProperties(new PrimLongDefaultBlankAcceptBlankConfig(), props);
}
@Test
@@ -1411,6 +1381,26 @@ public class BeanConfiguratorTest {
}
}
+ class PrimLongDefaultBlankAcceptEmptyConfig {
+
+ @Property(name = THE_VALUE, defaultValue = "", accept = "empty")
+ private long value;
+
+ public void setValue(long value) {
+ this.value = value;
+ }
+ }
+
+ class PrimLongDefaultBlankAcceptBlankConfig {
+
+ @Property(name = THE_VALUE, defaultValue = "", accept = "")
+ private long value;
+
+ public void setValue(long value) {
+ this.value = value;
+ }
+ }
+
/**
* This is just used as a mix-in to ensure that the configuration ignores interfaces.
*/