8b0f8f0598ba9b9ea7c6bc293a033ae6f2128a01
[onosfw.git] /
1 /*
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  */
16 package org.onosproject.net.topology;
17
18 import com.google.common.collect.ImmutableSet;
19
20 import org.junit.Test;
21 import org.onosproject.net.DefaultDevice;
22 import org.onosproject.net.Device;
23 import org.onosproject.net.DeviceId;
24
25 import static org.junit.Assert.assertEquals;
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.*;
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
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);
40
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
51     @Test
52     public void missingVertex() {
53         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());
59     }
60 }