Clean up RestconfDataServiceImplTest
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / AbstractJukeboxTest.java
1 /*
2  * Copyright (c) 2023 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.restconf.nb.rfc8040;
9
10 import org.junit.AfterClass;
11 import org.junit.BeforeClass;
12 import org.opendaylight.yangtools.yang.common.Decimal64;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
17 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
20 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
21 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
22 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
23 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
24
25 public abstract class AbstractJukeboxTest {
26     // container jukebox
27     protected static final QName JUKEBOX_QNAME =
28         QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
29     // container player
30     protected static final QName PLAYER_QNAME = QName.create(JUKEBOX_QNAME, "player");
31     // container library
32     protected static final QName LIBRARY_QNAME = QName.create(JUKEBOX_QNAME, "library");
33     // list artist
34     protected static final QName ARTIST_QNAME = QName.create(JUKEBOX_QNAME, "artist");
35     // list album
36     protected static final QName ALBUM_QNAME = QName.create(JUKEBOX_QNAME, "album");
37     // leaf name
38     protected static final QName NAME_QNAME = QName.create(JUKEBOX_QNAME, "name");
39     // leaf gap
40     protected static final QName GAP_QNAME = QName.create(JUKEBOX_QNAME, "gap");
41     // leaf playlist
42     protected static final QName PLAYLIST_QNAME = QName.create(JUKEBOX_QNAME, "playlist");
43     // leaf description
44     protected static final QName DESCRIPTION_QNAME = QName.create(JUKEBOX_QNAME, "description");
45
46     protected static final YangInstanceIdentifier JUKEBOX_IID = YangInstanceIdentifier.of(JUKEBOX_QNAME);
47     protected static final YangInstanceIdentifier PLAYLIST_IID =
48         YangInstanceIdentifier.of(JUKEBOX_QNAME, PLAYLIST_QNAME);
49
50     // instance identifier for accessing leaf node "gap"
51     protected static final YangInstanceIdentifier GAP_IID =
52         YangInstanceIdentifier.of(JUKEBOX_QNAME, PLAYER_QNAME, GAP_QNAME);
53
54     protected static final LeafNode<?> GAP_LEAF = ImmutableNodes.leafNode(GAP_QNAME, Decimal64.valueOf("0.2"));
55     protected static final ContainerNode CONT_PLAYER = Builders.containerBuilder()
56         .withNodeIdentifier(new NodeIdentifier(PLAYER_QNAME))
57         .withChild(GAP_LEAF)
58         .build();
59     protected static final ContainerNode EMPTY_JUKEBOX = Builders.containerBuilder()
60         .withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
61         .withChild(CONT_PLAYER)
62         .build();
63     protected static final MapEntryNode BAND_ENTRY = Builders.mapEntryBuilder()
64         .withNodeIdentifier(NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME, "name of band"))
65         .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name of band"))
66         .withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "band description"))
67         .build();
68
69     protected static EffectiveModelContext JUKEBOX_SCHEMA;
70
71     @BeforeClass
72     public static final void beforeClass() {
73         JUKEBOX_SCHEMA = YangParserTestUtils.parseYangResourceDirectory("/jukebox");
74     }
75
76     @AfterClass
77     public static final void afterClass() {
78         JUKEBOX_SCHEMA = null;
79     }
80 }