2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.restconf.openapi.impl;
10 import java.util.stream.Stream;
11 import org.junit.jupiter.api.BeforeAll;
12 import org.junit.jupiter.api.Test;
13 import org.junit.jupiter.params.ParameterizedTest;
14 import org.junit.jupiter.params.provider.Arguments;
15 import org.junit.jupiter.params.provider.MethodSource;
16 import org.skyscreamer.jsonassert.JSONAssert;
18 class OperationalDocumentTest extends AbstractDocumentTest {
20 * Model action-types is used for test correct generating of action statements for openapi.
22 private static final String ACTION_TYPES = "action-types";
24 * Model operational is used for test correct generating of operational parameters for openapi.
26 private static final String OPERATIONAL = "operational";
29 static void beforeAll() {
30 initializeClass("/operational/");
34 * Tests the swagger document that is result of the call to the '/single' endpoint.
37 void getAllModulesDocTest() throws Exception {
38 final var expectedJson = getExpectedDoc("operational-document/controller-all.json");
39 final var allModulesDoc = getAllModulesDoc(0);
40 JSONAssert.assertEquals(expectedJson, allModulesDoc, IGNORE_ORDER);
44 * Tests the swagger document that is result of the call to the '/moduleName' endpoint.
48 void getDocByModuleTest(final String moduleName, final String revision, final String jsonPath)
50 final var expectedJson = getExpectedDoc("operational-document/" + jsonPath);
51 final var moduleDoc = getDocByModule(moduleName, revision, 0);
52 JSONAssert.assertEquals(expectedJson, moduleDoc, IGNORE_ORDER);
55 private static Stream<Arguments> getDocByModuleTest() {
56 // moduleName, revision, jsonPath
58 Arguments.of(ACTION_TYPES, null, "controller-action-types.json"),
59 Arguments.of(OPERATIONAL, null, "controller-operational.json")
64 * Tests the swagger document that is result of the call to the '/mounts/1' endpoint.
67 void getMountDocTest() throws Exception {
68 final var expectedJson = getExpectedDoc("operational-document/device-all.json");
69 final var allModulesDoc = getMountDoc(0);
70 JSONAssert.assertEquals(expectedJson, allModulesDoc, IGNORE_ORDER);
74 * Tests the swagger document that is result of the call to the '/mounts/1/moduleName' endpoint.
78 void getMountDocByModuleTest(final String moduleName, final String revision, final String jsonPath)
80 final var expectedJson = getExpectedDoc("operational-document/" + jsonPath);
81 final var moduleDoc = getMountDocByModule(moduleName, revision, 0);
82 JSONAssert.assertEquals(expectedJson, moduleDoc, IGNORE_ORDER);
85 private static Stream<Arguments> getMountDocByModuleTest() {
86 // moduleName, revision, jsonPath
88 Arguments.of(ACTION_TYPES, null, "device-action-types.json"),
89 Arguments.of(OPERATIONAL, null, "device-operational.json")