2 * Copyright (c) 2016 Cisco Systems, Inc. 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.parser.stmt.rfc7950;
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.CoreMatchers.startsWith;
12 import static org.hamcrest.MatcherAssert.assertThat;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertTrue;
16 import java.util.Collection;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
21 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
23 public class Bug6880Test extends AbstractYangTest {
25 public void valid10Test() {
26 final var context = assertEffectiveModel("/rfc7950/bug6880/foo.yang");
28 final DataSchemaNode findDataSchemaNode = context.findDataTreeChild(QName.create("foo", "my-leaf-list"))
30 assertThat(findDataSchemaNode, instanceOf(LeafListSchemaNode.class));
31 final LeafListSchemaNode myLeafList = (LeafListSchemaNode) findDataSchemaNode;
33 final Collection<? extends Object> defaults = myLeafList.getDefaults();
34 assertEquals(2, defaults.size());
35 assertTrue(defaults.contains("my-default-value-1") && defaults.contains("my-default-value-2"));
39 public void invalid10Test() {
40 assertInvalidSubstatementException(startsWith("DEFAULT is not valid for LEAF_LIST"),
41 "/rfc7950/bug6880/invalid10.yang");