Merge "Do not require namespace repairing"
[yangtools.git] / yang / yang-model-util / src / test / java / org / opendaylight / yangtools / yang / model / util / DataNodeIteratorTest.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 org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
13
14 import java.util.Collections;
15 import java.util.NoSuchElementException;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertFalse;
19 import static org.mockito.Mockito.mock;
20
21 public class DataNodeIteratorTest {
22
23     private DataNodeIterator dataNodeIterator;
24
25     @Before
26     public void setUp() {
27         DataNodeContainer dataNodeContainer = mock(DataNodeContainer.class);
28         this.dataNodeIterator = new DataNodeIterator(dataNodeContainer);
29     }
30
31     @Test(expected=IllegalArgumentException.class)
32     public void createDataNodeIteratorWithNullArgument() {
33         new DataNodeIterator(null);
34     }
35
36     @Test(expected=UnsupportedOperationException.class)
37     public void removeFromEmptyDataNodeContainer() {
38         dataNodeIterator.remove();
39     }
40
41     @Test(expected = NoSuchElementException.class)
42     public void tryNextOnEmptyDataContainer() {
43         dataNodeIterator.next();
44     }
45
46     @Test
47     public void createDataNodeIteratorWith() {
48         assertFalse("Has no next", dataNodeIterator.hasNext());
49         assertEquals("Should be empty list", Collections.EMPTY_LIST, dataNodeIterator.allChoices());
50         assertEquals("Should be empty list", Collections.EMPTY_LIST, dataNodeIterator.allContainers());
51         assertEquals("Should be empty list", Collections.EMPTY_LIST, dataNodeIterator.allTypedefs());
52         assertEquals("Should be empty list", Collections.EMPTY_LIST, dataNodeIterator.allGroupings());
53         assertEquals("Should be empty list", Collections.EMPTY_LIST, dataNodeIterator.allLists());
54     }
55 }