use of org.opendaylight.yangtools.yang.xpath.api.YangLocationPath in project yangtools by opendaylight.
the class PathExpressionParserTest method testCurrentPredicateParsing.
@Test
public void testCurrentPredicateParsing() {
final YangLocationPath path = ((LocationPathSteps) parser.parseExpression(ctx, "/device_types/device_type[type = current()/../type_text]/desc").getSteps()).getLocationPath();
assertTrue(path.isAbsolute());
path.getSteps();
assertEquals(ImmutableList.of(YangXPathAxis.CHILD.asStep(UnresolvedQName.unqualified("device_types")), YangXPathAxis.CHILD.asStep(UnresolvedQName.unqualified("device_type"), ImmutableSet.of(YangBinaryOperator.EQUALS.exprWith(YangQNameExpr.of(UnresolvedQName.unqualified("type")), YangPathExpr.of(YangFunctionCallExpr.of(YangFunction.CURRENT.getIdentifier()), Relative.relative(YangXPathAxis.PARENT.asStep(), YangXPathAxis.CHILD.asStep(UnresolvedQName.unqualified("type_text"))))))), YangXPathAxis.CHILD.asStep(UnresolvedQName.unqualified("desc"))), path.getSteps());
}
use of org.opendaylight.yangtools.yang.xpath.api.YangLocationPath in project yangtools by opendaylight.
the class YT1060Test method before.
@Before
public void before() {
context = YangParserTestUtils.parseYangResourceDirectory("/yt1060");
final Module module = context.findModule(CONT.getModule()).get();
final ContainerSchemaNode cont = (ContainerSchemaNode) module.findDataChildByName(CONT).get();
final LeafSchemaNode leaf1 = (LeafSchemaNode) cont.findDataChildByName(LEAF1).get();
path = ((LeafrefTypeDefinition) leaf1.getType()).getPathStatement();
// Quick checks before we get to the point
final Steps pathSteps = path.getSteps();
assertThat(pathSteps, isA(LocationPathSteps.class));
final YangLocationPath locationPath = ((LocationPathSteps) pathSteps).getLocationPath();
assertTrue(locationPath.isAbsolute());
final ImmutableList<Step> steps = locationPath.getSteps();
assertEquals(2, steps.size());
steps.forEach(step -> assertThat(step, isA(ResolvedQNameStep.class)));
}
Aggregations