blob: 8226442f5f077afebad374eef500a805ad2c9e50 [file] [log] [blame]
Gaurav Agrawala04483c2016-02-13 14:23:40 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.parser.impl.listeners;
18
19import org.junit.Test;
20import org.onosproject.yangutils.datamodel.YangModule;
21import org.onosproject.yangutils.datamodel.YangNode;
22import org.onosproject.yangutils.parser.exceptions.ParserException;
23import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
24
25import java.io.IOException;
26
27import static org.hamcrest.core.Is.is;
28import static org.junit.Assert.assertThat;
29
30/**
31 * Test cases for testing revision listener functionality.
32 */
33public class RevisionListenerTest {
34
35 private final YangUtilsParserManager manager = new YangUtilsParserManager();
36
37 /**
38 * Checks if revision doesn't have optional parameters "revision and
39 * description".
40 */
41 @Test
42 public void processRevisionNoOptionalParameter() throws IOException, ParserException {
43
44 YangNode node = manager.getDataModel("src/test/resources/RevisionNoOptionalParameter.yang");
45
46 // Checks for the version value in data model tree.
47 assertThat(((YangModule) node).getRevision().getRevDate(), is("2016-02-03"));
48 }
49
50 /**
51 * Checks if the syntax of revision is correct.
52 */
53 @Test(expected = ParserException.class)
54 public void processRevisionInValidSyntax() throws IOException, ParserException {
55
56 YangNode node = manager.getDataModel("src/test/resources/RevisionInValidSyntax.yang");
57 }
58
59 /**
60 * Checks if the correct order is followed.
61 */
62 @Test(expected = ParserException.class)
63 public void processRevisionInValidOrder() throws IOException, ParserException {
64
65 YangNode node = manager.getDataModel("src/test/resources/RevisionInValidOrder.yang");
66 }
67}