Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
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.*; |
| 22 | |
| 23 | /** |
| 24 | * Unit tests for {@link Mod}. |
| 25 | */ |
| 26 | public class ModTest { |
| 27 | |
| 28 | private static final String AAA = "aaa"; |
| 29 | private static final String BBB = "bbb"; |
| 30 | |
| 31 | private Mod mod1; |
| 32 | private Mod mod2; |
| 33 | |
| 34 | @Test(expected = NullPointerException.class) |
| 35 | public void nullId() { |
| 36 | new Mod(null); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void basic() { |
| 41 | mod1 = new Mod(AAA); |
| 42 | assertEquals("wrong id", AAA, mod1.toString()); |
| 43 | } |
| 44 | |
| 45 | @Test |
| 46 | public void equivalence() { |
| 47 | mod1 = new Mod(AAA); |
| 48 | mod2 = new Mod(AAA); |
| 49 | assertNotSame("oops", mod1, mod2); |
| 50 | assertEquals("not equivalent", mod1, mod2); |
| 51 | } |
| 52 | |
| 53 | @Test |
| 54 | public void comparable() { |
| 55 | mod1 = new Mod(AAA); |
| 56 | mod2 = new Mod(BBB); |
| 57 | assertNotEquals("what?", mod1, mod2); |
| 58 | assertTrue(mod1.compareTo(mod2) < 0); |
| 59 | assertTrue(mod2.compareTo(mod1) > 0); |
| 60 | } |
| 61 | } |