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>
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 5fb92f8..7da4ecc 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 @@
@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 @@
@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 @@
@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 @@
}
}
+ 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.
*/