Remove some calls to the deprecated Path.cost() API

Change-Id: I71d01fdf35d8a06639e6422b4c8d5998b14e319d
This commit is contained in:
Ray Milkey 2018-09-18 14:55:59 -07:00 committed by Thomas Vachuska
parent 6e7843d5a3
commit cc0012423b
6 changed files with 50 additions and 46 deletions

View File

@ -483,7 +483,7 @@ public class PathComputationTest {
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -524,7 +524,7 @@ public class PathComputationTest {
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 200));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(200.0)));
}
/**
@ -561,7 +561,7 @@ public class PathComputationTest {
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**
@ -597,7 +597,7 @@ public class PathComputationTest {
constraints.add(bandwidthConst);
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**
@ -662,7 +662,7 @@ public class PathComputationTest {
constraints.add(costConst);
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -727,7 +727,7 @@ public class PathComputationTest {
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -742,7 +742,7 @@ public class PathComputationTest {
List<Constraint> constraints = new LinkedList<>();
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**
@ -784,7 +784,7 @@ public class PathComputationTest {
links.add(link1);
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -877,7 +877,7 @@ public class PathComputationTest {
links.add(link1);
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -964,7 +964,7 @@ public class PathComputationTest {
links.add(link1);
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -1050,7 +1050,7 @@ public class PathComputationTest {
links.add(link1);
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -1138,7 +1138,7 @@ public class PathComputationTest {
links.add(link1);
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
}
/**
@ -1205,7 +1205,7 @@ public class PathComputationTest {
List<Link> links = new LinkedList<>();
links.add(link1);
links.add(link2);
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**
@ -1221,7 +1221,7 @@ public class PathComputationTest {
List<Constraint> constraints = new LinkedList<>();
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**
@ -1237,7 +1237,7 @@ public class PathComputationTest {
List<Constraint> constraints = null;
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**
@ -1296,7 +1296,7 @@ public class PathComputationTest {
links.add(link4);
links.add(link5);
assertThat(builder.build().iterator().next().links(), is(links));
assertThat(builder.build().iterator().next().cost(), is((double) 40));
assertThat(builder.build().iterator().next().weight(), is(ScalarWeight.toWeight(40.0)));
}
/**
@ -1353,7 +1353,7 @@ public class PathComputationTest {
links.add(link2);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 2));
assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
}
/**

View File

@ -21,6 +21,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.graph.GraphPathSearch;
import org.onlab.graph.ScalarWeight;
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
import org.onlab.util.Bandwidth;
@ -1011,10 +1012,10 @@ public class PceManagerTest {
}
/**
* Tests resilency when L2 link is down.
* Tests resiliency when L2 link is down.
*/
@Test
public void resilencyTest1() {
public void resiliencyTest1() {
build4RouterTopo(true, false, false, false, 10);
@ -1050,14 +1051,14 @@ public class PceManagerTest {
//Path is D1-D3-D4
assertThat(pathService.paths().iterator().next().links(), is(links));
assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
assertThat(pathService.paths().iterator().next().weight(), is(ScalarWeight.toWeight(180.0)));
}
/**
* Tests resilency when L2 and L4 link is down.
* Tests resiliency when L2 and L4 link is down.
*/
@Test
public void resilencyTest2() {
public void resiliencyTest2() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1093,10 +1094,10 @@ public class PceManagerTest {
}
/**
* Tests resilency when D2 device is down.
* Tests resiliency when D2 device is down.
*/
@Test
public void resilencyTest3() {
public void resiliencyTest3() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1134,14 +1135,14 @@ public class PceManagerTest {
Path path = tunnelService.queryAllTunnels().iterator().next().path();
//Path is D1-D3-D4
assertThat(path.links(), is(links));
assertThat(path.cost(), is((double) 180));
assertThat(path.weight(), is(ScalarWeight.toWeight(180.0)));
}
/**
* Tests resilency when ingress device is down.
* Tests resiliency when ingress device is down.
*/
@Test
public void resilencyTest4() {
public void resiliencyTest4() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1177,10 +1178,10 @@ public class PceManagerTest {
}
/**
* Tests resilency when D2 and D3 devices are down.
* Tests resiliency when D2 and D3 devices are down.
*/
@Test
public void resilencyTest5() {
public void resiliencyTest5() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1226,10 +1227,10 @@ public class PceManagerTest {
}
/**
* Tests resilency when egress device is down.
* Tests resiliency when egress device is down.
*/
@Test
public void resilencyTest6() {
public void resiliencyTest6() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1268,10 +1269,10 @@ public class PceManagerTest {
}
/**
* Tests resilency when egress device is down.
* Tests resiliency when egress device is down.
*/
@Test
public void resilencyTest7() {
public void resiliencyTest7() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1310,10 +1311,10 @@ public class PceManagerTest {
}
/**
* Tests resilency when D2 device is suspended.
* Tests resiliency when D2 device is suspended.
*/
@Test
public void resilencyTest8() {
public void resiliencyTest8() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1355,14 +1356,14 @@ public class PceManagerTest {
//Path is D1-D3-D4
assertThat(path.links(), is(links));
assertThat(path.cost(), is((double) 180));
assertThat(path.weight(), is(ScalarWeight.toWeight(180.0)));
}
/**
* Tests resilency when D2 device availability is changed.
* Tests resiliency when D2 device availability is changed.
*/
@Test
public void resilencyTest11() {
public void resiliencyTest11() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();
@ -1404,14 +1405,14 @@ public class PceManagerTest {
//Path is D1-D3-D4
assertThat(path.links(), is(links));
assertThat(path.cost(), is((double) 180));
assertThat(path.weight(), is(ScalarWeight.toWeight(180.0)));
}
/**
* Tests resilency when link2 availability is changed.
* Tests resiliency when link2 availability is changed.
*/
@Test
public void resilencyTest12() {
public void resiliencyTest12() {
build4RouterTopo(true, false, false, false, 10);
List<Constraint> constraints = new LinkedList<Constraint>();

View File

@ -84,7 +84,7 @@ public class DefaultDisjointPathTest {
assertThat(disjointPath1.primary(), is(path1));
assertThat(disjointPath1.backup(), is(path2));
assertThat(disjointPath1.links(), is(links1));
assertThat(disjointPath1.cost(), is(1.0));
assertThat(disjointPath1.weight(), is(ScalarWeight.toWeight(1.0)));
}
/**

View File

@ -18,6 +18,7 @@ package org.onosproject.net.topology.impl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.graph.ScalarWeight;
import org.onosproject.event.Event;
import org.onosproject.common.event.impl.TestEventDispatcher;
import org.onosproject.net.ConnectPoint;
@ -168,7 +169,7 @@ public class TopologyManagerTest {
assertEquals("wrong path count", 2, paths.size());
Path path = paths.iterator().next();
assertEquals("wrong path length", 2, path.links().size());
assertEquals("wrong path cost", 2, path.cost(), 0.01);
assertEquals("wrong path cost", ScalarWeight.toWeight(2), path.weight());
}
@Test
@ -181,7 +182,7 @@ public class TopologyManagerTest {
assertEquals("wrong path count", 2, paths.size());
Path path = paths.iterator().next();
assertEquals("wrong path length", 2, path.links().size());
assertEquals("wrong path cost", 6.6, path.cost(), 0.01);
assertEquals("wrong path cost", ScalarWeight.toWeight(6.6), path.weight());
}
protected void validateEvents(Enum... types) {

View File

@ -19,6 +19,7 @@ package org.onosproject.incubator.net.virtual.impl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.graph.ScalarWeight;
import org.onlab.junit.TestUtils;
import org.onlab.osgi.TestServiceDirectory;
import org.onosproject.common.event.impl.TestEventDispatcher;
@ -233,7 +234,7 @@ public class VirtualNetworkPathManagerTest extends TestDeviceParams {
assertEquals("incorrect length", length, path.links().size());
assertEquals("incorrect source", src, path.src().elementId());
assertEquals("incorrect destination", dst, path.dst().elementId());
assertEquals("incorrect cost", cost, path.cost(), 0);
assertEquals("incorrect cost", ScalarWeight.toWeight(cost), path.weight());
}
}
}

View File

@ -19,6 +19,7 @@ package org.onosproject.incubator.net.virtual.impl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.graph.ScalarWeight;
import org.onlab.junit.TestUtils;
import org.onlab.osgi.TestServiceDirectory;
import org.onosproject.common.event.impl.TestEventDispatcher;
@ -420,7 +421,7 @@ public class VirtualNetworkTopologyManagerTest extends TestDeviceParams {
assertEquals("The paths size did not match.", 1, paths1.size());
Path path = paths1.iterator().next();
assertEquals("wrong path length", 1, path.links().size());
assertEquals("wrong path cost", 1.0, path.cost(), 0.01);
assertEquals("wrong path cost", ScalarWeight.toWeight(1.0), path.weight());
}
/**