783bc837e5abfb125bf733bab43fc51605447bed
[yangtools.git] / parser / 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.junit.Assert.assertThrows;
12 import static org.mockito.Mockito.mock;
13
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
17
18 public class QNameToStatementDefinitionMapTest {
19     private static final QName QNAME = QName.create("", "a");
20
21     private final QNameToStatementDefinitionMap map = new QNameToStatementDefinitionMap();
22     private final StatementSupport<?, ?, ?> support = mock(StatementSupport.class);
23
24     @Test
25     public void testPutNullNull() {
26         assertThrows(NullPointerException.class, () -> map.put(null, null));
27     }
28
29     @Test
30     public void testPutNullSome() {
31         assertThrows(NullPointerException.class, () -> map.put(null, mock(StatementSupport.class)));
32     }
33
34     @Test
35     public void testPutSomeNull() {
36         assertThrows(NullPointerException.class, () -> map.put(QName.create("", "a"), null));
37     }
38
39     @Test
40     public void testPut() {
41         map.put(QNAME, support);
42         assertSame(support, map.get(QNAME));
43     }
44 }