Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.topology; |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 17 | |
| 18 | import com.google.common.collect.ImmutableSet; |
Yuta HIGUCHI | 2210282 | 2014-11-12 23:09:59 -0800 | [diff] [blame] | 19 | |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 20 | import org.junit.Test; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 21 | import org.onosproject.net.DefaultDevice; |
| 22 | import org.onosproject.net.Device; |
| 23 | import org.onosproject.net.DeviceId; |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 24 | |
| 25 | import static org.junit.Assert.assertEquals; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 26 | import static org.onosproject.net.Device.Type.SWITCH; |
| 27 | import static org.onosproject.net.DeviceId.deviceId; |
| 28 | import static org.onosproject.net.topology.DefaultTopologyEdgeTest.*; |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 29 | |
| 30 | public 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 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 37 | 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); |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 40 | |
| 41 | @Test |
| 42 | public void basics() { |
| 43 | DefaultGraphDescription desc = |
Sho SHIMIZU | 2581e18 | 2015-09-25 10:22:33 -0700 | [diff] [blame] | 44 | new DefaultGraphDescription(4321L, System.currentTimeMillis(), ImmutableSet.of(DEV1, DEV2, DEV3), |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 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 HIGUCHI | 2210282 | 2014-11-12 23:09:59 -0800 | [diff] [blame] | 51 | @Test |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 52 | public void missingVertex() { |
Sho SHIMIZU | 2581e18 | 2015-09-25 10:22:33 -0700 | [diff] [blame] | 53 | GraphDescription desc = new DefaultGraphDescription(4321L, System.currentTimeMillis(), |
Yuta HIGUCHI | 2210282 | 2014-11-12 23:09:59 -0800 | [diff] [blame] | 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()); |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 59 | } |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 60 | } |