summaryrefslogtreecommitdiffstats
path: root/model/policy-model/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-02-07 17:56:44 +0000
committerliamfallon <liam.fallon@est.tech>2022-02-08 18:39:03 +0000
commit59b90519eda3b95b0cfc49b6349a591c7d0c78e2 (patch)
tree810e07f7d5cf270582264c40245372f597c713a2 /model/policy-model/src/test
parentdef44b294fa00bb5470e977eef9a05e5087035f0 (diff)
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 <liam.fallon@est.tech>
Diffstat (limited to 'model/policy-model/src/test')
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java13
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java10
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java11
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java5
4 files changed, 18 insertions, 21 deletions
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
index e724a4663..526f5a628 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -190,9 +190,9 @@ public class PoliciesTest {
final AxState clonedState = new AxState(policyPN.getStateMap().get("state"));
clonedState.getKey().setLocalName("ClonedState");
- clonedState.afterUnmarshal(null, null);
savedStateMap.put(clonedState.getKey().getLocalName(), clonedState);
+ policyPN.buildReferences();
result = new AxValidationResult();
result = policyPN.validate(result);
assertEquals(ValidationResult.WARNING, result.getValidationResult());
@@ -213,7 +213,9 @@ public class PoliciesTest {
assertEquals(policyPN, policyPN); // NOSONAR
assertEquals(policyPN, clonedPolicy);
assertNotNull(policyPN);
- assertNotEquals(policyPN, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(policyPN, helloObj);
assertNotEquals(policyPN,
new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState));
assertNotEquals(policyPN, new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState));
@@ -287,7 +289,6 @@ public class PoliciesTest {
assertEquals(ValidationResult.VALID, result.getValidationResult());
policies.clean();
- policies.afterUnmarshal(null, null);
final AxPolicies clonedPolicies = new AxPolicies(policies);
assertEquals("AxPolicies:(key=AxArtifactKey:(name=PoliciesKey,version=0.0.",
@@ -298,7 +299,7 @@ public class PoliciesTest {
assertEquals(policies, policies); // NOSONAR
assertEquals(policies, clonedPolicies);
assertNotNull(policies);
- assertNotEquals(policies, (Object) "Hello");
+ assertNotEquals(policyPN, helloObj);
assertNotEquals(policies, new AxPolicies(new AxArtifactKey()));
assertEquals(0, policies.compareTo(policies));
@@ -324,7 +325,6 @@ public class PoliciesTest {
final AxState secondState = new AxState(policyPN.getStateMap().get("state"));
secondState.getKey().setLocalName("SecondState");
- secondState.afterUnmarshal(null, null);
policyPN.getStateMap().put("SecondState", secondState);
policyPN.getStateMap().get("state").getStateOutputs().get("stateOutput0").setNextState(secondState.getKey());
@@ -344,7 +344,6 @@ public class PoliciesTest {
final AxState thirdState = new AxState(policyPN.getStateMap().get("state"));
thirdState.getKey().setLocalName("ThirdState");
- thirdState.afterUnmarshal(null, null);
policyPN.getStateMap().put("ThirdState", thirdState);
policyPN.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0")
.setNextState(thirdState.getKey());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
index 95a91325a..7fbe78078 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,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.
@@ -147,10 +147,10 @@ public class StateTest {
state.setTaskReferences(trMap);
assertEquals(trMap, state.getTaskReferences());
- state.afterUnmarshal(null, null);
+ state.buildReferences();
assertEquals(state.getKey(), state.getKeys().get(0));
state.getTaskSelectionLogic().getKey().setLocalName(AxKey.NULL_KEY_NAME);
- state.afterUnmarshal(null, null);
+ state.buildReferences();
assertEquals(state.getKey(), state.getKeys().get(0));
final Set<String> stateSet = state.getNextStateSet();
@@ -387,7 +387,9 @@ public class StateTest {
assertEquals(state, state); // NOSONAR
assertEquals(state, clonedState);
assertNotNull(state);
- assertNotEquals(state, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(state, helloObj);
assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(new AxReferenceKey()).trigger(triggerKey)
.stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl)
.stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap)));
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
index 89dc9a048..9c7866c85 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.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 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,7 +85,7 @@ public class TasksTest {
assertEquals("TaskName:0.0.1", task.getKey().getId());
assertEquals("TaskName:0.0.1", task.getKeys().get(0).getId());
- task.afterUnmarshal(null, null);
+ task.buildReferences();
assertEquals(1, task.getTaskParameters().size());
AxValidationResult result = new AxValidationResult();
@@ -154,7 +154,9 @@ public class TasksTest {
assertEquals(task, task); // NOSONAR
assertEquals(task, clonedTask);
assertNotNull(task);
- assertNotEquals(task, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(task, helloObj);
assertNotEquals(task, new AxTask(new AxArtifactKey(), tpMap, ctxtSet, tl));
assertEquals(task, new AxTask(taskKey, tpMap, ctxtSet, tl));
assertNotEquals(task, new AxTask(taskKey, tpEmptyMap, ctxtSet, tl));
@@ -224,7 +226,6 @@ public class TasksTest {
assertEquals(ValidationResult.VALID, result.getValidationResult());
tasks.clean();
- tasks.afterUnmarshal(null, null);
final AxTasks clonedTasks = new AxTasks(tasks);
assertEquals("AxTasks:(key=AxArtifactKey:(name=TasksKey,version=0.0.1),tas",
@@ -236,7 +237,7 @@ public class TasksTest {
assertEquals(tasks, tasks); // NOSONAR
assertEquals(tasks, clonedTasks);
assertNotNull(tasks);
- assertNotEquals(tasks, (Object) "Hello");
+ assertNotEquals(tasks, helloObj);
assertNotEquals(tasks, new AxTasks(new AxArtifactKey()));
assertEquals(0, tasks.compareTo(tasks));
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index a2a997e8d..48e4f87f9 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -132,11 +132,6 @@ public class ApexPolicyModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}