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 org.junit.Test;
13 import org.opendaylight.yang.gen.v1.mdsal552.norev.Mdsal552Data.OutputA;
14 import org.opendaylight.yang.gen.v1.mdsal552.norev.RefTestOutput;
15 import org.opendaylight.yang.gen.v1.mdsal552.norev.RefTestOutputBuilder;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
19 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
20 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
22 public class Mdsal552Test extends AbstractBindingCodecTest {
23 private static final Absolute OUTPUT_PATH = Absolute.of(QName.create(RefTestOutput.QNAME, "ref_test"),
25 private static final QName OUTPUTREF = QName.create(RefTestOutput.QNAME, "outputref");
28 public void testLeafrefEnumerationToNormalized() {
29 assertEquals(Builders.containerBuilder()
30 .withNodeIdentifier(new NodeIdentifier(RefTestOutput.QNAME))
31 .withChild(ImmutableNodes.leafNode(OUTPUTREF, OutputA.DownTest.getName()))
33 codecContext.toNormalizedNodeRpcData(new RefTestOutputBuilder().setOutputref(OutputA.DownTest).build()));
37 public void testLeafrefEnumerationFromNormalized() {
38 assertEquals(new RefTestOutputBuilder().setOutputref(OutputA.DownTest).build(),
39 codecContext.fromNormalizedNodeRpcData(OUTPUT_PATH, Builders.containerBuilder()
40 .withNodeIdentifier(new NodeIdentifier(RefTestOutput.QNAME))
41 .withChild(ImmutableNodes.leafNode(OUTPUTREF, OutputA.DownTest.getName()))