Integrate RestconfNormalizedNodeWriter
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / ErrorTagsTest.java
1 /*
2  * Copyright (c) 2021 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.nb.rfc8040;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11
12 import java.util.List;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.junit.jupiter.params.ParameterizedTest;
15 import org.junit.jupiter.params.provider.Arguments;
16 import org.junit.jupiter.params.provider.MethodSource;
17 import org.opendaylight.yangtools.yang.common.ErrorTag;
18
19 class ErrorTagsTest {
20     @ParameterizedTest(name = "{0} => {1}")
21     @MethodSource
22     void testStatusOf(final @NonNull String tagName, final int status) {
23         assertEquals(status, ErrorTagMapping.RFC8040.statusOf(new ErrorTag(tagName)).code());
24     }
25
26     static List<Arguments> testStatusOf() {
27         return List.of(
28             Arguments.of("in-use", 409),
29             Arguments.of("invalid-value", 400),
30             Arguments.of("too-big", 413),
31             Arguments.of("missing-attribute", 400),
32             Arguments.of("bad-attribute", 400),
33             Arguments.of("unknown-attribute", 400),
34             Arguments.of("missing-element", 400),
35             Arguments.of("bad-element", 400),
36             Arguments.of("unknown-element", 400),
37             Arguments.of("unknown-namespace", 400),
38             Arguments.of("access-denied", 403),
39             Arguments.of("lock-denied", 409),
40             Arguments.of("resource-denied", 409),
41             Arguments.of("rollback-failed", 500),
42             Arguments.of("data-exists", 409),
43             Arguments.of("data-missing", 409),
44             Arguments.of("operation-not-supported", 501),
45             Arguments.of("operation-failed", 500),
46             Arguments.of("partial-operation", 500),
47             Arguments.of("malformed-message", 400),
48             Arguments.of("resource-denied-transport", 503));
49     }
50 }