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