JUnit test for policy/engine PolicyEngineAPI
[policy/engine.git] / PolicyEngineAPI / src / test / java / org / onap / policy / test / PolicyDecisionTest.java
index a639170..a63094a 100644 (file)
 
 package org.onap.policy.test;
 
-import org.junit.*;
-import org.onap.policy.api.PolicyDecision;
+import static org.junit.Assert.assertEquals;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyDecision;
 
 /**
- * The class <code>PolicyDecisionTest</code> contains tests for the class <code>{@link PolicyDecision}</code>.
+ * The class <code>PolicyDecisionTest</code> contains tests for the class
+ * <code>{@link PolicyDecision}</code>.
  *
  * @generatedBy CodePro at 6/1/16 1:41 PM
  * @version $Revision: 1.0 $
  */
 public class PolicyDecisionTest {
-       /**
-        * Run the String toString() method test.
-        *
-        * @throws Exception
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Test
-       public void testToString_1()
-               throws Exception {
-               PolicyDecision fixture = PolicyDecision.DENY;
-
-               String result = fixture.toString();
 
-               // add additional test code here
-               assertEquals("deny", result);
-               
-               assertEquals(PolicyDecision.PERMIT, PolicyDecision.create(PolicyDecision.PERMIT.name()));
-       }
-       
-       @Test(expected = IllegalArgumentException.class)
-       public void testException() {
-               PolicyDecision.create("foobar");
-       }
+    @Test
+    public void testCreate_EnumName_PolicyDecisionEnum() {
+        for (final PolicyDecision policyDecision : PolicyDecision.values()) {
+            final PolicyDecision actualPolicyDecision = PolicyDecision.create(policyDecision.name());
+            assertEquals(policyDecision, actualPolicyDecision);
+            assertEquals(policyDecision.toString(), actualPolicyDecision.toString());
+        }
+    }
 
-       /**
-        * Perform pre-test initialization.
-        *
-        * @throws Exception
-        *         if the initialization fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @Before
-       public void setUp()
-               throws Exception {
-               // add additional set up code here
-       }
+    @Test
+    public void testCreate_StringValue_PolicyDecisionEnum() {
+        for (final PolicyDecision policyDecision : PolicyDecision.values()) {
+            final PolicyDecision autalPolicyDecision = PolicyDecision.create(policyDecision.toString());
+            assertEquals(policyDecision, autalPolicyDecision);
+        }
+    }
 
-       /**
-        * Perform post-test clean-up.
-        *
-        * @throws Exception
-        *         if the clean-up fails for some reason
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       @After
-       public void tearDown()
-               throws Exception {
-               // Add additional tear down code here
-       }
+    @Test(expected = IllegalArgumentException.class)
+    public void testException() {
+        PolicyDecision.create("foobar");
+    }
 
-       /**
-        * Launch the test.
-        *
-        * @param args the command line arguments
-        *
-        * @generatedBy CodePro at 6/1/16 1:41 PM
-        */
-       public static void main(String[] args) {
-               new org.junit.runner.JUnitCore().run(PolicyDecisionTest.class);
-       }
+    /**
+     * Launch the test.
+     *
+     * @param args
+     *            the command line arguments
+     *
+     * @generatedBy CodePro at 6/1/16 1:41 PM
+     */
+    public static void main(final String[] args) {
+        new org.junit.runner.JUnitCore().run(PolicyDecisionTest.class);
+    }
 }