From 59b90519eda3b95b0cfc49b6349a591c7d0c78e2 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 7 Feb 2022 17:56:44 +0000 Subject: Remove JAXB and XML, use GSON for JSON This review converst apex-pdp to use GSON for JSON handling. In order to preserve backward compatibility with the JAXB format of JSON, custom handling of maps was required. Therefore, the policy-common StandardCoder could not be used. There are a lot of small changes, removing annotations from concepts and tweaking of test data. However, this cleans up the code base so it is worth doing. Issue-ID: POLICY-1820 Change-Id: I213fa64f6d7f3f1df8d10f111d9fbedbe80f9fe0 Signed-off-by: liamfallon --- .../apex/examples/aadm/model/AadmDomainModelSaver.java | 3 +-- .../org/onap/policy/apex/examples/aadm/AadmModelTest.java | 5 ----- .../examples/adaptive/model/AdaptiveDomainModelSaver.java | 4 +--- .../apex/examples/adaptive/AnomalyDetectionModelTest.java | 5 ----- .../policy/apex/examples/adaptive/AutoLearnModelTest.java | 5 ----- .../policy/apex/examples/myfirstpolicy/MfpModelTest.java | 12 +----------- .../policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java | 3 +-- 7 files changed, 4 insertions(+), 33 deletions(-) (limited to 'examples') diff --git a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelSaver.java b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelSaver.java index 52edb31a3..490b9ac4f 100644 --- a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelSaver.java +++ b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelSaver.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019,2022 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,6 +57,5 @@ public final class AadmDomainModelSaver { final ApexModelSaver aadmModelSaver = new ApexModelSaver<>(AxPolicyModel.class, aadmPolicyModel, args[0]); aadmModelSaver.apexModelWriteJson(); - aadmModelSaver.apexModelWriteXml(); } } diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java index f0f0cea99..e35d9d278 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java @@ -50,11 +50,6 @@ public class AadmModelTest { assertEquals(VALID_MODEL_STRING, result.toString()); } - @Test - public void testModelWriteReadXml() throws Exception { - testApexModel.testApexModelWriteReadXml(); - } - @Test public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java index 0ebff497c..3400fa303 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019,2022 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,13 +57,11 @@ public final class AdaptiveDomainModelSaver { final ApexModelSaver adModelSaver = new ApexModelSaver<>(AxPolicyModel.class, adPolicyModel, args[0]); adModelSaver.apexModelWriteJson(); - adModelSaver.apexModelWriteXml(); // Save Auto Learn model final AxPolicyModel alPolicyModel = new AdaptiveDomainModelFactory().getAutoLearnPolicyModel(); final ApexModelSaver alModelSaver = new ApexModelSaver<>(AxPolicyModel.class, alPolicyModel, args[0]); alModelSaver.apexModelWriteJson(); - alModelSaver.apexModelWriteXml(); } } diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java index 310b43f68..4f9c58cc6 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java @@ -49,11 +49,6 @@ public class AnomalyDetectionModelTest { assertEquals(VALID_MODEL_STRING, result.toString()); } - @Test - public void testModelWriteReadXml() throws Exception { - testApexModel.testApexModelWriteReadXml(); - } - @Test public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java index 515451490..c69fa0678 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java @@ -49,11 +49,6 @@ public class AutoLearnModelTest { assertEquals(VALID_MODEL_STRING, result.toString()); } - @Test - public void testModelWriteReadXml() throws Exception { - testApexModel.testApexModelWriteReadXml(); - } - @Test public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java index 1bd67f961..2472cb466 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,17 +63,6 @@ public class MfpModelTest { assertTrue("Model did not validate cleanly", result.isOk()); } - /** - * Test model write and read XML. - * - * @throws Exception if there is an error - */ - @Test - public void testModelWriteReadXml() throws Exception { - testApexModel1.testApexModelWriteReadXml(); - testApexModel2.testApexModelWriteReadXml(); - } - /** * Test model write and read JSON. * diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java index 8b5d2ef88..a6c85fb0e 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -235,7 +235,6 @@ public class OnapVCpeSimEndpoint { if (appcResponse != null) { LOGGER.info("\n*** CONTROLLER RESPONSE START ***"); - System.err.println(appcResponse); LOGGER.info("\n*** CONTROLLER RESPONSE END ***"); return Response.status(200).entity(appcResponse).build(); -- cgit 1.2.3-korg