Add node IP attribute in k8s node class with minor code refactoring

Change-Id: I4c1c86c95acfeb38569b91c1677e4ce8af90460f
diff --git a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeCodecTest.java b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeCodecTest.java
index 6b2689d..ae31130 100644
--- a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeCodecTest.java
+++ b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeCodecTest.java
@@ -86,6 +86,7 @@
                 .state(K8sNodeState.INIT)
                 .managementIp(IpAddress.valueOf("10.10.10.1"))
                 .dataIp(IpAddress.valueOf("20.20.20.2"))
+                .nodeIp(IpAddress.valueOf("30.30.30.3"))
                 .intgBridge(DeviceId.deviceId("kbr-int"))
                 .extIntf("eth1")
                 .extBridgeIp(IpAddress.valueOf("10.10.10.5"))
@@ -112,6 +113,7 @@
         assertEquals(100, node.segmentId());
         assertEquals("172.16.130.4", node.managementIp().toString());
         assertEquals("172.16.130.4", node.dataIp().toString());
+        assertEquals("172.16.130.5", node.nodeIp().toString());
         assertEquals("of:00000000000000a1", node.intgBridge().toString());
         assertEquals("eth1", node.extIntf());
         assertEquals("172.16.130.5", node.extBridgeIp().toString());
diff --git a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java
index 71c5ca9..d0d97a8 100644
--- a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java
+++ b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java
@@ -35,6 +35,7 @@
     private static final String SEGMENT_ID = "segmentId";
     private static final String MANAGEMENT_IP = "managementIp";
     private static final String DATA_IP = "dataIp";
+    private static final String NODE_IP = "nodeIp";
     private static final String INTEGRATION_BRIDGE = "integrationBridge";
     private static final String STATE = "state";
     private static final String EXTERNAL_INTF = "externalInterface";
@@ -91,6 +92,14 @@
             return false;
         }
 
+        // check node IP
+        String jsonNodeIp = jsonNode.get(NODE_IP).asText();
+        String nodeIp = node.nodeIp().toString();
+        if (!jsonNodeIp.equals(nodeIp)) {
+            description.appendText("node IP was " + jsonNodeIp);
+            return false;
+        }
+
         // check integration bridge
         JsonNode jsonIntgBridge = jsonNode.get(INTEGRATION_BRIDGE);
         if (jsonIntgBridge != null) {
diff --git a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/impl/K8sNodeManagerTest.java b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/impl/K8sNodeManagerTest.java
index 0bb0258..e336164 100644
--- a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/impl/K8sNodeManagerTest.java
+++ b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/impl/K8sNodeManagerTest.java
@@ -360,6 +360,7 @@
                 .tunBridge(tunBridge.id())
                 .managementIp(ipAddr)
                 .dataIp(ipAddr)
+                .nodeIp(ipAddr)
                 .state(state)
                 .build();
     }
diff --git a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/web/K8sNodeWebResourceTest.java b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/web/K8sNodeWebResourceTest.java
index 1005ab2..9908e99 100644
--- a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/web/K8sNodeWebResourceTest.java
+++ b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/web/K8sNodeWebResourceTest.java
@@ -97,6 +97,7 @@
                 .type(K8sNode.Type.MINION)
                 .dataIp(IpAddress.valueOf("10.134.34.222"))
                 .managementIp(IpAddress.valueOf("10.134.231.30"))
+                .nodeIp(IpAddress.valueOf("30.30.30.3"))
                 .intgBridge(DeviceId.deviceId("of:00000000000000a1"))
                 .extBridge(DeviceId.deviceId("of:00000000000000b1"))
                 .state(K8sNodeState.INIT)