2 * Copyright (c) 2021 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.common;
10 import static java.util.Objects.requireNonNull;
11 import static org.junit.Assert.assertEquals;
13 import java.util.Arrays;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.junit.runners.Parameterized;
17 import org.junit.runners.Parameterized.Parameters;
18 import org.opendaylight.yangtools.yang.common.ErrorTag;
20 @RunWith(Parameterized.class)
21 public class ErrorTagsTest {
22 @Parameters(name = "{0} => {1}")
23 public static Iterable<Object[]> data() {
24 return Arrays.asList(new Object[][] {
26 { "invalid-value", 400 },
28 { "missing-attribute", 400 },
29 { "bad-attribute", 400 },
30 { "unknown-attribute", 400 },
31 { "missing-element", 400 },
32 { "bad-element", 400 },
33 { "unknown-element", 400 },
34 { "unknown-namespace", 400 },
35 { "access-denied", 403 },
36 { "lock-denied", 409 },
37 { "resource-denied", 409 },
38 { "rollback-failed", 500 },
39 { "data-exists", 409 },
40 { "data-missing", 409 },
41 { "operation-not-supported", 501 },
42 { "operation-failed", 500 },
43 { "partial-operation", 500 },
44 { "malformed-message", 400 },
45 { "resource-denied-transport", 503 }
49 private final String tagName;
50 private final int status;
52 public ErrorTagsTest(final String tagName, final int status) {
53 this.tagName = requireNonNull(tagName);
58 public void testStatusOf() {
59 assertEquals(status, ErrorTags.statusOf(new ErrorTag(tagName)).getStatusCode());