blob: ef1b774020d46ba750b88cbc2cb480160647fbc3 [file] [log] [blame]
Vidyashree Rama7142d9c2016-04-26 15:06:06 +05301/*
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
Gaurav Agrawalc5f63272016-06-16 13:09:53 +053017package org.onosproject.yangutils.plugin.manager;
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053018
19import java.io.IOException;
Bharat saraswal33dfa012016-05-17 19:59:16 +053020
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053021import org.junit.Test;
22import org.onosproject.yangutils.datamodel.YangNode;
23import org.onosproject.yangutils.parser.exceptions.ParserException;
24import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
Shankara-Huaweibdf24bb2016-08-02 18:13:13 +053025import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053026
27import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
VinodKumarS-Huaweicb3a1f52016-05-10 17:58:57 +053028import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053029
30/**
31 * Unit tests for choice-case translator.
32 */
33public final class ChoiceCaseTranslatorTest {
34
35 private final YangUtilsParserManager manager = new YangUtilsParserManager();
36
37 /**
38 * Checks choice-case translation should not result in any exception.
39 */
40 @Test
41 public void processChoiceCaseTranslator() throws IOException, ParserException {
42
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053043 YangNode node = manager.getDataModel("src/test/resources/ChoiceCaseTranslator.yang");
44
45 YangPluginConfig yangPluginConfig = new YangPluginConfig();
Bharat saraswal991f6882016-06-17 12:16:25 +053046 yangPluginConfig.setCodeGenDir("target/ChoiceCaseTestGenFile/");
Bharat saraswalb1170bd2016-07-14 13:26:18 +053047 yangPluginConfig.setManagerCodeGenDir("target/ChoiceCaseTestGenFile/");
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053048
Bharat saraswal33dfa012016-05-17 19:59:16 +053049 generateJavaCode(node, yangPluginConfig);
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053050
Bharat saraswal991f6882016-06-17 12:16:25 +053051 deleteDirectory("target/ChoiceCaseTestGenFile/");
Vidyashree Rama7142d9c2016-04-26 15:06:06 +053052 }
53 // TODO enhance the test cases, after having a framework of translator test.
VinodKumarS-Huaweicb3a1f52016-05-10 17:58:57 +053054}