blob: 90b04591e06e6877cd2c542d0a816440aad6593c [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.link;
tomc0ccfb22014-09-08 00:41:32 -070017
18import org.junit.Test;
Pavel Likin9d49f542015-12-13 15:04:55 +030019import org.onosproject.net.DefaultAnnotations;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.DeviceId;
21import org.onosproject.net.PortNumber;
tomc0ccfb22014-09-08 00:41:32 -070022
23import static org.junit.Assert.assertEquals;
Pavel Likin9d49f542015-12-13 15:04:55 +030024import static org.junit.Assert.assertTrue;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import static org.onosproject.net.DefaultLinkTest.cp;
26import static org.onosproject.net.DeviceId.deviceId;
27import static org.onosproject.net.Link.Type.DIRECT;
28import static org.onosproject.net.PortNumber.portNumber;
tomc0ccfb22014-09-08 00:41:32 -070029
30/**
31 * Test of the default link description.
32 */
33public class DefaultLinkDescriptionTest {
34
35 private static final DeviceId DID1 = deviceId("of:foo");
36 private static final DeviceId DID2 = deviceId("of:bar");
37 private static final PortNumber P1 = portNumber(1);
Pavel Likin9d49f542015-12-13 15:04:55 +030038 private static final DefaultAnnotations DA =
39 DefaultAnnotations.builder().set("Key", "Value").build();
tomc0ccfb22014-09-08 00:41:32 -070040
41 @Test
42 public void basics() {
Pavel Likin9d49f542015-12-13 15:04:55 +030043 LinkDescription desc = new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P1), DIRECT, DA);
tomc0ccfb22014-09-08 00:41:32 -070044 assertEquals("incorrect src", cp(DID1, P1), desc.src());
45 assertEquals("incorrect dst", cp(DID2, P1), desc.dst());
46 assertEquals("incorrect type", DIRECT, desc.type());
Pavel Likin9d49f542015-12-13 15:04:55 +030047 assertTrue("incorrect annotatios", desc.toString().contains("Key=Value"));
tomc0ccfb22014-09-08 00:41:32 -070048 }
49
50}