Merge "fix critical sonar bugs"
authorSteve Smokowski <ss835w@att.com>
Mon, 18 Feb 2019 13:28:05 +0000 (13:28 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 18 Feb 2019 13:28:06 +0000 (13:28 +0000)
adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java

index 65c7d09..59884f2 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Modifications Copyright (C) 2018 IBM.
+ * 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.
@@ -90,6 +91,7 @@ public class SDNCRestClient{
                        Thread.sleep(5000);
                } catch (InterruptedException e) {
                        e.printStackTrace();
+                       Thread.currentThread().interrupt();
                }
 
                String action = bpelRequest.getRequestHeader().getSvcAction();
index 076a9f3..01fa3db 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 - 2018 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
@@ -30,6 +32,7 @@ import org.junit.Test;
 import org.onap.so.adapters.sdnc.BaseTest;
 import org.springframework.beans.factory.annotation.Autowired;
 import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.Assert.assertTrue;
 
 
 public class SDNCRestClientTest extends BaseTest {
@@ -51,4 +54,11 @@ public class SDNCRestClientTest extends BaseTest {
         SDNCResponse response = sdncClient.getSdncResp("", rt);
         assertNotNull(response);
     }
+
+    @Test
+    public void executeRequestInterrupted() {
+        Thread.currentThread().interrupt();
+        sdncClient.executeRequest(null);
+        assertTrue(Thread.interrupted());
+    }
 }
index cc1ce00..2f71358 100644 (file)
@@ -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 "{}";
                }
        }
index 5433681..88a83db 100644 (file)
@@ -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"));