2 * Copyright (c) 2023 PANTHEON.tech, 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.restconf.nb.rfc8040.databind;
10 import static org.junit.Assert.assertThrows;
12 import org.junit.Test;
13 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
14 import org.opendaylight.restconf.nb.rfc8040.AbstractJukeboxTest;
15 import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 public class ResourceBodyTest extends AbstractJukeboxTest {
20 public void testValidTopLevelNodeName() {
21 ResourceBody.validTopLevelNodeName(GAP_IID.getLastPathArgument(), GAP_LEAF);
25 public void testValidTopLevelNodeNameWrongTopIdentifier() {
26 // FIXME: more asserts
27 assertThrows(RestconfDocumentedException.class,
28 () -> ResourceBody.validTopLevelNodeName(PLAYLIST_IID.getLastPathArgument(), GAP_LEAF));
32 public void testValidateListKeysEqualityInPayloadAndUri() {
33 final var path = YangInstanceIdentifier.builder()
36 .nodeWithKey(PLAYLIST_QNAME, NAME_QNAME, "name of band")
38 final var iidContext = InstanceIdentifierContext.ofLocalPath(JUKEBOX_SCHEMA, path);
39 ResourceBody.validateListKeysEqualityInPayloadAndUri(iidContext.getSchemaNode(), path, BAND_ENTRY);