Enforce InstanceIdentifier creation
[mdsal.git] / binding / mdsal-binding-dom-codec / src / test / java / org / opendaylight / mdsal / binding / dom / codec / impl / TopLevelContainerViaUsesTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.mdsal.binding.dom.codec.impl;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.test.top.via.uses.rev151112.OpendaylightBindingTopLevelViaUsesData;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.test.top.via.uses.rev151112.container.top.ContainerTop;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
18
19 public class TopLevelContainerViaUsesTest extends AbstractBindingCodecTest {
20     private static final InstanceIdentifier<ContainerTop> TOP_LEVEL_CONTAINER_FROM_USES =
21         InstanceIdentifier.builderOfInherited(OpendaylightBindingTopLevelViaUsesData.class, ContainerTop.class).build();
22
23     @Test
24     public void testBindingToDomFirst() {
25         final YangInstanceIdentifier yangII = codecContext.toYangInstanceIdentifier(TOP_LEVEL_CONTAINER_FROM_USES);
26         final PathArgument lastArg = yangII.getLastPathArgument();
27         assertEquals(ContainerTop.QNAME, lastArg.getNodeType());
28     }
29
30     @Test
31     public void testDomToBindingFirst() {
32         final YangInstanceIdentifier yangII = YangInstanceIdentifier.of(ContainerTop.QNAME);
33         final InstanceIdentifier<?> bindingII = codecContext.fromYangInstanceIdentifier(yangII);
34         assertEquals(TOP_LEVEL_CONTAINER_FROM_USES, bindingII);
35     }
36 }