2 * Copyright (c) 2023 Verizon 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.yangtools.yang.stmt;
10 import static org.hamcrest.MatcherAssert.assertThat;
11 import static org.hamcrest.Matchers.hasItem;
12 import static org.hamcrest.Matchers.instanceOf;
13 import static org.hamcrest.Matchers.not;
14 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import java.util.List;
18 import org.junit.jupiter.api.Test;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
23 class YT1485Test extends AbstractYangTest {
24 private static final QName FOO = QName.create("urn:foo", "foo");
27 void testLeafFooFeatureSupported() {
28 assertEquals(List.of(), assertFoo("leaf", null).effectiveSubstatements());
32 void testLeafFooFeatureNotSupported() {
33 assertEquals(List.of(), assertFoo("leaf", Set.of()).effectiveSubstatements());
37 void testAugmentFooFeatureSupported() {
38 assertThat(assertFoo("augment", null).effectiveSubstatements(),
39 not(hasItem(instanceOf(LeafEffectiveStatement.class))));
43 void testAugmentFooFeatureNotSupported() {
44 assertEquals(List.of(), assertFoo("augment", Set.of()).effectiveSubstatements());
47 private static ContainerEffectiveStatement assertFoo(final String dirName,
48 final Set<QName> supportedFeatures) {
49 final var foo = assertEffectiveModelDir("/bugs/YT1485/" + dirName, supportedFeatures)
50 .findModuleStatement(FOO).orElseThrow()
51 .findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
52 assertEquals(FOO, foo.argument());