Bug 6641: Fix ip_address in allowed_address_pairs info 16/45216/2
authorSridhar Gaddam <sgaddam@redhat.com>
Tue, 6 Sep 2016 10:46:02 +0000 (16:16 +0530)
committerSridhar Gaddam <sgaddam@redhat.com>
Fri, 9 Sep 2016 11:42:05 +0000 (17:12 +0530)
Change-Id: Id612243cbdc6ab8db8d66ce46ca2973a0effc0ee
Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronPortTests.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronPortInterface.java

index d02bc1f823959a77888878bc15cc5d4d8bfd3f86..b04917e24ac2122074e10221e66f774eba0f13b3 100644 (file)
@@ -8,6 +8,10 @@
 
 package org.opendaylight.neutron.e2etest;
 
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import org.junit.Assert;
+
 public class NeutronPortTests {
     String base;
 
@@ -92,7 +96,8 @@ public class NeutronPortTests {
         String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
         String content = " { \"port\": { " + " \"status\": \"DOWN\", "
                 + " \"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", "
-                + " \"allowed_address_pairs\": [], " + " \"extra_dhcp_opts\": [], "
+                + " \"allowed_address_pairs\": [ { " + " \"mac_address\": \"fa:16:3e:11:11:5e\", "
+                + " \"ip_address\": \"192.168.1.200/32\" } ], " + " \"extra_dhcp_opts\": [], "
                 + " \"device_owner\": \"compute:nova\", " + " \"binding:profile\": {}, " + " \"fixed_ips\": [ { "
                 + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\"," + " \"ip_address\": \"10.0.0.7\" } ], "
                 + " \"id\": \"43c831e0-19ce-4a76-9a49-57b57e69428b\", " + " \"security_groups\": [], "
@@ -117,6 +122,18 @@ public class NeutronPortTests {
         ITNeutronE2E.test_fetch(url, true, "Port Element Get With Query Failed");
     }
 
+    public void port_element_get_with_query_content_validation_test() {
+        String element = "allowed_address_pairs";
+        String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b"
+                + "?fields=" + element;
+        String expectedContent = "[{\"mac_address\":\"fa:16:3e:11:11:5e\",\"ip_address\":\"192.168.1.200/32\"}]";
+        String context = "Port details do not match.";
+        JsonObject jsonObjectOutput = ITNeutronE2E.test_fetch_gson(url, context);
+        jsonObjectOutput = jsonObjectOutput.getAsJsonObject("port");
+        JsonElement jsonElementValue = jsonObjectOutput.get(element);
+        Assert.assertEquals(context, expectedContent, String.valueOf(jsonElementValue));
+    }
+
     public void port_delete_test() {
         String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
         ITNeutronE2E.test_delete(url, "Port Element Delete Failed");
@@ -135,6 +152,7 @@ public class NeutronPortTests {
         port_tester.bulk_port_create_test();
         port_tester.port_update_test();
         port_tester.port_element_get_test();
+        port_tester.port_element_get_with_query_content_validation_test();
         port_tester.port_element_get_with_query_test();
         port_tester.port_collection_get_test();
         port_tester.port_delete_test();
index d4d070ad6ac5eb1948582ad9f450faa5f13a3ead..177c5d22d92ef7fe3cb01f944785807505b0175e 100644 (file)
@@ -115,7 +115,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             final List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
             for (final AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
                 final NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
-                pair.setIpAddress(mdPair.getIpAddress().getValue().toString());
+                pair.setIpAddress(String.valueOf(mdPair.getIpAddress().getValue()));
                 pair.setMacAddress(mdPair.getMacAddress().getValue());
                 pairs.add(pair);
             }