DefaultDeviceDescription and DefaultLinkDescriptionTest classes toString() method have been updated.
Annotation information of these classes is added to return value of toString() method. Unit tests have been updated. Change-Id: I1d618eeb414b1ccad3588b36dad1ec0be0521c6a
Showing
4 changed files
with
15 additions
and
4 deletions
| ... | @@ -130,6 +130,7 @@ public class DefaultDeviceDescription extends AbstractDescription | ... | @@ -130,6 +130,7 @@ public class DefaultDeviceDescription extends AbstractDescription |
| 130 | .add("uri", uri).add("type", type).add("mfr", manufacturer) | 130 | .add("uri", uri).add("type", type).add("mfr", manufacturer) |
| 131 | .add("hw", hwVersion).add("sw", swVersion) | 131 | .add("hw", hwVersion).add("sw", swVersion) |
| 132 | .add("serial", serialNumber) | 132 | .add("serial", serialNumber) |
| 133 | + .add("annotations", annotations()) | ||
| 133 | .toString(); | 134 | .toString(); |
| 134 | } | 135 | } |
| 135 | 136 | ... | ... |
| ... | @@ -68,7 +68,9 @@ public class DefaultLinkDescription extends AbstractDescription | ... | @@ -68,7 +68,9 @@ public class DefaultLinkDescription extends AbstractDescription |
| 68 | return MoreObjects.toStringHelper(this) | 68 | return MoreObjects.toStringHelper(this) |
| 69 | .add("src", src()) | 69 | .add("src", src()) |
| 70 | .add("dst", dst()) | 70 | .add("dst", dst()) |
| 71 | - .add("type", type()).toString(); | 71 | + .add("type", type()) |
| 72 | + .add("annotations", annotations()) | ||
| 73 | + .toString(); | ||
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | @Override | 76 | @Override | ... | ... |
| ... | @@ -17,6 +17,7 @@ package org.onosproject.net.device; | ... | @@ -17,6 +17,7 @@ package org.onosproject.net.device; |
| 17 | 17 | ||
| 18 | import org.junit.Test; | 18 | import org.junit.Test; |
| 19 | import org.onlab.packet.ChassisId; | 19 | import org.onlab.packet.ChassisId; |
| 20 | +import org.onosproject.net.DefaultAnnotations; | ||
| 20 | 21 | ||
| 21 | import java.net.URI; | 22 | import java.net.URI; |
| 22 | 23 | ||
| ... | @@ -35,12 +36,13 @@ public class DefaultDeviceDescriptionTest { | ... | @@ -35,12 +36,13 @@ public class DefaultDeviceDescriptionTest { |
| 35 | private static final String SW = "3.9.1"; | 36 | private static final String SW = "3.9.1"; |
| 36 | private static final String SN = "43311-12345"; | 37 | private static final String SN = "43311-12345"; |
| 37 | private static final ChassisId CID = new ChassisId(); | 38 | private static final ChassisId CID = new ChassisId(); |
| 38 | - | 39 | + private static final DefaultAnnotations DA = |
| 40 | + DefaultAnnotations.builder().set("Key", "Value").build(); | ||
| 39 | 41 | ||
| 40 | @Test | 42 | @Test |
| 41 | public void basics() { | 43 | public void basics() { |
| 42 | DeviceDescription device = | 44 | DeviceDescription device = |
| 43 | - new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID); | 45 | + new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID, DA); |
| 44 | assertEquals("incorrect uri", DURI, device.deviceUri()); | 46 | assertEquals("incorrect uri", DURI, device.deviceUri()); |
| 45 | assertEquals("incorrect type", SWITCH, device.type()); | 47 | assertEquals("incorrect type", SWITCH, device.type()); |
| 46 | assertEquals("incorrect manufacturer", MFR, device.manufacturer()); | 48 | assertEquals("incorrect manufacturer", MFR, device.manufacturer()); |
| ... | @@ -49,6 +51,7 @@ public class DefaultDeviceDescriptionTest { | ... | @@ -49,6 +51,7 @@ public class DefaultDeviceDescriptionTest { |
| 49 | assertEquals("incorrect serial", SN, device.serialNumber()); | 51 | assertEquals("incorrect serial", SN, device.serialNumber()); |
| 50 | assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); | 52 | assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); |
| 51 | assertTrue("Incorrect chassis", device.chassisId().value() == 0); | 53 | assertTrue("Incorrect chassis", device.chassisId().value() == 0); |
| 54 | + assertTrue("incorrect annotatios", device.toString().contains("Key=Value")); | ||
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | } | 57 | } | ... | ... |
| ... | @@ -16,10 +16,12 @@ | ... | @@ -16,10 +16,12 @@ |
| 16 | package org.onosproject.net.link; | 16 | package org.onosproject.net.link; |
| 17 | 17 | ||
| 18 | import org.junit.Test; | 18 | import org.junit.Test; |
| 19 | +import org.onosproject.net.DefaultAnnotations; | ||
| 19 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.PortNumber; | 21 | import org.onosproject.net.PortNumber; |
| 21 | 22 | ||
| 22 | import static org.junit.Assert.assertEquals; | 23 | import static org.junit.Assert.assertEquals; |
| 24 | +import static org.junit.Assert.assertTrue; | ||
| 23 | import static org.onosproject.net.DefaultLinkTest.cp; | 25 | import static org.onosproject.net.DefaultLinkTest.cp; |
| 24 | import static org.onosproject.net.DeviceId.deviceId; | 26 | import static org.onosproject.net.DeviceId.deviceId; |
| 25 | import static org.onosproject.net.Link.Type.DIRECT; | 27 | import static org.onosproject.net.Link.Type.DIRECT; |
| ... | @@ -33,13 +35,16 @@ public class DefaultLinkDescriptionTest { | ... | @@ -33,13 +35,16 @@ public class DefaultLinkDescriptionTest { |
| 33 | private static final DeviceId DID1 = deviceId("of:foo"); | 35 | private static final DeviceId DID1 = deviceId("of:foo"); |
| 34 | private static final DeviceId DID2 = deviceId("of:bar"); | 36 | private static final DeviceId DID2 = deviceId("of:bar"); |
| 35 | private static final PortNumber P1 = portNumber(1); | 37 | private static final PortNumber P1 = portNumber(1); |
| 38 | + private static final DefaultAnnotations DA = | ||
| 39 | + DefaultAnnotations.builder().set("Key", "Value").build(); | ||
| 36 | 40 | ||
| 37 | @Test | 41 | @Test |
| 38 | public void basics() { | 42 | public void basics() { |
| 39 | - LinkDescription desc = new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P1), DIRECT); | 43 | + LinkDescription desc = new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P1), DIRECT, DA); |
| 40 | assertEquals("incorrect src", cp(DID1, P1), desc.src()); | 44 | assertEquals("incorrect src", cp(DID1, P1), desc.src()); |
| 41 | assertEquals("incorrect dst", cp(DID2, P1), desc.dst()); | 45 | assertEquals("incorrect dst", cp(DID2, P1), desc.dst()); |
| 42 | assertEquals("incorrect type", DIRECT, desc.type()); | 46 | assertEquals("incorrect type", DIRECT, desc.type()); |
| 47 | + assertTrue("incorrect annotatios", desc.toString().contains("Key=Value")); | ||
| 43 | } | 48 | } |
| 44 | 49 | ||
| 45 | } | 50 | } | ... | ... |
-
Please register or login to post a comment