Expand yang-data-api test suite
[yangtools.git] / yang / yang-data-api / src / test / java / org / opendaylight / yangtools / yang / data / api / PathArgumentListTest.java
1 /*
2  * Copyright (c) 2015 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.data.api;
9
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.fail;
12 import com.google.common.collect.UnmodifiableIterator;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15
16 public class PathArgumentListTest {
17     private static final class TestClass extends PathArgumentList {
18         @Override
19         public UnmodifiableIterator<PathArgument> iterator() {
20             return null;
21         }
22
23         @Override
24         public PathArgument get(final int index) {
25             return null;
26         }
27
28         @Override
29         public int size() {
30             return 0;
31         }
32     }
33
34     @Test
35     public void testIsEmpty() {
36         assertFalse(new TestClass().isEmpty());
37     }
38
39     @Test
40     public void testProtections() {
41         final PathArgumentList l = new TestClass();
42
43         try {
44             l.remove(null);
45             fail();
46         } catch (UnsupportedOperationException e) {
47         }
48
49         try {
50             l.addAll(null);
51             fail();
52         } catch (UnsupportedOperationException e) {
53         }
54
55         try {
56             l.removeAll(null);
57             fail();
58         } catch (UnsupportedOperationException e) {
59         }
60
61         try {
62             l.retainAll(null);
63             fail();
64         } catch (UnsupportedOperationException e) {
65         }
66
67         try {
68             l.clear();
69             fail();
70         } catch (UnsupportedOperationException e) {
71         }
72
73         try {
74             l.addAll(0, null);
75             fail();
76         } catch (UnsupportedOperationException e) {
77         }
78
79     }
80 }