Pavel Likin

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
......@@ -130,6 +130,7 @@ public class DefaultDeviceDescription extends AbstractDescription
.add("uri", uri).add("type", type).add("mfr", manufacturer)
.add("hw", hwVersion).add("sw", swVersion)
.add("serial", serialNumber)
.add("annotations", annotations())
.toString();
}
......
......@@ -68,7 +68,9 @@ public class DefaultLinkDescription extends AbstractDescription
return MoreObjects.toStringHelper(this)
.add("src", src())
.add("dst", dst())
.add("type", type()).toString();
.add("type", type())
.add("annotations", annotations())
.toString();
}
@Override
......
......@@ -17,6 +17,7 @@ package org.onosproject.net.device;
import org.junit.Test;
import org.onlab.packet.ChassisId;
import org.onosproject.net.DefaultAnnotations;
import java.net.URI;
......@@ -35,12 +36,13 @@ public class DefaultDeviceDescriptionTest {
private static final String SW = "3.9.1";
private static final String SN = "43311-12345";
private static final ChassisId CID = new ChassisId();
private static final DefaultAnnotations DA =
DefaultAnnotations.builder().set("Key", "Value").build();
@Test
public void basics() {
DeviceDescription device =
new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID);
new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID, DA);
assertEquals("incorrect uri", DURI, device.deviceUri());
assertEquals("incorrect type", SWITCH, device.type());
assertEquals("incorrect manufacturer", MFR, device.manufacturer());
......@@ -49,6 +51,7 @@ public class DefaultDeviceDescriptionTest {
assertEquals("incorrect serial", SN, device.serialNumber());
assertTrue("incorrect toString", device.toString().contains("uri=of:foo"));
assertTrue("Incorrect chassis", device.chassisId().value() == 0);
assertTrue("incorrect annotatios", device.toString().contains("Key=Value"));
}
}
......
......@@ -16,10 +16,12 @@
package org.onosproject.net.link;
import org.junit.Test;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.onosproject.net.DefaultLinkTest.cp;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.Link.Type.DIRECT;
......@@ -33,13 +35,16 @@ public class DefaultLinkDescriptionTest {
private static final DeviceId DID1 = deviceId("of:foo");
private static final DeviceId DID2 = deviceId("of:bar");
private static final PortNumber P1 = portNumber(1);
private static final DefaultAnnotations DA =
DefaultAnnotations.builder().set("Key", "Value").build();
@Test
public void basics() {
LinkDescription desc = new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P1), DIRECT);
LinkDescription desc = new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P1), DIRECT, DA);
assertEquals("incorrect src", cp(DID1, P1), desc.src());
assertEquals("incorrect dst", cp(DID2, P1), desc.dst());
assertEquals("incorrect type", DIRECT, desc.type());
assertTrue("incorrect annotatios", desc.toString().contains("Key=Value"));
}
}
......