aboutsummaryrefslogtreecommitdiffstats
path: root/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-06-12 14:32:25 -0400
committerJim Hahn <jrh3@att.com>2019-06-12 17:36:59 -0400
commitea262e6da52fd4da0733f02998f87aebaf502ddb (patch)
treea7cded567521f0141f31d9f8c185eccdaf2a8979 /common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
parente671e9fa5d09ec696cb24aeefaf10ddbc7c705d7 (diff)
Apply simple sonar fixes
Note: A number of these were identified, by SonarLint, in the Test classes, which are not typically scanned by Sonar. Removed unnecessary imports. Removed unneeded "throws Xxx". Replaced lambda with method references. Replaced duplicate strings with constants. Replaced try-fail-catch with assert-j methods to eliminate sonar complaints about duplicate failure messages. Added missing @Override annotations. Use map.computeIfAbsent() where appropriate. Also fixed some minor checkstyle issues. Removed unneeded "volatile" declarations. Replaced some if-else constructs with "?:" construct, per sonar. Replaced Object.wait() with CountDownLatch.await(); according to sonar (and javadocs), Object.wait() can return due to "spurious wakeups". Fixed issue whereby CryptoUtilsTest wouldn't run in my Eclipse. Change-Id: Ib6b71ed65662cfd6209400dac57ed69279bf29ec Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java')
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
index 30e2c0da..12cd80cb 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
@@ -37,6 +37,7 @@ public class TestBeanValidationResult {
private static final String NEXT_INDENT = "yy ";
private static final String MID_INDENT = "xx yy ";
private static final String NAME = "my-name";
+ private static final String MY_LIST_INVALID = " 'my-list' INVALID, item has status INVALID\n ";
private static final String BEAN_INVALID_MSG = requote("'my-name' INVALID, item has status INVALID\n");
private String cleanMsg;
@@ -105,14 +106,14 @@ public class TestBeanValidationResult {
list = Arrays.asList(invalid, invalid);
assertFalse(bean.validateNotNullList(MY_LIST, list, item -> item));
assertFalse(bean.isValid());
- assertEquals(requote(BEAN_INVALID_MSG + " 'my-list' INVALID, item has status INVALID\n " + invalidMsg
+ assertEquals(requote(BEAN_INVALID_MSG + MY_LIST_INVALID + invalidMsg
+ " " + invalidMsg), bean.getResult());
}
@Test
public void testValidateNotNullList_NullList() {
List<ValidationResult> list = null;
- assertFalse(bean.validateNotNullList("my-list", list, item -> item));
+ assertFalse(bean.validateNotNullList(MY_LIST, list, item -> item));
assertFalse(bean.isValid());
assertEquals(requote(BEAN_INVALID_MSG + " item 'my-list' value 'null' INVALID, is null\n"), bean.getResult());
@@ -137,14 +138,14 @@ public class TestBeanValidationResult {
bean = new BeanValidationResult(NAME, OBJECT);
assertFalse(bean.validateList(MY_LIST, list, item -> item));
assertFalse(bean.isValid());
- assertEquals(requote(BEAN_INVALID_MSG + " 'my-list' INVALID, item has status INVALID\n "
+ assertEquals(requote(BEAN_INVALID_MSG + MY_LIST_INVALID
+ "item 'item' value 'null' INVALID, null\n"), bean.getResult());
list = Arrays.asList(invalid, invalid);
bean = new BeanValidationResult(NAME, OBJECT);
assertFalse(bean.validateList(MY_LIST, list, item -> item));
assertFalse(bean.isValid());
- assertEquals(requote(BEAN_INVALID_MSG + " 'my-list' INVALID, item has status INVALID\n " + invalidMsg
+ assertEquals(requote(BEAN_INVALID_MSG + MY_LIST_INVALID + invalidMsg
+ " " + invalidMsg), bean.getResult());
}