tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.topology; |
| 2 | |
| 3 | import com.google.common.collect.ImmutableSet; |
| 4 | import org.junit.Test; |
| 5 | import org.onlab.onos.net.DefaultDevice; |
| 6 | import org.onlab.onos.net.Device; |
| 7 | import org.onlab.onos.net.DeviceId; |
| 8 | |
| 9 | import static org.junit.Assert.assertEquals; |
| 10 | import static org.onlab.onos.net.Device.Type.SWITCH; |
| 11 | import static org.onlab.onos.net.DeviceId.deviceId; |
| 12 | import static org.onlab.onos.net.topology.DefaultTopologyEdgeTest.*; |
| 13 | |
| 14 | public 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 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame^] | 21 | 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); |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 24 | |
| 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 HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 40 | } |