2 * Copyright (c) 2020 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.mdsal.binding.dom.codec.impl;
10 import static org.junit.Assert.assertEquals;
12 import java.io.IOException;
13 import org.junit.Test;
14 import org.opendaylight.mdsal.binding.dom.codec.test.AbstractBindingCodecTest;
15 import org.opendaylight.yang.gen.v1.mdsal552.norev.Mdsal552Data.OutputA;
16 import org.opendaylight.yang.gen.v1.mdsal552.norev.RefTestOutput;
17 import org.opendaylight.yang.gen.v1.mdsal552.norev.RefTestOutputBuilder;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
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.SchemaPath;
24 public class Mdsal552Test extends AbstractBindingCodecTest {
25 private static final SchemaPath OUTPUT_PATH = SchemaPath.create(true, QName.create(RefTestOutput.QNAME, "ref_test"),
27 private static final QName OUTPUTREF = QName.create(RefTestOutput.QNAME, "outputref");
30 public void testLeafrefEnumerationToNormalized() throws IOException {
31 assertEquals(Builders.containerBuilder()
32 .withNodeIdentifier(new NodeIdentifier(RefTestOutput.QNAME))
33 .withChild(ImmutableNodes.leafNode(OUTPUTREF, OutputA.DownTest.getName()))
35 registry.toNormalizedNodeRpcData(new RefTestOutputBuilder().setOutputref(OutputA.DownTest).build()));
39 public void testLeafrefEnumerationFromNormalized() throws IOException {
40 assertEquals(new RefTestOutputBuilder().setOutputref(OutputA.DownTest).build(),
41 registry.fromNormalizedNodeRpcData(OUTPUT_PATH, Builders.containerBuilder()
42 .withNodeIdentifier(new NodeIdentifier(RefTestOutput.QNAME))
43 .withChild(ImmutableNodes.leafNode(OUTPUTREF, OutputA.DownTest.getName()))