blob: 4b229d855d95e183a6c9a117caabb485acd9482a [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
tom747a2132014-10-02 08:18:41 -070016package org.onlab.onos.net.topology;
17
18import com.google.common.collect.ImmutableSet;
19import org.junit.Test;
20import org.onlab.onos.net.DefaultDevice;
21import org.onlab.onos.net.Device;
22import org.onlab.onos.net.DeviceId;
23
24import static org.junit.Assert.assertEquals;
25import static org.onlab.onos.net.Device.Type.SWITCH;
26import static org.onlab.onos.net.DeviceId.deviceId;
27import static org.onlab.onos.net.topology.DefaultTopologyEdgeTest.*;
28
29public class DefaultGraphDescriptionTest {
30
31 static final DefaultTopologyEdge E1 = new DefaultTopologyEdge(V1, V2, L1);
32 static final DefaultTopologyEdge E2 = new DefaultTopologyEdge(V1, V2, L1);
33
34 private static final DeviceId D3 = deviceId("3");
35
alshabib7911a052014-10-16 17:49:37 -070036 static final Device DEV1 = new DefaultDevice(PID, D1, SWITCH, "", "", "", "", null);
37 static final Device DEV2 = new DefaultDevice(PID, D2, SWITCH, "", "", "", "", null);
38 static final Device DEV3 = new DefaultDevice(PID, D3, SWITCH, "", "", "", "", null);
tom747a2132014-10-02 08:18:41 -070039
40 @Test
41 public void basics() {
42 DefaultGraphDescription desc =
43 new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV2, DEV3),
44 ImmutableSet.of(L1, L2));
45 assertEquals("incorrect time", 4321L, desc.timestamp());
46 assertEquals("incorrect vertex count", 3, desc.vertexes().size());
47 assertEquals("incorrect edge count", 2, desc.edges().size());
48 }
49
50 @Test(expected = IllegalArgumentException.class)
51 public void missingVertex() {
52 new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV3),
53 ImmutableSet.of(L1, L2));
54 }
Yuta HIGUCHI885be1d2014-10-04 21:47:26 -070055}