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.stmt;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertNotNull;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 class ChoiceStmtTest extends AbstractModelTest {
20 void choiceAndCaseTest() {
21 final var container = assertInstanceOf(ContainerSchemaNode.class, FOO.getDataChildByName(fooQName("transfer")));
22 final var choice = assertInstanceOf(ChoiceSchemaNode.class, container.getDataChildByName(fooQName("how")));
23 assertEquals(5, choice.getCases().size());
25 var caseNode = choice.findCaseNodes("input").iterator().next();
26 assertNotNull(caseNode);
27 caseNode = choice.findCaseNodes("output").iterator().next();
28 assertNotNull(caseNode);
29 caseNode = choice.findCaseNodes("interval").iterator().next();
30 assertNotNull(caseNode);
31 caseNode = choice.findCaseNodes("daily").iterator().next();
32 assertNotNull(caseNode);
33 caseNode = choice.findCaseNodes("manual").iterator().next();
34 assertNotNull(caseNode);
35 assertEquals("interval", choice.getDefaultCase().orElseThrow().getQName().getLocalName());