2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.sal.rest.doc.impl;
11 import com.google.common.base.Preconditions;
12 import org.json.JSONObject;
13 import org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
21 import java.util.HashSet;
25 public class ModelGeneratorTest {
27 private DocGenTestHelper helper;
28 private SchemaContext schemaContext;
31 public void setUp() throws Exception {
32 helper = new DocGenTestHelper();
34 schemaContext = new YangParserImpl().resolveSchemaContext(new HashSet<Module>(helper.getModules().values()));
38 public void testConvertToJsonSchema() throws Exception {
40 Preconditions.checkArgument(helper.getModules() != null, "No modules found");
42 ModelGenerator generator = new ModelGenerator();
44 for (Map.Entry<File, Module> m : helper.getModules().entrySet()) {
45 if (m.getKey().getAbsolutePath().endsWith("opflex.yang")) {
47 JSONObject jsonObject = generator.convertToJsonSchema(m.getValue(), schemaContext);
48 Assert.assertNotNull(jsonObject);