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