diff options
Diffstat (limited to 'framework/src/onos/core/api/src/test/java/org/onosproject/net/topology/DefaultGraphDescriptionTest.java')
-rw-r--r-- | framework/src/onos/core/api/src/test/java/org/onosproject/net/topology/DefaultGraphDescriptionTest.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/topology/DefaultGraphDescriptionTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/topology/DefaultGraphDescriptionTest.java new file mode 100644 index 00000000..8b0f8f05 --- /dev/null +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/topology/DefaultGraphDescriptionTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.net.topology; + +import com.google.common.collect.ImmutableSet; + +import org.junit.Test; +import org.onosproject.net.DefaultDevice; +import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; + +import static org.junit.Assert.assertEquals; +import static org.onosproject.net.Device.Type.SWITCH; +import static org.onosproject.net.DeviceId.deviceId; +import static org.onosproject.net.topology.DefaultTopologyEdgeTest.*; + +public class DefaultGraphDescriptionTest { + + static final DefaultTopologyEdge E1 = new DefaultTopologyEdge(V1, V2, L1); + static final DefaultTopologyEdge E2 = new DefaultTopologyEdge(V1, V2, L1); + + private static final DeviceId D3 = deviceId("3"); + + static final Device DEV1 = new DefaultDevice(PID, D1, SWITCH, "", "", "", "", null); + static final Device DEV2 = new DefaultDevice(PID, D2, SWITCH, "", "", "", "", null); + static final Device DEV3 = new DefaultDevice(PID, D3, SWITCH, "", "", "", "", null); + + @Test + public void basics() { + DefaultGraphDescription desc = + new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV2, DEV3), + ImmutableSet.of(L1, L2)); + assertEquals("incorrect time", 4321L, desc.timestamp()); + assertEquals("incorrect vertex count", 3, desc.vertexes().size()); + assertEquals("incorrect edge count", 2, desc.edges().size()); + } + + @Test + public void missingVertex() { + GraphDescription desc = new DefaultGraphDescription(4321L, + ImmutableSet.of(DEV1, DEV3), + ImmutableSet.of(L1, L2)); + assertEquals("incorrect time", 4321L, desc.timestamp()); + assertEquals("incorrect vertex count", 2, desc.vertexes().size()); + assertEquals("incorrect edge count", 0, desc.edges().size()); + } +} |