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