blob: 2d329d1443f4bd58b29a0519a1982c794e54ddad [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -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 */
Madan Jampani92c64eb2015-07-23 15:37:07 -070016package org.onosproject.store.consistent.impl;
17
18import static junit.framework.TestCase.assertEquals;
19import static junit.framework.TestCase.assertFalse;
20import static junit.framework.TestCase.assertNull;
21import static junit.framework.TestCase.assertTrue;
22
23import org.junit.Test;
24
25/**
26 * Unit tests for Result.
27 */
28public class ResultTest {
29
30 @Test
31 public void testLocked() {
32 Result<String> r = Result.locked();
33 assertFalse(r.success());
34 assertNull(r.value());
35 assertEquals(Result.Status.LOCKED, r.status());
36 }
37
38 @Test
39 public void testOk() {
40 Result<String> r = Result.ok("foo");
41 assertTrue(r.success());
42 assertEquals("foo", r.value());
43 assertEquals(Result.Status.OK, r.status());
44 }
45
46 @Test
47 public void testEquality() {
48 Result<String> r1 = Result.ok("foo");
49 Result<String> r2 = Result.locked();
50 Result<String> r3 = Result.ok("bar");
51 Result<String> r4 = Result.ok("foo");
52 assertTrue(r1.equals(r4));
53 assertFalse(r1.equals(r2));
54 assertFalse(r1.equals(r3));
55 assertFalse(r2.equals(r3));
56 }
57}