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
8 package org.opendaylight.controller.sal.rest.doc.impl;
10 import static org.junit.Assert.assertTrue;
12 import com.fasterxml.jackson.databind.node.ObjectNode;
13 import java.util.Optional;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl;
18 import org.opendaylight.netconf.sal.rest.doc.impl.DefinitionGenerator;
19 import org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames;
20 import org.opendaylight.yangtools.yang.common.Revision;
21 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
25 public final class SwaggerObjectTest {
26 private EffectiveModelContext context;
30 context = YangParserTestUtils.parseYangResourceDirectory("/yang");
34 public void testConvertToJsonSchema() throws Exception {
35 final Optional<? extends Module> module = context.findModule("opflex", Revision.of("2014-05-28"));
36 assertTrue("Desired module not found", module.isPresent());
37 final DefinitionGenerator generator = new DefinitionGenerator();
38 final ObjectNode jsonObject = generator.convertToJsonSchema(module.get(), context,
39 new DefinitionNames(), ApiDocServiceImpl.OAversion.V2_0, true);
40 Assert.assertNotNull(jsonObject);
44 public void testActionTypes() throws Exception {
45 final Optional<? extends Module> module = context.findModule("action-types");
46 assertTrue("Desired module not found", module.isPresent());
47 final DefinitionGenerator generator = new DefinitionGenerator();
48 final ObjectNode jsonObject = generator.convertToJsonSchema(module.get(), context,
49 new DefinitionNames(), ApiDocServiceImpl.OAversion.V2_0, true);
50 Assert.assertNotNull(jsonObject);
54 public void testStringTypes() throws Exception {
55 final Optional<? extends Module> module = context.findModule("string-types");
56 assertTrue("Desired module not found", module.isPresent());
57 final DefinitionGenerator generator = new DefinitionGenerator();
58 final ObjectNode jsonObject = generator.convertToJsonSchema(module.get(), context, new DefinitionNames(),
59 ApiDocServiceImpl.OAversion.V2_0, true);
61 Assert.assertNotNull(jsonObject);