e7d82499f0de57c857bd3a3eb0356aa57298ff24
[policy/engine.git] / PolicyEngineAPI / src / test / java / org / onap / policy / test / PolicyConfigStatusTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 2017 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.test;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.policy.api.PolicyConfigStatus;
30
31 /**
32  * The class <code>PolicyConfigStatusTest</code> contains tests for the class
33  * <code>{@link PolicyConfigStatus}</code>.
34  *
35  * @generatedBy CodePro at 6/1/16 1:41 PM
36  * @version $Revision: 1.0 $
37  */
38 public class PolicyConfigStatusTest {
39     /**
40      * Run the PolicyConfigStatus getStatus(String) method test.
41      *
42      * @throws Exception
43      *
44      * @generatedBy CodePro at 6/1/16 1:41 PM
45      */
46     @Test
47     public void testGetStatus_1() throws Exception {
48         final String configStatus = "";
49
50         final PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
51
52         // add additional test code here
53         assertNotNull(result);
54         assertEquals("not_found", result.toString());
55         assertEquals("CONFIG_NOT_FOUND", result.name());
56         assertEquals(1, result.ordinal());
57
58         assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, PolicyConfigStatus.create("retrieved"));
59     }
60
61     /**
62      * Run the PolicyConfigStatus getStatus(String) method test.
63      *
64      * @throws Exception
65      *
66      * @generatedBy CodePro at 6/1/16 1:41 PM
67      */
68     @Test
69     public void testGetStatus_2() throws Exception {
70         final String configStatus = "retrieved";
71
72         final PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
73
74         // add additional test code here
75         assertNotNull(result);
76         assertEquals("retrieved", result.toString());
77         assertEquals("CONFIG_RETRIEVED", result.name());
78         assertEquals(0, result.ordinal());
79     }
80
81     @Test
82     public void testCreate_EnumName_PolicyConfigStatusEnum() {
83         for (final PolicyConfigStatus policyConfigStatus : PolicyConfigStatus.values()) {
84             final PolicyConfigStatus actualPolicyConfigStatus = PolicyConfigStatus.create(policyConfigStatus.name());
85             assertEquals(policyConfigStatus, actualPolicyConfigStatus);
86             assertEquals(policyConfigStatus.toString(), actualPolicyConfigStatus.toString());
87         }
88     }
89
90     @Test
91     public void testCreate_StringValue_PolicyClassEnum() {
92         for (final PolicyConfigStatus policyConfigStatus : PolicyConfigStatus.values()) {
93             final PolicyConfigStatus actualPolicyClass = PolicyConfigStatus.create(policyConfigStatus.toString());
94             assertEquals(policyConfigStatus, actualPolicyClass);
95         }
96     }
97
98     @Test(expected = IllegalArgumentException.class)
99     public void testException() {
100         PolicyConfigStatus.create("foobar");
101     }
102
103     /**
104      * Launch the test.
105      *
106      * @param args
107      *            the command line arguments
108      *
109      * @generatedBy CodePro at 6/1/16 1:41 PM
110      */
111     public static void main(final String[] args) {
112         new org.junit.runner.JUnitCore().run(PolicyConfigStatusTest.class);
113     }
114 }