Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-parser-spi / src / test / java / org / opendaylight / yangtools / yang / parser / spi / source / QNameToStatementDefinitionMapTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.parser.spi.source;
9
10 import static org.junit.Assert.assertSame;
11 import static org.mockito.Mockito.mock;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
16
17 public class QNameToStatementDefinitionMapTest {
18     private static final QName QNAME = QName.create("", "a");
19
20     private final QNameToStatementDefinitionMap map = new QNameToStatementDefinitionMap();
21     private final StatementSupport<?, ?, ?> support = mock(StatementSupport.class);
22
23     @Test(expected = NullPointerException.class)
24     public void testPutNullNull() {
25         map.put(null, null);
26     }
27
28     @Test(expected = NullPointerException.class)
29     public void testPutNullSome() {
30         map.put(null, mock(StatementSupport.class));
31     }
32
33     @Test(expected = NullPointerException.class)
34     public void testPutSomeNull() {
35         map.put(QName.create("", "a"), null);
36     }
37
38     @Test
39     public void testPut() {
40         map.put(QNAME, support);
41         assertSame(support, map.get(QNAME));
42     }
43 }