2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.util;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
14 import java.util.Collections;
15 import java.util.NoSuchElementException;
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertFalse;
19 import static org.mockito.Mockito.mock;
21 public class DataNodeIteratorTest {
23 private DataNodeIterator dataNodeIterator;
27 DataNodeContainer dataNodeContainer = mock(DataNodeContainer.class);
28 this.dataNodeIterator = new DataNodeIterator(dataNodeContainer);
31 @Test(expected=IllegalArgumentException.class)
32 public void createDataNodeIteratorWithNullArgument() {
33 new DataNodeIterator(null);
36 @Test(expected=UnsupportedOperationException.class)
37 public void removeFromEmptyDataNodeContainer() {
38 dataNodeIterator.remove();
41 @Test(expected = NoSuchElementException.class)
42 public void tryNextOnEmptyDataContainer() {
43 dataNodeIterator.next();
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());