blob: 86ced8c8a158cd1a13da37cf3eae61a3883b08b4 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.topology;
tom747a2132014-10-02 08:18:41 -070017
18import com.google.common.collect.ImmutableSet;
Yuta HIGUCHI22102822014-11-12 23:09:59 -080019
tom747a2132014-10-02 08:18:41 -070020import org.junit.Test;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.net.DefaultDevice;
22import org.onosproject.net.Device;
23import org.onosproject.net.DeviceId;
tom747a2132014-10-02 08:18:41 -070024
25import static org.junit.Assert.assertEquals;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import static org.onosproject.net.Device.Type.SWITCH;
27import static org.onosproject.net.DeviceId.deviceId;
28import static org.onosproject.net.topology.DefaultTopologyEdgeTest.*;
tom747a2132014-10-02 08:18:41 -070029
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 =
Sho SHIMIZU2581e182015-09-25 10:22:33 -070044 new DefaultGraphDescription(4321L, System.currentTimeMillis(), ImmutableSet.of(DEV1, DEV2, DEV3),
tom747a2132014-10-02 08:18:41 -070045 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() {
Sho SHIMIZU2581e182015-09-25 10:22:33 -070053 GraphDescription desc = new DefaultGraphDescription(4321L, System.currentTimeMillis(),
Yuta HIGUCHI22102822014-11-12 23:09:59 -080054 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}