Add support for legacy guard policies
[policy/models.git] / models-provider / src / test / java / org / onap / policy / models / provider / impl / PolicyLegacyOperationalPersistenceTest.java
index 90d00fc..60d577c 100644 (file)
@@ -24,8 +24,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
-import com.google.gson.Gson;
-
 import java.util.Base64;
 
 import lombok.NonNull;
@@ -33,6 +31,7 @@ import lombok.NonNull;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
@@ -51,7 +50,7 @@ public class PolicyLegacyOperationalPersistenceTest {
     // Logger for this class
     private static final Logger LOGGER = LoggerFactory.getLogger(PolicyLegacyOperationalPersistenceTest.class);
 
-    private Gson gson;
+    private StandardCoder standardCoder;
 
     private PolicyModelsProvider databaseProvider;
 
@@ -87,11 +86,11 @@ public class PolicyLegacyOperationalPersistenceTest {
     }
 
     /**
-     * Set up GSON.
+     * Set up standard coder.
      */
     @Before
-    public void setupGson() {
-        gson = new Gson();
+    public void setupStandardCoder() {
+        standardCoder = new StandardCoder();
     }
 
     @After
@@ -122,7 +121,7 @@ public class PolicyLegacyOperationalPersistenceTest {
      */
     public void testJsonStringPolicyPersistence(@NonNull final String policyInputString,
             final String policyOutputString) throws Exception {
-        LegacyOperationalPolicy lop = gson.fromJson(policyInputString, LegacyOperationalPolicy.class);
+        LegacyOperationalPolicy lop = standardCoder.decode(policyInputString, LegacyOperationalPolicy.class);
 
         assertNotNull(lop);
 
@@ -132,7 +131,7 @@ public class PolicyLegacyOperationalPersistenceTest {
         LegacyOperationalPolicy gotLop = databaseProvider.getOperationalPolicy(lop.getPolicyId());
         assertEquals(gotLop, lop);
 
-        String actualRetrievedJson = gson.toJson(gotLop);
+        String actualRetrievedJson = standardCoder.encode(gotLop);
 
         // All of this dash/underscore stuff is to avoid a checkstyle error around escaping unicode characters
         assertEquals(