Cleanup use of Guava library
[yangtools.git] / yang / yang-model-util / src / test / java / org / opendaylight / yangtools / yang / model / util / SchemaNodeUtilsTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.util;
9
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.assertThat;
14 import static org.mockito.Mockito.doReturn;
15
16 import java.util.Optional;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.mockito.Mock;
20 import org.mockito.MockitoAnnotations;
21 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
23
24 public class SchemaNodeUtilsTest {
25
26     @Mock
27     private DerivableSchemaNode derivableNode;
28
29     @Before
30     public void setup() {
31         MockitoAnnotations.initMocks(this);
32     }
33
34     @Test
35     public void testHandleNullGetOriginalIfPossible() {
36         Optional<SchemaNode> originalIfPossible = SchemaNodeUtils
37                 .getOriginalIfPossible(null);
38         assertNotNull(originalIfPossible);
39         assertThat(originalIfPossible, instanceOf(Optional.class));
40     }
41
42     @Test
43     public void testHandleNodeGetOriginalIfPossible() {
44         Optional<DerivableSchemaNode> of = Optional.of(derivableNode);
45         doReturn(of).when(derivableNode).getOriginal();
46         Optional<SchemaNode> originalIfPossible = SchemaNodeUtils
47                 .getOriginalIfPossible(derivableNode);
48         assertNotNull(originalIfPossible);
49         assertThat(originalIfPossible, instanceOf(Optional.class));
50     }
51
52     @Test
53     public void testHandleNullGetRootOriginalIfPossible() {
54         SchemaNode rootOriginalIfPossible = SchemaNodeUtils
55                 .getRootOriginalIfPossible(null);
56         assertNull(rootOriginalIfPossible);
57     }
58 }