Madan Jampani | 92c64eb | 2015-07-23 15:37:07 -0700 | [diff] [blame] | 1 | package org.onosproject.store.consistent.impl; |
| 2 | |
| 3 | import static junit.framework.TestCase.assertEquals; |
| 4 | import static junit.framework.TestCase.assertFalse; |
| 5 | import static junit.framework.TestCase.assertNull; |
| 6 | import static junit.framework.TestCase.assertTrue; |
| 7 | |
| 8 | import org.junit.Test; |
| 9 | |
| 10 | /** |
| 11 | * Unit tests for Result. |
| 12 | */ |
| 13 | public class ResultTest { |
| 14 | |
| 15 | @Test |
| 16 | public void testLocked() { |
| 17 | Result<String> r = Result.locked(); |
| 18 | assertFalse(r.success()); |
| 19 | assertNull(r.value()); |
| 20 | assertEquals(Result.Status.LOCKED, r.status()); |
| 21 | } |
| 22 | |
| 23 | @Test |
| 24 | public void testOk() { |
| 25 | Result<String> r = Result.ok("foo"); |
| 26 | assertTrue(r.success()); |
| 27 | assertEquals("foo", r.value()); |
| 28 | assertEquals(Result.Status.OK, r.status()); |
| 29 | } |
| 30 | |
| 31 | @Test |
| 32 | public void testEquality() { |
| 33 | Result<String> r1 = Result.ok("foo"); |
| 34 | Result<String> r2 = Result.locked(); |
| 35 | Result<String> r3 = Result.ok("bar"); |
| 36 | Result<String> r4 = Result.ok("foo"); |
| 37 | assertTrue(r1.equals(r4)); |
| 38 | assertFalse(r1.equals(r2)); |
| 39 | assertFalse(r1.equals(r3)); |
| 40 | assertFalse(r2.equals(r3)); |
| 41 | } |
| 42 | } |