2 * Copyright (c) 2015 Cisco Systems, Inc. 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.test;
10 import static org.junit.Assert.assertEquals;
12 import javassist.ClassPool;
13 import org.junit.Test;
14 import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
15 import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
16 import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.test.top.via.uses.rev151112.container.top.ContainerTop;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
22 public class TopLevelContainerViaUsesTest extends AbstractBindingRuntimeTest {
24 private static final InstanceIdentifier<ContainerTop> TOP_LEVEL_CONTAINER_FROM_USES =
25 InstanceIdentifier.create(ContainerTop.class);
27 private BindingNormalizedNodeCodecRegistry registry;
32 final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
33 registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
34 registry.onBindingRuntimeContextUpdated(getRuntimeContext());
38 public void testBindingToDomFirst() {
39 final YangInstanceIdentifier yangII = registry.toYangInstanceIdentifier(TOP_LEVEL_CONTAINER_FROM_USES);
40 final PathArgument lastArg = yangII.getLastPathArgument();
41 assertEquals(ContainerTop.QNAME, lastArg.getNodeType());
46 public void testDomToBindingFirst() {
47 final YangInstanceIdentifier yangII = YangInstanceIdentifier.of(ContainerTop.QNAME);
48 InstanceIdentifier<?> bindingII = registry.fromYangInstanceIdentifier(yangII);
49 assertEquals(TOP_LEVEL_CONTAINER_FROM_USES, bindingII);