Remove RestconfError.ErrorTag
[netconf.git] / restconf / restconf-common / src / test / java / org / opendaylight / restconf / common / 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.common;
9
10 import static java.util.Objects.requireNonNull;
11 import static org.junit.Assert.assertEquals;
12
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;
19
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[][] {
25             { "in-use", 409 },
26             { "invalid-value", 400 },
27             { "too-big", 413 },
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 }
46         });
47     }
48
49     private final String tagName;
50     private final int status;
51
52     public ErrorTagsTest(final String tagName, final int status) {
53         this.tagName = requireNonNull(tagName);
54         this.status = status;
55     }
56
57     @Test
58     public void testStatusOf() {
59         assertEquals(status, ErrorTags.statusOf(new ErrorTag(tagName)).getStatusCode());
60     }
61 }