JUnit test for policy/engine PolicyEngineAPI
[policy/engine.git] / PolicyEngineAPI / src / test / java / org / onap / policy / test / PolicyResponseStatusTest.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.PolicyResponseStatus;
30
31 /**
32  * The class <code>PolicyResponseStatusTest</code> contains tests for the class
33  * <code>{@link PolicyResponseStatus}</code>.
34  *
35  * @generatedBy CodePro at 6/1/16 1:41 PM
36  * @version $Revision: 1.0 $
37  */
38 public class PolicyResponseStatusTest {
39     /**
40      * Run the PolicyResponseStatus 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 responseStatus = "";
49
50         final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
51
52         // add additional test code here
53         assertNotNull(result);
54         assertEquals("no_action", result.toString());
55         assertEquals("NO_ACTION_REQUIRED", result.name());
56         assertEquals(0, result.ordinal());
57     }
58
59     @Test
60     public void testCreate_EnumName_PolicyResponseStatusEnum() {
61         for (final PolicyResponseStatus policyResponseStatus : PolicyResponseStatus.values()) {
62             final PolicyResponseStatus actualPolicyResponseStatus = PolicyResponseStatus
63                     .create(policyResponseStatus.name());
64             assertEquals(policyResponseStatus, actualPolicyResponseStatus);
65             assertEquals(policyResponseStatus.toString(), actualPolicyResponseStatus.toString());
66         }
67     }
68
69     @Test
70     public void testCreate_StringValue_PolicyResponseStatusEnum() {
71         for (final PolicyResponseStatus policyResponseStatus : PolicyResponseStatus.values()) {
72             final PolicyResponseStatus actualPolicyResponseStatus = PolicyResponseStatus
73                     .create(policyResponseStatus.toString());
74             assertEquals(policyResponseStatus, actualPolicyResponseStatus);
75         }
76     }
77
78     /**
79      * Run the PolicyResponseStatus getStatus(String) method test.
80      *
81      * @throws Exception
82      *
83      * @generatedBy CodePro at 6/1/16 1:41 PM
84      */
85     @Test
86     public void testGetStatus_2() throws Exception {
87         final String responseStatus = "action_advised";
88
89         final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
90
91         // add additional test code here
92         assertNotNull(result);
93         assertEquals("action_advised", result.toString());
94         assertEquals("ACTION_ADVISED", result.name());
95         assertEquals(1, result.ordinal());
96     }
97
98     /**
99      * Run the PolicyResponseStatus getStatus(String) method test.
100      *
101      * @throws Exception
102      *
103      * @generatedBy CodePro at 6/1/16 1:41 PM
104      */
105     @Test
106     public void testGetStatus_3() throws Exception {
107         final String responseStatus = "action_taken";
108
109         final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
110
111         // add additional test code here
112         assertNotNull(result);
113         assertEquals("action_taken", result.toString());
114         assertEquals("ACTION_TAKEN", result.name());
115         assertEquals(2, result.ordinal());
116     }
117
118     /**
119      * Run the String toString() method test.
120      *
121      * @throws Exception
122      *
123      * @generatedBy CodePro at 6/1/16 1:41 PM
124      */
125     @Test
126     public void testToString_1() throws Exception {
127         final PolicyResponseStatus fixture = PolicyResponseStatus.ACTION_ADVISED;
128
129         final String result = fixture.toString();
130
131         // add additional test code here
132         assertEquals("action_advised", result);
133
134         assertEquals(PolicyResponseStatus.ACTION_ADVISED, PolicyResponseStatus.create("ACTION_ADVISED"));
135     }
136
137     @Test(expected = IllegalArgumentException.class)
138     public void testTheRest() {
139         PolicyResponseStatus.create("foobar");
140     }
141
142     /**
143      * Perform pre-test initialization.
144      *
145      * @throws Exception
146      *             if the initialization fails for some reason
147      *
148      * @generatedBy CodePro at 6/1/16 1:41 PM
149      */
150     @Before
151     public void setUp() throws Exception {
152         // add additional set up code here
153     }
154
155     /**
156      * Perform post-test clean-up.
157      *
158      * @throws Exception
159      *             if the clean-up fails for some reason
160      *
161      * @generatedBy CodePro at 6/1/16 1:41 PM
162      */
163     @After
164     public void tearDown() throws Exception {
165         // Add additional tear down code here
166     }
167
168     /**
169      * Launch the test.
170      *
171      * @param args
172      *            the command line arguments
173      *
174      * @generatedBy CodePro at 6/1/16 1:41 PM
175      */
176     public static void main(final String[] args) {
177         new org.junit.runner.JUnitCore().run(PolicyResponseStatusTest.class);
178     }
179 }