Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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 | |
| 17 | package org.onosproject.yangutils.translator.tojava.utils; |
| 18 | |
| 19 | import java.io.IOException; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 20 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 21 | import org.junit.Test; |
| 22 | import org.onosproject.yangutils.datamodel.YangNode; |
| 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
| 25 | |
| 26 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
| 27 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.clean; |
| 28 | |
| 29 | /** |
| 30 | * Unit tests for union translator. |
| 31 | */ |
| 32 | public final class UnionTranslatorTest { |
| 33 | |
| 34 | private final YangUtilsParserManager manager = new YangUtilsParserManager(); |
| 35 | |
| 36 | /** |
| 37 | * Checks union translation should not result in any exception. |
| 38 | */ |
| 39 | @Test |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 40 | public void processUnionTranslator() |
| 41 | throws IOException, ParserException { |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 42 | |
| 43 | clean("src/test/org/onosproject/yang"); |
| 44 | |
| 45 | YangNode node = manager.getDataModel("src/test/resources/UnionTranslator.yang"); |
| 46 | |
| 47 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
| 48 | yangPluginConfig.setCodeGenDir("target/UnionTestGenFile"); |
| 49 | |
| 50 | generateJavaCode(node, yangPluginConfig); |
| 51 | |
| 52 | clean("target/UnionTestGenFile"); |
| 53 | } |
| 54 | |
| 55 | // TODO enhance the test cases, after having a framework of translator test. |
| 56 | } |