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;
13 import org.json.JSONObject;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.netconf.sal.rest.doc.impl.ModelGenerator;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 public class ModelGeneratorTest {
24 private static final String NAMESPACE = "urn:opendaylight:groupbasedpolicy:opflex";
25 private static final String STRING_DATE = "2014-05-28";
26 private static final Date REVISION = Date.valueOf(STRING_DATE);
27 private DocGenTestHelper helper;
28 private SchemaContext schemaContext;
31 public void setUp() throws Exception {
32 this.helper = new DocGenTestHelper();
34 this.schemaContext = this.helper.getSchemaContext();
38 public void testConvertToJsonSchema() throws Exception {
40 Preconditions.checkArgument(this.helper.getModules() != null, "No modules found");
42 final ModelGenerator generator = new ModelGenerator();
44 for (final Module m : this.helper.getModules()) {
45 if (m.getQNameModule().getNamespace().toString().equals(NAMESPACE)
46 && m.getQNameModule().getRevision().equals(REVISION)) {
48 final JSONObject jsonObject = generator.convertToJsonSchema(m, this.schemaContext);
49 Assert.assertNotNull(jsonObject);