03b7fbb859b8abb7e2b2d84f4aef11ca06d480c7
[netconf.git] / restconf / restconf-openapi / src / test / java / org / opendaylight / restconf / openapi / OpenApiTestUtils.java
1 /*
2  * Copyright (c) 2022 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;
9
10 import java.util.List;
11 import java.util.Map;
12 import org.opendaylight.restconf.openapi.model.Parameter;
13 import org.opendaylight.restconf.openapi.model.Path;
14
15 public final class OpenApiTestUtils {
16
17     private OpenApiTestUtils() {
18         // Hidden on purpose
19     }
20
21     /**
22      * Get path parameters names for {@code path} for GET operation.
23      *
24      * @return {@link List} of parameters excluding `content` parameter
25      */
26     public static List<String> getPathGetParameters(final Map<String, Path> paths, final String path) {
27         return paths.get(path).get().parameters()
28             .stream()
29             .map(Parameter::name)
30             .filter(p -> !"content".equals(p))
31             .toList();
32     }
33
34     /**
35      * Get path parameters names for {@code path} for POST operation.
36      *
37      * @return {@link List} of parameters
38      */
39     public static List<String> getPathPostParameters(final Map<String, Path> paths, final String path) {
40         return paths.get(path).post().parameters()
41             .stream()
42             .map(Parameter::name)
43             .toList();
44     }
45 }