2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.appc;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNull;
27 import org.junit.Test;
29 public class EnumsTest {
32 public void testResponseCode() {
33 assertEquals(5, ResponseCode.values().length);
35 assertNull(ResponseCode.toResponseCode(0));
37 assertEquals(ResponseCode.ACCEPT, ResponseCode.toResponseCode(100));
38 assertEquals(ResponseCode.ERROR, ResponseCode.toResponseCode(200));
39 assertEquals(ResponseCode.REJECT, ResponseCode.toResponseCode(300));
40 assertEquals(ResponseCode.SUCCESS, ResponseCode.toResponseCode(400));
41 assertEquals(ResponseCode.FAILURE, ResponseCode.toResponseCode(500));
43 assertEquals(100, ResponseCode.ACCEPT.getValue());
44 assertEquals(200, ResponseCode.ERROR.getValue());
45 assertEquals(300, ResponseCode.REJECT.getValue());
46 assertEquals(400, ResponseCode.SUCCESS.getValue());
47 assertEquals(500, ResponseCode.FAILURE.getValue());
49 assertEquals("100", ResponseCode.ACCEPT.toString());
50 assertEquals("200", ResponseCode.ERROR.toString());
51 assertEquals("300", ResponseCode.REJECT.toString());
52 assertEquals("400", ResponseCode.SUCCESS.toString());
53 assertEquals("500", ResponseCode.FAILURE.toString());
57 public void testResponseValue() {
58 assertEquals(5, ResponseValue.values().length);
60 assertNull(ResponseValue.toResponseValue("Dorothy"));
61 assertNull(ResponseValue.toResponseValue(null));
63 assertEquals(ResponseValue.ACCEPT, ResponseValue.toResponseValue("ACCEPT"));
64 assertEquals(ResponseValue.ERROR, ResponseValue.toResponseValue("ERROR"));
65 assertEquals(ResponseValue.REJECT, ResponseValue.toResponseValue("REJECT"));
66 assertEquals(ResponseValue.SUCCESS, ResponseValue.toResponseValue("SUCCESS"));
67 assertEquals(ResponseValue.FAILURE, ResponseValue.toResponseValue("FAILURE"));
69 assertEquals("ACCEPT", ResponseValue.ACCEPT.toString());
70 assertEquals("ERROR", ResponseValue.ERROR.toString());
71 assertEquals("REJECT", ResponseValue.REJECT.toString());
72 assertEquals("SUCCESS", ResponseValue.SUCCESS.toString());
73 assertEquals("FAILURE", ResponseValue.FAILURE.toString());