blob: e7c5048fca3eb1f7a530bcd856194b55ecc30b45 [file] [log] [blame]
Simon Huntd6685d02015-08-21 09:56:06 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Huntd6685d02015-08-21 09:56:06 -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.
Simon Huntd6685d02015-08-21 09:56:06 -070015 */
16
17package org.onosproject.ui.topo;
18
19import org.junit.Test;
20
21import static org.junit.Assert.assertEquals;
22import static org.junit.Assert.assertNull;
23
24/**
25 * Unit tests for {@link BiLink}.
26 */
27public class BiLinkTest extends BiLinkTestBase {
28
29 private static final String EXP_ID_AB = "device-a/1-device-b/2";
30
31 private BiLink blink;
32
33 @Test
34 public void basic() {
35 blink = new ConcreteLink(KEY_AB, LINK_AB);
36 assertEquals("wrong id", EXP_ID_AB, blink.linkId());
37 assertEquals("wrong key", KEY_AB, blink.key());
38 assertEquals("wrong link one", LINK_AB, blink.one());
39 assertNull("what?", blink.two());
40
41 blink.setOther(LINK_BA);
42 assertEquals("wrong link two", LINK_BA, blink.two());
43 }
44
45 @Test(expected = NullPointerException.class)
46 public void nullKey() {
47 new ConcreteLink(null, LINK_AB);
48 }
49
50 @Test(expected = NullPointerException.class)
51 public void nullLink() {
52 new ConcreteLink(KEY_AB, null);
53 }
54
55 @Test(expected = NullPointerException.class)
56 public void nullOther() {
57 blink = new ConcreteLink(KEY_AB, LINK_AB);
58 blink.setOther(null);
59 }
60}
61