Bug 8622: convert sal-rest-docgen to Jackson
[netconf.git] / restconf / sal-rest-docgen / src / test / java / org / opendaylight / controller / sal / rest / doc / impl / ModelGeneratorTest.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.sal.rest.doc.impl;
10
11 import com.fasterxml.jackson.databind.node.ObjectNode;
12 import com.google.common.base.Preconditions;
13 import java.sql.Date;
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;
20
21
22 public class ModelGeneratorTest {
23
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;
29
30     @Before
31     public void setUp() throws Exception {
32         this.helper = new DocGenTestHelper();
33         this.helper.setUp();
34         this.schemaContext = this.helper.getSchemaContext();
35     }
36
37     @Test
38     public void testConvertToJsonSchema() throws Exception {
39
40         Preconditions.checkArgument(this.helper.getModules() != null, "No modules found");
41
42         final ModelGenerator generator = new ModelGenerator();
43
44         for (final Module m : this.helper.getModules()) {
45             if (m.getQNameModule().getNamespace().toString().equals(NAMESPACE)
46                     && m.getQNameModule().getRevision().equals(REVISION)) {
47
48                 final ObjectNode jsonObject = generator.convertToJsonSchema(m, this.schemaContext);
49                 Assert.assertNotNull(jsonObject);
50             }
51         }
52
53     }
54 }