use of org.onosproject.net.ElementId in project onos by opennetworkinglab.
the class ComparatorsTest method testElementIdComparator.
@Test
public void testElementIdComparator() {
ElementId elementid1 = new ElementId() {
};
ElementId elementid2 = elementid1;
ElementId elementid3 = new ElementId() {
};
while (elementid1 == elementid3) {
elementid3 = new ElementId() {
};
}
assertTrue(0 == ELEMENT_ID_COMPARATOR.compare(elementid1, elementid2));
assertFalse(0 == ELEMENT_ID_COMPARATOR.compare(elementid3, elementid1));
}
use of org.onosproject.net.ElementId in project onos by opennetworkinglab.
the class MockLinkService method addLink.
public void addLink(String device, long port, String device2, long port2) {
ElementId d1;
if (device.charAt(0) == 'H') {
device = device.substring(1, device.length());
d1 = HostId.hostId(device);
} else {
d1 = DeviceId.deviceId(device);
}
ElementId d2;
if (device2.charAt(0) == 'H') {
d2 = HostId.hostId(device2.substring(1, device2.length()));
} else {
d2 = DeviceId.deviceId(device2);
}
ConnectPoint src = new ConnectPoint(d1, PortNumber.portNumber(port));
ConnectPoint dst = new ConnectPoint(d2, PortNumber.portNumber(port2));
Link curLink;
curLink = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).build();
links.add(curLink);
if (d1 instanceof DeviceId && d2 instanceof DeviceId) {
TopologyVertex v1 = () -> (DeviceId) d1, v2 = () -> (DeviceId) d2;
createdGraph.addVertex(v1);
createdGraph.addVertex(v2);
createdGraph.addEdge(new TopologyEdge() {
@Override
public Link link() {
return curLink;
}
@Override
public TopologyVertex src() {
return v1;
}
@Override
public TopologyVertex dst() {
return v2;
}
});
}
}
Aggregations