From 1e39e2bf48a7122aec00792cf43672a46ae9fa65 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 28 Sep 2020 14:37:44 -0400 Subject: New sonars in policy-common Addressed the following sonars: - too many assertions in a test case - use parameterized test method Disabled production sonars for util-test, as the entire module is only used for testing other modules. Issue-ID: POLICY-2650-sonar Change-Id: If49775a6c95855dcd9601ee0d833bb00741b1550 Signed-off-by: Jim Hahn --- .../utils/properties/BeanConfiguratorTest.java | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'utils') 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 07e0795f..5fb92f8e 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - Common Modules * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,6 +80,10 @@ public class BeanConfiguratorTest { @Test public void testConfigureFromProperties() throws PropertyException { + testStringValueNoDefault(); + } + + private void testStringValueNoDefault() throws PropertyException { props.setProperty(THE_VALUE, STRING_VALUE); PlainStringConfig cfg = new PlainStringConfig(); @@ -177,11 +181,7 @@ public class BeanConfiguratorTest { @Test public void testSetValueObjectFieldProperties_FieldSet() throws PropertyException { - props.setProperty(THE_VALUE, STRING_VALUE); - PlainStringConfig cfg = new PlainStringConfig(); - beancfg.configureFromProperties(cfg, props); - - assertEquals(STRING_VALUE, cfg.value); + testStringValueNoDefault(); } @Test @@ -500,11 +500,7 @@ public class BeanConfiguratorTest { @Test public void testGetStringValue() throws PropertyException { - props.setProperty(THE_VALUE, STRING_VALUE); - PlainStringConfig cfg = new PlainStringConfig(); - beancfg.configureFromProperties(cfg, props); - - assertEquals(STRING_VALUE, cfg.value); + testStringValueNoDefault(); } @Test @@ -721,12 +717,7 @@ public class BeanConfiguratorTest { @Test public void testGetPropValue_Prop_NoDefault() throws PropertyException { - props.setProperty(THE_VALUE, STRING_VALUE); - - PlainStringConfig cfg = new PlainStringConfig(); - beancfg.configureFromProperties(cfg, props); - - assertEquals(STRING_VALUE, cfg.value); + testStringValueNoDefault(); } @Test -- cgit 1.2.3-korg