2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.parser.spi.source;
10 import static org.junit.Assert.assertSame;
11 import static org.junit.Assert.assertThrows;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
21 public class QNameToStatementDefinitionMapTest {
22 private static final QName QNAME = QName.create("", "a");
24 private final QNameToStatementDefinitionMap map = new QNameToStatementDefinitionMap();
25 private final StatementSupport<?, ?, ?> support = mock(StatementSupport.class);
26 private final StatementDefinition definition = mock(StatementDefinition.class);
29 public void before() {
30 doReturn(definition).when(support).definition();
34 public void testPutNullNull() {
35 assertThrows(NullPointerException.class, () -> map.put(null, null));
39 public void testPutNullSome() {
40 assertThrows(NullPointerException.class, () -> map.put(null, support));
44 public void testPutSomeNull() {
45 assertThrows(NullPointerException.class, () -> map.put(QName.create("", "a"), null));
49 public void testPut() {
50 map.put(QNAME, support);
51 assertSame(definition, map.get(QNAME));
52 assertSame(support, map.getSupport(QNAME));