a76bb52bfe18112c52c41e73fdfab5bfac593a12
[ccsdk/sli.git] /
1 package org.onap.ccsdk.sli.plugins.restconfapicall;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertNull;
5
6 import org.junit.Test;
7 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
8 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
9 import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
10 import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
11
12 /*-
13  * ============LICENSE_START=======================================================
14  * ONAP: CCSDK
15  * ================================================================================
16  * Copyright (C) 2021 AT&T Intellectual Property. All rights
17  *                                              reserved.
18  * ================================================================================
19  * Licensed under the Apache License, Version 2.0 (the "License");
20  * you may not use this file except in compliance with the License.
21  * You may obtain a copy of the License at
22  * 
23  *      http://www.apache.org/licenses/LICENSE-2.0
24  * 
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS,
27  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  * ============LICENSE_END=========================================================
31  */
32
33 public class TestRestconfApiUtils {
34     @Test 
35     public void testGetSchemaCtxFromDir() throws SvcLogicException {
36
37         YangParserFactory factory = new YangParserFactoryImpl();
38         
39
40         // Test with valid subdirectories
41         EffectiveModelContext modelCtx = RestconfApiUtils.getSchemaCtxFromDir(factory, "src/test/test-yang");
42         assertNotNull(modelCtx);
43
44         // Test with directory with no yang
45         modelCtx = RestconfApiUtils.getSchemaCtxFromDir(factory, "src/test/java");
46         assertNotNull(modelCtx);
47
48         // Test with invalid directory
49         modelCtx = RestconfApiUtils.getSchemaCtxFromDir(factory, "no/such/directory");
50         assertNotNull(modelCtx);
51     }
52 }