2 * Copyright (c) 2017 Pantheon Technologies 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
9 package org.opendaylight.mdsal.binding.javav2.runtime.context.util;
11 import static org.junit.Assert.assertNotNull;
14 import java.io.FileNotFoundException;
15 import java.net.URISyntaxException;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
19 import org.opendaylight.mdsal.gen.javav2.org.test.runtime.rev170710.data.MyCont;
20 import org.opendaylight.mdsal.gen.javav2.org.test.runtime.rev170710.data.my_cont.MyChoice;
21 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
23 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
25 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
27 public class BindingSchemaContextUtilsTest {
29 private SchemaContext schemaContext;
30 private DataNodeContainer myCont;
31 private ChoiceSchemaNode myChoice;
33 private static final InstanceIdentifier<MyCont> MY_CONT_NODE_PATH
34 = InstanceIdentifier.create(MyCont.class);
38 public void setup() throws URISyntaxException, FileNotFoundException, ReactorException {
39 schemaContext = YangParserTestUtils.parseYangSources(
40 new File(getClass().getResource("/yang/test-runtime.yang").toURI()));
41 myCont = (DataNodeContainer) schemaContext.getChildNodes().iterator().next();
42 myChoice = (ChoiceSchemaNode) myCont.getChildNodes().iterator().next();
46 public void utilTest() {
47 assertNotNull(BindingSchemaContextUtils.findDataNodeContainer(schemaContext, MY_CONT_NODE_PATH));
48 assertNotNull(BindingSchemaContextUtils.findInstantiatedChoice(myCont, MyChoice.class));
49 assertNotNull(BindingSchemaContextUtils.findInstantiatedCase(myChoice, myChoice.getCaseNodeByName("one")));