blob: 81e639319091110bf21b95b3dcf1dde18ce59ec4 [file] [log] [blame]
tom747a2132014-10-02 08:18:41 -07001package org.onlab.onos.net.topology;
2
3import com.google.common.collect.ImmutableSet;
4import org.junit.Test;
5import org.onlab.onos.net.DefaultDevice;
6import org.onlab.onos.net.Device;
7import org.onlab.onos.net.DeviceId;
8
9import static org.junit.Assert.assertEquals;
10import static org.onlab.onos.net.Device.Type.SWITCH;
11import static org.onlab.onos.net.DeviceId.deviceId;
12import static org.onlab.onos.net.topology.DefaultTopologyEdgeTest.*;
13
14public class DefaultGraphDescriptionTest {
15
16 static final DefaultTopologyEdge E1 = new DefaultTopologyEdge(V1, V2, L1);
17 static final DefaultTopologyEdge E2 = new DefaultTopologyEdge(V1, V2, L1);
18
19 private static final DeviceId D3 = deviceId("3");
20
alshabib7911a052014-10-16 17:49:37 -070021 static final Device DEV1 = new DefaultDevice(PID, D1, SWITCH, "", "", "", "", null);
22 static final Device DEV2 = new DefaultDevice(PID, D2, SWITCH, "", "", "", "", null);
23 static final Device DEV3 = new DefaultDevice(PID, D3, SWITCH, "", "", "", "", null);
tom747a2132014-10-02 08:18:41 -070024
25 @Test
26 public void basics() {
27 DefaultGraphDescription desc =
28 new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV2, DEV3),
29 ImmutableSet.of(L1, L2));
30 assertEquals("incorrect time", 4321L, desc.timestamp());
31 assertEquals("incorrect vertex count", 3, desc.vertexes().size());
32 assertEquals("incorrect edge count", 2, desc.edges().size());
33 }
34
35 @Test(expected = IllegalArgumentException.class)
36 public void missingVertex() {
37 new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV3),
38 ImmutableSet.of(L1, L2));
39 }
Yuta HIGUCHI885be1d2014-10-04 21:47:26 -070040}