diff options
author | k.kazak <k.kazak@samsung.com> | 2019-02-14 09:20:50 +0100 |
---|---|---|
committer | k.kazak <k.kazak@samsung.com> | 2019-02-14 09:20:50 +0100 |
commit | db87a79ae00c35499a61fd3d41122021cb9a9e25 (patch) | |
tree | cf89f59cfc1447865faa7cfe80ee91c5d05ad796 /common/src/main/java/org/onap | |
parent | 1ffa4a397fb51acb09273e2b04b47281f7eb4840 (diff) |
fix critical sonar bugs
Restore interrupted state when InterruptedException is thrown in SDNCRestClient
Added test for this case
Replaced formatting anchor with text empty object in GraphInventoryResultWrapper
Escaped anchor is also considered as bug by sonar
Case is already covered in AAIResultWrapperTest
Marked comparison of the same object as false positive in EqualsAndHashCodeTester
Added clearer comment to this comparison
Change-Id: I24496c2323c33599db99a3d3b59fc4f6a008cf1f
Issue-ID: SO-1492
Signed-off-by: k.kazak <k.kazak@samsung.com>
Diffstat (limited to 'common/src/main/java/org/onap')
-rw-r--r-- | common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java | 4 | ||||
-rw-r--r-- | common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java index cc1ce0063b..2f71358f04 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -59,7 +61,7 @@ public class GraphInventoryResultWrapper implements Serializable { try { return mapper.writeValueAsString(aaiObject); } catch (JsonProcessingException e) { - logger.warn("could not parse object into json - defaulting to {}"); + logger.warn("could not parse object into json - defaulting to empty object"); return "{}"; } } diff --git a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java index 5433681b83..88a83db7e2 100644 --- a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java +++ b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -59,6 +61,10 @@ public class EqualsAndHashCodeTester implements Tester { this.onlyDeclaredMethods = true; return this; } + + // Marks sonar warnings about object being compared to itself as false positive + // https://sonar.onap.org/coding_rules#rule_key=squid%3AS1764 + @SuppressWarnings("squid:S1764") @Override public void run(PojoClass pojoClass) { Class<?> clazz = pojoClass.getClazz(); @@ -104,9 +110,9 @@ public class EqualsAndHashCodeTester implements Tester { Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals(classInstanceTwo)); - Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals( - classInstanceOne)); - + Affirm.affirmTrue("Expected true for comparison of the same references [" + classInstanceOne.getClass().getName() + "]", + classInstanceOne.equals(classInstanceOne)); + Affirm.affirmTrue("HashCode test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.hashCode() == classInstanceTwo.hashCode()); Affirm.affirmFalse("Expected false for comparison of two unlike objects", classInstanceOne.equals("test")); |