use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetClusters.
/**
* Test getClusters() method.
*/
@Test
public void testGetClusters() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
// test the getClusters() method.
assertNotNull("The clusters should not be null.", topologyService.getClusters(topology));
assertEquals("The clusters size did not match.", 2, topologyService.getClusters(topology).size());
}
use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetClusterUsingNullClusterId.
/**
* Test getCluster() method using a null cluster identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetClusterUsingNullClusterId() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
Set<TopologyCluster> clusters = topologyService.getClusters(topology);
TopologyCluster cluster = clusters.stream().findFirst().get();
// test the getCluster() method with a null cluster identifier
TopologyCluster cluster1 = topologyService.getCluster(topology, null);
}
use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.
the class TopologyResourceTest method setUpTest.
/**
* Initializes the test harness.
*/
@Before
public void setUpTest() {
TopologyService topologyService = new MockTopologyService();
DeviceService mockDeviceService = new MockDeviceService();
CodecManager codecService = new CodecManager();
codecService.activate();
ServiceDirectory testDirectory = new TestServiceDirectory().add(DeviceService.class, mockDeviceService).add(TopologyService.class, topologyService).add(CodecService.class, codecService);
setServiceDirectory(testDirectory);
}
use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.
the class TopologyWebResource method getClusterDevices.
/**
* Gets devices in a specific SCC.
*
* @param clusterId id of the cluster to query
* @return 200 OK with topology cluster devices
* @onos.rsModel TopologyClustersDevices
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("clusters/{id}/devices")
public Response getClusterDevices(@PathParam("id") int clusterId) {
TopologyService service = get(TopologyService.class);
Topology topology = service.currentTopology();
TopologyCluster cluster = getTopologyCluster(clusterId, topology);
List<DeviceId> deviceIds = Lists.newArrayList(service.getClusterDevices(topology, cluster));
ObjectNode root = mapper().createObjectNode();
ArrayNode devicesNode = root.putArray("devices");
deviceIds.forEach(id -> devicesNode.add(id.toString()));
return ok(root).build();
}
use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.
the class PathPainterTopovMessageHandler method init.
// ===============-=-=-=-=-=-======================-=-=-=-=-=-=-===========
@Override
public void init(UiConnection connection, ServiceDirectory directory) {
super.init(connection, directory);
pathService = directory.get(PathService.class);
topologyService = directory.get(TopologyService.class);
linkData = new GeoDistanceLinkWeight(directory.get(DeviceService.class));
addListeners();
}
Aggregations