Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 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. |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package org.onosproject.ui.topo; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | |
| 21 | import static org.junit.Assert.assertEquals; |
| 22 | import static org.junit.Assert.assertNull; |
| 23 | |
| 24 | /** |
| 25 | * Unit tests for {@link BiLink}. |
| 26 | */ |
| 27 | public 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 | |