@Test public void testComputePath() throws Exception { VirtualNodeId source = mock(VirtualNodeId.class); VirtualNodeId target = mock(VirtualNodeId.class); VirtualPath result; when(source.getValue()).thenReturn(new String("src")); when(target.getValue()) .thenReturn(new String("null")) .thenReturn(new String("dst")); result = vnComputationUnit.computePath(source,target); Assert.assertTrue(result == null); result = vnComputationUnit.computePath(source,target); Assert.assertTrue(result != null); verify(source, times(2)).getValue(); verify(target,times(2)).getValue(); }
public VirtualPath computePath(VirtualNodeId source, VirtualNodeId target) { List<Edge> edges = routingAlgorithm.computePath(routingAlgorithm.getVertex(source.getValue()), routingAlgorithm.getVertex(target.getValue())); if ( null == edges || edges.isEmpty() ) { return null; } List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<>(edges.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink virtualLink; long metric = 0; long delay = 0; for ( Edge edge : edges ) { virtualLink = new VirtualLinkBuilder() .setLinkId(new VirtualLinkId(edge.getId())) .setOrder((long) virtualLinks.size()) .build(); virtualLinks.add(virtualLink); metric += edge.getMetric(); } VirtualPath virtualPath = new VirtualPathBuilder() .setPathId(new VirtualPathId(UUID.randomUUID().toString())) .setVirtualLink(virtualLinks) .setMetric(metric) .setBandwidth(0L) .setDelay(delay) .build(); return virtualPath; }
VNComputationUnit implements AutoCloseable { public VirtualPath computePath(VirtualNodeId source, VirtualNodeId target) { List<Edge> edges = routingAlgorithm.computePath(routingAlgorithm.getVertex(source.getValue()), routingAlgorithm.getVertex(target.getValue())); if ( null == edges || edges.isEmpty() ) { return null; } List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<>(edges.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink virtualLink; long metric = 0; long delay = 0; for ( Edge edge : edges ) { virtualLink = new VirtualLinkBuilder() .setLinkId(new VirtualLinkId(edge.getId())) .setOrder((long) virtualLinks.size()) .build(); virtualLinks.add(virtualLink); metric += edge.getMetric(); } VirtualPath virtualPath = new VirtualPathBuilder() .setPathId(new VirtualPathId(UUID.randomUUID().toString())) .setVirtualLink(virtualLinks) .setMetric(metric) .setBandwidth(0L) .setDelay(delay) .build(); return virtualPath; } }
VNComputationUnit implements AutoCloseable { public VirtualPath computePath(VirtualNodeId source, VirtualNodeId target) { List<Edge> edges = routingAlgorithm.computePath(routingAlgorithm.getVertex(source.getValue()), routingAlgorithm.getVertex(target.getValue())); if ( null == edges || edges.isEmpty() ) { return null; } List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<>(edges.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink virtualLink; long metric = 0; long delay = 0; for ( Edge edge : edges ) { virtualLink = new VirtualLinkBuilder() .setLinkId(new VirtualLinkId(edge.getId())) .setOrder((long) virtualLinks.size()) .build(); virtualLinks.add(virtualLink); metric += edge.getMetric(); } VirtualPath virtualPath = new VirtualPathBuilder() .setPathId(new VirtualPathId(UUID.randomUUID().toString())) .setVirtualLink(virtualLinks) .setMetric(metric) .setBandwidth(0L) .setDelay(delay) .build(); return virtualPath; } VNComputationUnit(DataBroker dataBroker, UserId userId);  VNComputationUnit(DataBroker dataBroker, VirtualNetwork virtualNetwork); }
VNComputationUnit implements AutoCloseable { public VirtualPath computePath(VirtualNodeId source, VirtualNodeId target) { List<Edge> edges = routingAlgorithm.computePath(routingAlgorithm.getVertex(source.getValue()), routingAlgorithm.getVertex(target.getValue())); if ( null == edges || edges.isEmpty() ) { return null; } List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<>(edges.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink virtualLink; long metric = 0; long delay = 0; for ( Edge edge : edges ) { virtualLink = new VirtualLinkBuilder() .setLinkId(new VirtualLinkId(edge.getId())) .setOrder((long) virtualLinks.size()) .build(); virtualLinks.add(virtualLink); metric += edge.getMetric(); } VirtualPath virtualPath = new VirtualPathBuilder() .setPathId(new VirtualPathId(UUID.randomUUID().toString())) .setVirtualLink(virtualLinks) .setMetric(metric) .setBandwidth(0L) .setDelay(delay) .build(); return virtualPath; } VNComputationUnit(DataBroker dataBroker, UserId userId);  VNComputationUnit(DataBroker dataBroker, VirtualNetwork virtualNetwork); VirtualPath computePath(VirtualNodeId source, VirtualNodeId target); VirtualPath computePath(VirtualNodeId source, VirtualNodeId target, long bandwidth); @Override void close(); }
VNComputationUnit implements AutoCloseable { public VirtualPath computePath(VirtualNodeId source, VirtualNodeId target) { List<Edge> edges = routingAlgorithm.computePath(routingAlgorithm.getVertex(source.getValue()), routingAlgorithm.getVertex(target.getValue())); if ( null == edges || edges.isEmpty() ) { return null; } List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink> virtualLinks = new ArrayList<>(edges.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.path.instance.VirtualLink virtualLink; long metric = 0; long delay = 0; for ( Edge edge : edges ) { virtualLink = new VirtualLinkBuilder() .setLinkId(new VirtualLinkId(edge.getId())) .setOrder((long) virtualLinks.size()) .build(); virtualLinks.add(virtualLink); metric += edge.getMetric(); } VirtualPath virtualPath = new VirtualPathBuilder() .setPathId(new VirtualPathId(UUID.randomUUID().toString())) .setVirtualLink(virtualLinks) .setMetric(metric) .setBandwidth(0L) .setDelay(delay) .build(); return virtualPath; } VNComputationUnit(DataBroker dataBroker, UserId userId);  VNComputationUnit(DataBroker dataBroker, VirtualNetwork virtualNetwork); VirtualPath computePath(VirtualNodeId source, VirtualNodeId target); VirtualPath computePath(VirtualNodeId source, VirtualNodeId target, long bandwidth); @Override void close();  }