From 3c703e2e48c0e74cb580b8afafb212fb9728aeeb Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 29 May 2020 11:43:49 -0400 Subject: Use OperationsHistory from models Deleted Dbao and replaced it with the shared class in policy-models. Also had to update the queries and the persistence.xml accordingly. Issue-ID: POLICY-2581 Change-Id: I59dfa2f37c272796ccebc0f578c9f4e8e1b9c8ab Signed-off-by: Jim Hahn --- .../xacml/pdp/application/guard/GuardPdpApplicationTest.java | 6 +++--- .../xacml/pdp/application/guard/SonCoordinationTest.java | 10 ++++------ applications/guard/src/test/resources/META-INF/persistence.xml | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'applications/guard') diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java index f5392cfa..e83f4d29 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java @@ -52,6 +52,7 @@ import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.guard.OperationsHistory; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @@ -60,7 +61,6 @@ import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider; import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils; import org.onap.policy.pdp.xacml.application.common.operationshistory.CountRecentOperationsPip; -import org.onap.policy.pdp.xacml.application.common.operationshistory.Dbao; import org.onap.policy.pdp.xacml.xacmltest.TestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,7 +160,7 @@ public class GuardPdpApplicationTest { @Before public void startClean() throws Exception { em.getTransaction().begin(); - em.createQuery("DELETE FROM Dbao").executeUpdate(); + em.createQuery("DELETE FROM OperationsHistory").executeUpdate(); em.getTransaction().commit(); } @@ -362,7 +362,7 @@ public class GuardPdpApplicationTest { // // Add an entry // - Dbao newEntry = new Dbao(); + OperationsHistory newEntry = new OperationsHistory(); newEntry.setActor(properties.get("actor").toString()); newEntry.setOperation(properties.get("operation").toString()); newEntry.setClosedLoopName(properties.get("clname").toString()); diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java index 4c5bced7..ba51f556 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java @@ -34,10 +34,8 @@ import java.util.Map; import java.util.Properties; import java.util.ServiceLoader; import java.util.UUID; - import javax.persistence.EntityManager; import javax.persistence.Persistence; - import org.apache.commons.lang3.tuple.Pair; import org.junit.AfterClass; import org.junit.Before; @@ -51,13 +49,13 @@ import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.guard.OperationsHistory; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider; import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils; import org.onap.policy.pdp.xacml.application.common.operationshistory.CountRecentOperationsPip; -import org.onap.policy.pdp.xacml.application.common.operationshistory.Dbao; import org.onap.policy.pdp.xacml.xacmltest.TestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -154,7 +152,7 @@ public class SonCoordinationTest { @Before public void startClean() throws Exception { em.getTransaction().begin(); - em.createQuery("DELETE FROM Dbao").executeUpdate(); + em.createQuery("DELETE FROM OperationsHistory").executeUpdate(); em.getTransaction().commit(); } @@ -271,7 +269,7 @@ public class SonCoordinationTest { // // Add an entry // - Dbao newEntry = new Dbao(); + OperationsHistory newEntry = new OperationsHistory(); newEntry.setActor(properties.get("actor").toString()); newEntry.setOperation(properties.get("operation").toString()); newEntry.setClosedLoopName(properties.get("clname").toString()); @@ -288,7 +286,7 @@ public class SonCoordinationTest { private void updateOperationEvent(long id, String outcome) { - Dbao updateEntry = em.find(Dbao.class, id); + OperationsHistory updateEntry = em.find(OperationsHistory.class, id); updateEntry.setOutcome(outcome); updateEntry.setEndtime(Date.from(Instant.now())); em.getTransaction().begin(); diff --git a/applications/guard/src/test/resources/META-INF/persistence.xml b/applications/guard/src/test/resources/META-INF/persistence.xml index 41b25b42..ceb255f8 100644 --- a/applications/guard/src/test/resources/META-INF/persistence.xml +++ b/applications/guard/src/test/resources/META-INF/persistence.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP ================================================================================ - Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ org.eclipse.persistence.jpa.PersistenceProvider - org.onap.policy.pdp.xacml.application.common.operationshistory.Dbao + org.onap.policy.guard.OperationsHistory -- cgit 1.2.3-korg