OpenApi: Rework tests to parameterized
[netconf.git] / restconf / restconf-openapi / src / test / java / org / opendaylight / restconf / openapi / impl / ToasterDocumentTest.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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 package org.opendaylight.restconf.openapi.impl;
9
10 import org.junit.jupiter.api.BeforeAll;
11 import org.junit.jupiter.api.Test;
12 import org.skyscreamer.jsonassert.JSONAssert;
13
14 public class ToasterDocumentTest extends AbstractDocumentTest {
15     private static final String TOASTER = "toaster";
16     private static final String TOASTER_REV = "2009-11-20";
17
18     @BeforeAll
19     public static void beforeClass() {
20         initializeClass("/toaster-document/");
21     }
22
23     /**
24      * Tests the swagger document that is result of the call to the '/single' endpoint.
25      */
26     @Test
27     public void getAllModulesDocTest() throws Exception {
28         final var jsonControllerDoc = getAllModulesDoc();
29         final var expectedJson = getExpectedDoc("toaster-document/controller-all.json");
30         JSONAssert.assertEquals(expectedJson, jsonControllerDoc, IGNORE_ORDER);
31     }
32
33     /**
34      * Tests the swagger document that is result of the call to the '/toaster(2009-11-20)' endpoint.
35      *
36      * <p>
37      * Model toaster is used for test correct generating of complex openapi object.
38      */
39     @Test
40     public void getDocByModuleTest() throws Exception {
41         final var jsonControllerDoc = getDocByModule(TOASTER, TOASTER_REV);
42         final var expectedJson = getExpectedDoc("toaster-document/controller-toaster.json");
43         JSONAssert.assertEquals(expectedJson, jsonControllerDoc, IGNORE_ORDER);
44     }
45
46     /**
47      * Tests the swagger document that is result of the call to the '/mounts/1' endpoint.
48      */
49     @Test
50     public void getMountDocTest() throws Exception {
51         final var jsonDeviceDoc = getMountDoc();
52         final var expectedJson = getExpectedDoc("toaster-document/device-all.json");
53         JSONAssert.assertEquals(expectedJson, jsonDeviceDoc, IGNORE_ORDER);
54     }
55
56     /**
57      * Tests the swagger document that is result of the call to the '/mounts/1/toaster(2009-11-20)' endpoint.
58      *
59      * <p>
60      * Model toaster is used for test correct generating of complex openapi object.
61      */
62     @Test
63     public void getMountDocByModuleTest() throws Exception {
64         final var jsonDeviceDoc = getMountDocByModule(TOASTER, TOASTER_REV);
65         final var expectedJson = getExpectedDoc("toaster-document/device-toaster.json");
66         JSONAssert.assertEquals(expectedJson, jsonDeviceDoc, IGNORE_ORDER);
67     }
68 }