Add hashCode() methods to two classes for Sonar 73/3373/1
authorLott, Christopher (cl778h) <cl778h@att.com>
Wed, 22 Apr 2020 00:49:29 +0000 (20:49 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Wed, 22 Apr 2020 00:51:31 +0000 (20:51 -0400)
Trying to lift the Dashboard score out of the basement.

Change-Id: I2f8523079fcdf0ec614908063f4417c0b35352e6
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/AppStats.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/StatsDetailsTransport.java
dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/model/ModelTest.java

index 1bf6b97..8a12bf8 100644 (file)
@@ -68,4 +68,13 @@ public class AppStats implements IDashboardResponse {
                return Objects.equals(instanceKey, other.instanceKey) && Objects.equals(statsDetails, other.statsDetails);
        }
 
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = super.hashCode();
+               result = prime * result + ((instanceKey == null) ? 0 : instanceKey.hashCode());
+               result = prime * result + ((statsDetails == null) ? 0 : statsDetails.hashCode());
+               return result;
+       }
+
 }
index 847fdcb..b3e1c69 100644 (file)
@@ -75,4 +75,15 @@ public class StatsDetailsTransport implements IDashboardResponse {
                StatsDetailsTransport other = (StatsDetailsTransport) obj;
                return appId == other.appId;
        }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = super.hashCode();
+               result = prime * result + appId;
+               result = prime * result + ((appName == null) ? 0 : appName.hashCode());
+               result = prime * result + ((metricUrl == null) ? 0 : metricUrl.hashCode());
+               return result;
+       }
+
 }
index 88bcf99..78458d0 100644 (file)
@@ -55,6 +55,7 @@ public class ModelTest extends AbstractModelTest {
                m.setInstanceKey(s1);
                m.setStatsDetails(n);
                checkAppStats(m);
+               Assert.assertNotEquals(1, m.hashCode());
                logger.info(m.toString());
        }