Fix a bug in the JSON string representation of a MAC address.
The MAC address should be 48-bit value.
Change-Id: Ib3f745cae97229e8c58d404635249e22537a99e2
OLD: "00:00:00:00:00:00:ff:fe"
NEW: "00:00:00:00:ff:fe"
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/ShortestPathIntentSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/ShortestPathIntentSerializer.java
index f0fa00c..42f102f 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/ShortestPathIntentSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/ShortestPathIntentSerializer.java
@@ -2,6 +2,7 @@
import com.google.common.net.InetAddresses;
+import net.floodlightcontroller.util.MACAddress;
import net.onrc.onos.core.intent.ShortestPathIntent;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.SerializerProvider;
@@ -57,7 +58,7 @@
jsonGenerator.writeStringField("srcPortNumber",
Long.toString(intent.getSrcPortNumber()));
jsonGenerator.writeStringField("srcMac",
- HexString.toHexString(intent.getSrcMac()));
+ MACAddress.valueOf(intent.getSrcMac()).toString());
jsonGenerator.writeStringField("srcIp",
toIPAddressString(intent.getSrcIp()));
@@ -66,7 +67,7 @@
jsonGenerator.writeStringField("dstPortNumber",
Long.toString(intent.getDstPortNumber()));
jsonGenerator.writeStringField("dstMac",
- HexString.toHexString(intent.getDstMac()));
+ MACAddress.valueOf(intent.getDstMac()).toString());
jsonGenerator.writeStringField("dstIp",
toIPAddressString(intent.getDstIp()));
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighGet.java b/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighGet.java
index 97003aa..58e9bfa 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighGet.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighGet.java
@@ -185,7 +185,7 @@
assertThat(intent, hasKey("srcPortNumber"));
assertThat(intent.get("srcPortNumber"), is(equalTo("14")));
assertThat(intent, hasKey("srcMac"));
- assertThat(intent.get("srcMac"), is(equalTo("00:00:00:00:00:00:ff:fe")));
+ assertThat(intent.get("srcMac"), is(equalTo("00:00:00:00:ff:fe")));
assertThat(intent, hasKey("srcMac"));
assertThat(intent.get("srcIp"), is(equalTo(IP_ADDRESS_1)));
@@ -194,7 +194,7 @@
assertThat(intent, hasKey("dstPortNumber"));
assertThat(intent.get("dstPortNumber"), is(equalTo("41")));
assertThat(intent, hasKey("dstMac"));
- assertThat(intent.get("dstMac"), is(equalTo("00:00:00:00:00:00:ff:fe")));
+ assertThat(intent.get("dstMac"), is(equalTo("00:00:00:00:ff:fe")));
assertThat(intent, hasKey("dstMac"));
assertThat(intent.get("dstIp"), is(equalTo(IP_ADDRESS_2)));
}