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.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.jupiter.api.Assertions.assertEquals;
13 import org.junit.jupiter.api.Test;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.MissingSubstatementException;
16 class SubstatementValidatorTest extends AbstractYangTest {
19 assertEquals(3, assertEffectiveModelDir("/augment-test/augment-in-augment").getModules().size());
23 void undesirableElementException() {
24 assertInvalidSubstatementExceptionDir("/substatement-validator/undesirable-element",
25 startsWith("TYPE is not valid for REVISION. Error in module undesirable "
26 + "(QNameModule{ns=urn:opendaylight.undesirable, rev=2015-11-11}) [at "));
30 void maximalElementCountException() {
31 assertInvalidSubstatementExceptionDir("/substatement-validator/maximal-element",
32 startsWith("Maximal count of DESCRIPTION for AUGMENT is 1, detected 2. Error in module baz "
33 + "(QNameModule{ns=urn:opendaylight.baz, rev=2015-11-11}) [at "));
37 void missingElementException() {
38 // FIXME: should be MissingSubstatementException?
39 assertSourceExceptionDir("/substatement-validator/missing-element",
40 startsWith("Missing prefix statement [at "));
45 assertEquals(1, assertEffectiveModelDir("/substatement-validator/empty-element").getModules().size());
50 assertExceptionDir("/substatement-validator/bug-4310", MissingSubstatementException.class,
51 startsWith("TYPE is missing TYPE. Minimal count is 1. Error in module bug4310 "
52 + "(QNameModule{ns=urn:opendaylight.bug4310}) [at "));