Committed by
Ray Milkey
Add missing getter for waypoints and unit test for equality
Change-Id: If6ca25bd4459c32e30467991039bbbe36f2256f2
Showing
2 changed files
with
21 additions
and
0 deletions
| ... | @@ -48,6 +48,10 @@ public class WaypointConstraint implements Constraint { | ... | @@ -48,6 +48,10 @@ public class WaypointConstraint implements Constraint { |
| 48 | this.waypoints = ImmutableList.copyOf(waypoints); | 48 | this.waypoints = ImmutableList.copyOf(waypoints); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | + public List<ElementId> waypoints() { | ||
| 52 | + return waypoints; | ||
| 53 | + } | ||
| 54 | + | ||
| 51 | @Override | 55 | @Override |
| 52 | public double cost(Link link, LinkResourceService resourceService) { | 56 | public double cost(Link link, LinkResourceService resourceService) { |
| 53 | // Always consider the number of hops | 57 | // Always consider the number of hops | ... | ... |
| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onlab.onos.net.intent.constraint; | 16 | package org.onlab.onos.net.intent.constraint; |
| 17 | 17 | ||
| 18 | +import com.google.common.testing.EqualsTester; | ||
| 18 | import org.junit.Before; | 19 | import org.junit.Before; |
| 19 | import org.junit.Test; | 20 | import org.junit.Test; |
| 20 | import org.onlab.onos.net.DefaultLink; | 21 | import org.onlab.onos.net.DefaultLink; |
| ... | @@ -22,6 +23,7 @@ import org.onlab.onos.net.DefaultPath; | ... | @@ -22,6 +23,7 @@ import org.onlab.onos.net.DefaultPath; |
| 22 | import org.onlab.onos.net.DeviceId; | 23 | import org.onlab.onos.net.DeviceId; |
| 23 | import org.onlab.onos.net.Path; | 24 | import org.onlab.onos.net.Path; |
| 24 | import org.onlab.onos.net.PortNumber; | 25 | import org.onlab.onos.net.PortNumber; |
| 26 | +import org.onlab.onos.net.intent.Constraint; | ||
| 25 | import org.onlab.onos.net.provider.ProviderId; | 27 | import org.onlab.onos.net.provider.ProviderId; |
| 26 | import org.onlab.onos.net.resource.LinkResourceService; | 28 | import org.onlab.onos.net.resource.LinkResourceService; |
| 27 | 29 | ||
| ... | @@ -84,4 +86,19 @@ public class WaypointConstraintTest { | ... | @@ -84,4 +86,19 @@ public class WaypointConstraintTest { |
| 84 | 86 | ||
| 85 | assertThat(sut.validate(path, linkResourceService), is(false)); | 87 | assertThat(sut.validate(path, linkResourceService), is(false)); |
| 86 | } | 88 | } |
| 89 | + | ||
| 90 | + @Test | ||
| 91 | + public void testEquality() { | ||
| 92 | + Constraint c1 = new WaypointConstraint(DID1, DID2); | ||
| 93 | + Constraint c2 = new WaypointConstraint(DID1, DID2); | ||
| 94 | + | ||
| 95 | + Constraint c3 = new WaypointConstraint(DID2); | ||
| 96 | + Constraint c4 = new WaypointConstraint(DID3); | ||
| 97 | + | ||
| 98 | + new EqualsTester() | ||
| 99 | + .addEqualityGroup(c1, c2) | ||
| 100 | + .addEqualityGroup(c3) | ||
| 101 | + .addEqualityGroup(c4) | ||
| 102 | + .testEquals(); | ||
| 103 | + } | ||
| 87 | } | 104 | } | ... | ... |
-
Please register or login to post a comment