blob: 5ff936719e5d11adbd2cc542a2bdf0e34bca30b3 [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;
Yuta HIGUCHI22102822014-11-12 23:09:59 -080019
tom747a2132014-10-02 08:18:41 -070020import org.junit.Test;
21import org.onlab.onos.net.DefaultDevice;
22import org.onlab.onos.net.Device;
23import org.onlab.onos.net.DeviceId;
24
25import static org.junit.Assert.assertEquals;
26import static org.onlab.onos.net.Device.Type.SWITCH;
27import static org.onlab.onos.net.DeviceId.deviceId;
28import static org.onlab.onos.net.topology.DefaultTopologyEdgeTest.*;
29
30public class DefaultGraphDescriptionTest {
31
32 static final DefaultTopologyEdge E1 = new DefaultTopologyEdge(V1, V2, L1);
33 static final DefaultTopologyEdge E2 = new DefaultTopologyEdge(V1, V2, L1);
34
35 private static final DeviceId D3 = deviceId("3");
36
alshabib7911a052014-10-16 17:49:37 -070037 static final Device DEV1 = new DefaultDevice(PID, D1, SWITCH, "", "", "", "", null);
38 static final Device DEV2 = new DefaultDevice(PID, D2, SWITCH, "", "", "", "", null);
39 static final Device DEV3 = new DefaultDevice(PID, D3, SWITCH, "", "", "", "", null);
tom747a2132014-10-02 08:18:41 -070040
41 @Test
42 public void basics() {
43 DefaultGraphDescription desc =
44 new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV2, DEV3),
45 ImmutableSet.of(L1, L2));
46 assertEquals("incorrect time", 4321L, desc.timestamp());
47 assertEquals("incorrect vertex count", 3, desc.vertexes().size());
48 assertEquals("incorrect edge count", 2, desc.edges().size());
49 }
50
Yuta HIGUCHI22102822014-11-12 23:09:59 -080051 @Test
tom747a2132014-10-02 08:18:41 -070052 public void missingVertex() {
Yuta HIGUCHI22102822014-11-12 23:09:59 -080053 GraphDescription desc = new DefaultGraphDescription(4321L,
54 ImmutableSet.of(DEV1, DEV3),
55 ImmutableSet.of(L1, L2));
56 assertEquals("incorrect time", 4321L, desc.timestamp());
57 assertEquals("incorrect vertex count", 2, desc.vertexes().size());
58 assertEquals("incorrect edge count", 0, desc.edges().size());
tom747a2132014-10-02 08:18:41 -070059 }
Yuta HIGUCHI885be1d2014-10-04 21:47:26 -070060}