Sonar Fixes policy/models, removing model-yaml
[policy/models.git] / models-interactions / model-yaml / src / test / java / org / onap / policy / controlloop / policy / guard / ControlLoopGuardTest.java
index 01d6eb1..3d4cb37 100644 (file)
@@ -2,15 +2,15 @@
  * ============LICENSE_START=======================================================
  * policy-yaml unit test
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
@@ -25,15 +25,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.LinkedList;
-
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,14 +41,14 @@ import org.yaml.snakeyaml.constructor.Constructor;
 
 public class ControlLoopGuardTest {
     private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardTest.class);
-    
-    @Test 
-    public void testGuardvdns() {
+
+    @Test
+    public void testGuardvdns() throws Exception {
         this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
     }
 
-    @Test 
-    public void testGuardvusp() {
+    @Test
+    public void testGuardvusp() throws Exception {
         this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml");
     }
 
@@ -122,10 +118,11 @@ public class ControlLoopGuardTest {
 
     /**
      * Does the actual test.
-     * 
+     *
      * @param testFile input file
+     * @throws Exception if an error occurs
      */
-    public void test(String testFile) {
+    public void test(String testFile) throws Exception {
         try (InputStream is = new FileInputStream(new File(testFile))) {
             //
             // Read the yaml into our Java Object
@@ -151,20 +148,13 @@ public class ControlLoopGuardTest {
             dump(newObject);
             assertNotNull(newObject);
             assertTrue(newObject instanceof ControlLoopGuard);
-            //
-            // Have to comment it out tentatively since it causes junit to fail. 
-            // Seems we cannot use assertEquals here. Need advice.
-            //
-            //assertEquals(newObject, obj);
-        } catch (FileNotFoundException e) {
-            fail(e.getLocalizedMessage());
-        } catch (IOException e) {
-            fail(e.getLocalizedMessage());
+
+            assertEquals(obj, newObject);
         }
     }
 
     public void dump(Object obj) {
-        logger.debug("Dumping {}", obj.getClass().getCanonicalName());
+        logger.debug("Dumping {}", obj.getClass().getName());
         logger.debug("{}", obj);
     }
 }