Cleanup BindingRuntimeHelpers
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / query / binding / adapter / QueryBuilderTest.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.query.binding.adapter;
9
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
13 import org.opendaylight.mdsal.binding.api.query.QueryExpression;
14 import org.opendaylight.mdsal.binding.api.query.QueryFactory;
15 import org.opendaylight.mdsal.binding.api.query.QueryStructureException;
16 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
17 import org.opendaylight.mdsal.binding.dom.codec.impl.DefaultBindingCodecTreeFactory;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22
23 public class QueryBuilderTest {
24     private static BindingCodecTree CODEC;
25
26     private final QueryFactory factory = new DefaultQueryFactory(CODEC);
27
28     @BeforeClass
29     public static void beforeClass() {
30         CODEC = new DefaultBindingCodecTreeFactory().create(BindingRuntimeHelpers.createRuntimeContext());
31     }
32
33     @Test
34     public void bar() throws QueryStructureException {
35         final QueryExpression<TopLevelList> query = factory.querySubtree(InstanceIdentifier.builder(Top.class).build())
36                 .extractChild(TopLevelList.class)
37                 .matching()
38                     .childObject(NestedList.class)
39                     .leaf(NestedList::getName).contains("foo")
40                     .and().leaf(TopLevelList::getName).valueEquals("bar")
41                 .build();
42 //
43 //        // Execution start
44 //        final Result<TopLevelList> result = query.getResult();
45 //        // Execution fetch
46 //        final TopLevelList value = result.getValue();
47     }
48 }