blob: b674d26f509eb521dbf06161ba060bb960bd824f [file] [log] [blame]
Bharat saraswale707f032016-07-14 23:33:55 +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
17package org.onosproject.yangutils.plugin.manager;
18
19import java.io.IOException;
20
21import org.apache.maven.plugin.MojoExecutionException;
22import org.junit.Test;
23import org.onosproject.yangutils.parser.exceptions.ParserException;
24import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
Shankara-Huaweibdf24bb2016-08-02 18:13:13 +053025import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
Bharat saraswale707f032016-07-14 23:33:55 +053026
27import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
28
29/**
30 * Unit test case for typedef translator.
31 */
32public class TypeDefTranslatorTest {
33
34 private final YangUtilManager utilManager = new YangUtilManager();
35
36 /**
37 * Checks typedef translation should not result in any exception.
38 *
39 * @throws MojoExecutionException
40 */
41 @Test
42 public void processTypeDefTranslator() throws IOException, ParserException, MojoExecutionException {
43
Bharat saraswal6a5911f2016-08-02 18:43:16 +053044 String searchDir = "src/test/resources/typedefTranslator/without";
Bharat saraswale707f032016-07-14 23:33:55 +053045 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
46 utilManager.parseYangFileInfoSet();
47 utilManager.createYangNodeSet();
48 utilManager.resolveDependenciesUsingLinker();
49
50 YangPluginConfig yangPluginConfig = new YangPluginConfig();
51 yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
52 yangPluginConfig.setManagerCodeGenDir("target/typedefTranslator/");
53 utilManager.translateToJava(yangPluginConfig);
54
55 deleteDirectory("target/typedefTranslator/");
56 }
57
Bharat saraswal6a5911f2016-08-02 18:43:16 +053058 /**
59 * Checks typedef translation should not result in any exception.
60 *
61 * @throws MojoExecutionException
62 */
63 @Test
64 public void processTypeDefWithRestrictionsTranslator() throws IOException, ParserException, MojoExecutionException {
65
66 /*FIXME: After typedef with leafref is fixed.
67 String searchDir = "src/test/resources/typedefTranslator/with";
68 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
69 utilManager.parseYangFileInfoSet();
70 utilManager.createYangNodeSet();
71 utilManager.resolveDependenciesUsingLinker();
72
73 YangPluginConfig yangPluginConfig = new YangPluginConfig();
74 yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
75 yangPluginConfig.setManagerCodeGenDir("target/typedefTranslator/");
76 utilManager.translateToJava(yangPluginConfig);
77
78 deleteDirectory("target/typedefTranslator/");
79 */
80 }
Bharat saraswale707f032016-07-14 23:33:55 +053081}