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.nb.rfc8040.rests.services.impl;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertTrue;
13 import java.util.List;
14 import java.util.Optional;
15 import org.junit.jupiter.api.DisplayName;
16 import org.junit.jupiter.api.Test;
17 import org.junit.jupiter.params.ParameterizedTest;
18 import org.junit.jupiter.params.provider.Arguments;
19 import org.junit.jupiter.params.provider.MethodSource;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
21 import org.opendaylight.yangtools.yang.common.Revision;
23 class RestconfSchemaSourceUrlProviderTest {
25 @DisplayName("Unsupported module-set name.")
26 void unsupportedModuleSet() {
27 final var urlProvider = new RestconfSchemaSourceUrlProvider();
28 final var result = urlProvider.getSchemaSourceUrl("some-module-set", "module", null);
29 assertTrue(result.isEmpty());
32 @ParameterizedTest(name = "Supported module-set name. URL: {2}")
33 @MethodSource("getSchemaSourceUrlArgs")
34 void getSchemaSourceUrl(final String moduleName, final Revision revision, final Uri expected) {
35 final var urlProvider = new RestconfSchemaSourceUrlProvider();
36 final var result = urlProvider.getSchemaSourceUrl("ODL_modules", moduleName, revision);
37 assertEquals(Optional.of(expected), result);
40 private static List<Arguments> getSchemaSourceUrlArgs() {
42 Arguments.of("odl-module", Revision.of("2023-02-23"),
43 new Uri("/rests/modules/odl-module?revision=2023-02-23")),
44 Arguments.of("module-no-revision", null, new Uri("/rests/modules/module-no-revision"))