Another round of Sonar warnings fixes
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / AbstractModelTest.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, 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.stmt;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.junit.jupiter.api.BeforeAll;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18
19 /**
20  * Abstract base class for tests of the model context available in {@code src/test/resources/model}.
21  */
22 public abstract class AbstractModelTest extends AbstractYangTest {
23     private static final QNameModule FOO_NS = QNameModule.of("urn:opendaylight.foo", "2013-02-27");
24     private static final QNameModule BAR_NS = QNameModule.of("urn:opendaylight.bar", "2013-07-03");
25     private static final QNameModule BAZ_NS = QNameModule.of("urn:opendaylight.baz", "2013-02-27");
26
27     static EffectiveModelContext CTX;
28     static Module FOO;
29     static Module BAR;
30     static Module BAZ;
31
32     @BeforeAll
33     static void beforeClass() {
34         CTX = assertEffectiveModelDir("/model");
35         assertEquals(3, CTX.getModules().size());
36
37         FOO = CTX.findModules("foo").iterator().next();
38         BAR = CTX.findModules("bar").iterator().next();
39         BAZ = CTX.findModules("baz").iterator().next();
40     }
41
42     static final @NonNull QName fooQName(final String localName) {
43         return QName.create(FOO_NS, localName);
44     }
45
46     static final @NonNull QName barQName(final String localName) {
47         return QName.create(BAR_NS, localName);
48     }
49
50     static final @NonNull QName bazQName(final String localName) {
51         return QName.create(BAZ_NS, localName);
52     }
53 }