From 2a72226cf71344b12cb53e67782855dfba9e9d01 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 30 Sep 2020 17:31:34 -0400 Subject: 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 --- .../utils/properties/BeanConfiguratorTest.java | 56 +++++++++------------- 1 file 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. */ -- cgit 1.2.3-korg