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.query.binding.adapter;
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;
23 public class QueryBuilderTest {
24 private static BindingCodecTree CODEC;
26 private final QueryFactory factory = new DefaultQueryFactory(CODEC);
29 public static void beforeClass() {
30 CODEC = new DefaultBindingCodecTreeFactory().create(BindingRuntimeHelpers.createRuntimeContext());
34 public void bar() throws QueryStructureException {
35 final QueryExpression<TopLevelList> query = factory.querySubtree(InstanceIdentifier.builder(Top.class).build())
36 .extractChild(TopLevelList.class)
38 .childObject(NestedList.class)
39 .leaf(NestedList::getName).contains("foo")
40 .and().leaf(TopLevelList::getName).valueEquals("bar")
44 // final Result<TopLevelList> result = query.getResult();
46 // final TopLevelList value = result.getValue();