summaryrefslogtreecommitdiffstats
path: root/applications/common
diff options
context:
space:
mode:
authorpramod.jamkhedkar <pramod@research.att.com>2020-05-18 11:27:50 -0400
committerpramod.jamkhedkar <pramod@research.att.com>2020-05-19 10:34:32 -0400
commitcac1b44880610e19ae831d3f3656b8b835389db0 (patch)
treea0b9b0d017031ddfede913f07e148c1fcf461f01 /applications/common
parent50c786ff425de405252cccddea7ff776942ef671 (diff)
Change CLC granularity to CL level.
Change CLC granularity from target level to CL level. Remove the target matching for the db query at PIP level. Issue-ID: POLICY-2573 Change-Id: If9ba1a4d22c3b8bc5dfce0632f7037ad085f6ea6 Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
Diffstat (limited to 'applications/common')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java8
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java15
2 files changed, 8 insertions, 15 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
index b269e25a..fb018b02 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
@@ -90,7 +90,7 @@ public class GetOperationOutcomePip extends StdOnapPip {
target = getAttribute(pipFinder, PIP_REQUEST_TARGET);
logger.debug("Going to query DB about: clname={}, target={}", clname, target);
- String outcome = doDatabaseQuery(clname, target);
+ String outcome = doDatabaseQuery(clname);
logger.debug("Query result is: {}", outcome);
StdMutablePIPResponse pipResponse = new StdMutablePIPResponse();
@@ -102,8 +102,8 @@ public class GetOperationOutcomePip extends StdOnapPip {
return new StdPIPResponse(pipResponse);
}
- private String doDatabaseQuery(String clname, String target) {
- logger.info("Querying operations history for {} {}", clname, target);
+ private String doDatabaseQuery(String clname) {
+ logger.info("Querying operations history for {}", clname);
//
// Only can query if we have an EntityManager
//
@@ -120,11 +120,9 @@ public class GetOperationOutcomePip extends StdOnapPip {
//
return em.createQuery("select e.outcome from Dbao e"
+ " where e.closedLoopName= ?1"
- + " and e.target= ?2"
+ " order by e.endtime desc",
String.class)
.setParameter(1, clname)
- .setParameter(2, target)
.setMaxResults(1)
.getSingleResult();
} catch (NoResultException e) {
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java
index e0dc7cd4..dcb172e6 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java
@@ -189,13 +189,12 @@ public class GetOperationOutcomePipTest {
// Use reflection to run getCountFromDB
//
Method method = GetOperationOutcomePip.class.getDeclaredMethod("doDatabaseQuery",
- String.class,
String.class);
method.setAccessible(true);
//
// Test pipEngine
//
- String outcome = (String) method.invoke(pipEngine, "testcl1", "testtarget1");
+ String outcome = (String) method.invoke(pipEngine, "testcl1");
assertThat(outcome).isNull();
//
// Insert entry
@@ -204,7 +203,7 @@ public class GetOperationOutcomePipTest {
//
// Test pipEngine
//
- outcome = (String) method.invoke(pipEngine, "testcl1", "testtarget1");
+ outcome = (String) method.invoke(pipEngine, "testcl1");
//
// outcome should be "1"
//
@@ -214,25 +213,21 @@ public class GetOperationOutcomePipTest {
//
insertEntry("testcl1", "testtarget1", "2");
insertEntry("testcl2", "testtarget2", "3");
- insertEntry("testcl1", "testtarget2", "4");
//
// Test pipEngine
//
- outcome = (String) method.invoke(pipEngine, "testcl1", "testtarget1");
+ outcome = (String) method.invoke(pipEngine, "testcl1");
assertEquals("2", outcome);
- outcome = (String) method.invoke(pipEngine, "testcl2", "testtarget2");
+ outcome = (String) method.invoke(pipEngine, "testcl2");
assertEquals("3", outcome);
- outcome = (String) method.invoke(pipEngine, "testcl1", "testtarget2");
- assertEquals("4", outcome);
-
//
// Shut it down
//
pipEngine.shutdown();
- assertThat(method.invoke(pipEngine, "testcl1", "testtarget2")).isNull();
+ assertThat(method.invoke(pipEngine, "testcl1")).isNull();
}
private void insertEntry(String cl, String target, String outcome) {