import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import com.google.gson.Gson;
-
import java.util.Base64;
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;
// Logger for this class
private static final Logger LOGGER = LoggerFactory.getLogger(PolicyLegacyOperationalPersistenceTest.class);
- private Gson gson;
+ private StandardCoder standardCoder;
private PolicyModelsProvider databaseProvider;
}
/**
- * Set up GSON.
+ * Set up standard coder.
*/
@Before
- public void setupGson() {
- gson = new Gson();
+ public void setupStandardCoder() {
+ standardCoder = new StandardCoder();
}
@After
*/
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);
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(