Fix: store router ID to name for entity identification

Change-Id: I4dd431e18031d7f9d5ead84e2f386cb9af7ecbe6
diff --git a/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodec.java b/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodec.java
index 0e80b0d..15fdbb3 100644
--- a/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodec.java
+++ b/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodec.java
@@ -54,7 +54,7 @@
 
         ObjectNode result = context.mapper().createObjectNode()
                 .put(ID, lb.id())
-                .put(NAME, lb.name())
+                .put(NAME, lb.id())
                 .put(VIP, lb.vip().toString())
                 .put(NETWORK_ID, lb.networkId());
 
@@ -90,7 +90,7 @@
         }
 
         String id = nullIsIllegal(json.get(ID).asText(), ID + MISSING_MESSAGE);
-        String name = nullIsIllegal(json.get(NAME).asText(), NAME + MISSING_MESSAGE);
+        String name = nullIsIllegal(json.get(ID).asText(), NAME + MISSING_MESSAGE);
         IpAddress vip = IpAddress.valueOf(nullIsIllegal(json.get(VIP).asText(),
                 VIP + MISSING_MESSAGE));
         String networkId = nullIsIllegal(json.get(NETWORK_ID).asText(),
diff --git a/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodec.java b/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodec.java
index 3bfb44d..d2f2f51 100644
--- a/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodec.java
+++ b/apps/kubevirt-networking/web/src/main/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodec.java
@@ -63,7 +63,7 @@
 
         ObjectNode result = context.mapper().createObjectNode()
                 .put(ID, router.id())
-                .put(NAME, router.name())
+                .put(NAME, router.id())
                 .put(ENABLE_SNAT, router.enableSnat())
                 .put(MAC_ADDRESS, router.mac().toString());
 
@@ -116,7 +116,7 @@
         String id = nullIsIllegal(json.get(ID).asText(),
                 ID + MISSING_MESSAGE);
 
-        String name = nullIsIllegal(json.get(NAME).asText(),
+        String name = nullIsIllegal(json.get(ID).asText(),
                 NAME + MISSING_MESSAGE);
 
         String vrouterMac = nullIsIllegal(json.get(MAC_ADDRESS).asText(),
diff --git a/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodecTest.java b/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodecTest.java
index d15a38d..008d1eb 100644
--- a/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodecTest.java
+++ b/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtLoadBalancerCodecTest.java
@@ -97,7 +97,7 @@
     public void testKubevirtLoadBalancerEncode() {
         KubevirtLoadBalancer lb = DefaultKubevirtLoadBalancer.builder()
                 .id("26fcc876-f39a-459f-801d-75dcd3654ab8")
-                .name("lb-1")
+                .name("26fcc876-f39a-459f-801d-75dcd3654ab8")
                 .networkId("net-1")
                 .vip(IpAddress.valueOf("10.10.10.10"))
                 .members(ImmutableSet.of(IpAddress.valueOf("10.10.10.11"),
@@ -118,7 +118,7 @@
         KubevirtLoadBalancer lb = getKubevirtLoadBalancer("KubevirtLoadBalancer.json");
 
         assertThat(lb.id(), is("26fcc876-f39a-459f-801d-75dcd3654ab8"));
-        assertThat(lb.name(), is("lb-1"));
+        assertThat(lb.name(), is("26fcc876-f39a-459f-801d-75dcd3654ab8"));
         assertThat(lb.description(), is("Example Load Balancer"));
         assertThat(lb.networkId(), is("net-1"));
         assertThat(lb.vip(), is(IpAddress.valueOf("10.10.10.10")));
diff --git a/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodecTest.java b/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodecTest.java
index 104833c..4012501 100644
--- a/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodecTest.java
+++ b/apps/kubevirt-networking/web/src/test/java/org/onosproject/kubevirtnetworking/codec/KubevirtRouterCodecTest.java
@@ -78,7 +78,7 @@
 
         KubevirtRouter router = DefaultKubevirtRouter.builder()
                 .id("26fcc876-f39a-459f-801d-75dcd3654ab8")
-                .name("router-1")
+                .name("26fcc876-f39a-459f-801d-75dcd3654ab8")
                 .enableSnat(true)
                 .mac(MacAddress.valueOf("11:22:33:44:55:66"))
                 .description("router-1")
@@ -97,7 +97,7 @@
         KubevirtRouter router = getKubevirtRouter("KubevirtRouter.json");
 
         assertEquals("26fcc876-f39a-459f-801d-75dcd3654ab8", router.id());
-        assertEquals("router-1", router.name());
+        assertEquals("26fcc876-f39a-459f-801d-75dcd3654ab8", router.name());
         assertEquals("Example Virtual Router", router.description());
         assertTrue(router.enableSnat());
         assertEquals("11:22:33:44:55:66", router.mac().toString());