aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2022-02-07 16:05:17 +0000
committera.sreekumar <ajith.sreekumar@bell.ca>2022-02-10 10:31:15 +0000
commit873803eca00830dc3ecb61e610d90710f64a8242 (patch)
tree31531d76a87c300577da83bdf86563b78a015fce /main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
parented116b0d61f3195a1b0ed9d38f23e494260977fd (diff)
Move PAP database provider to spring boot default
This review makes PAP talk to DB directly using the spring repositories instead of going to policy-models-provider. The models-provider methods that were just used by PAP (and not used anymore) will be removed in a different review. Also a bug identified with the usage of GeneratedValue in PfGeneratedIdKey (which is just used by PAP in statistics & audit) will also be fixed in a separate review as part of POLICY-3897. CSIT changes: https://gerrit.onap.org/r/c/policy/docker/+/127033 WIP OOM review: https://gerrit.onap.org/r/c/oom/+/127035 Change-Id: Idb13ba7eb2767cc718672b582a6518fcfc95320f Issue-ID: POLICY-3867 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
index 9134985c..5fec269a 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. 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.
@@ -41,14 +42,14 @@ import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.pap.concepts.PolicyNotification;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.PolicyPapRuntimeException;
import org.onap.policy.pap.main.comm.Publisher;
import org.onap.policy.pap.main.comm.QueueToken;
+import org.onap.policy.pap.main.service.PolicyStatusService;
@RunWith(MockitoJUnitRunner.class)
public class PolicyNotifierTest {
@@ -61,10 +62,7 @@ public class PolicyNotifierTest {
private Publisher<PolicyNotification> publisher;
@Mock
- private PolicyModelsProviderFactoryWrapper daoFactory;
-
- @Mock
- private PolicyModelsProvider dao;
+ private PolicyStatusService policyStatusService;
@Mock
private DeploymentStatus tracker;
@@ -92,8 +90,7 @@ public class PolicyNotifierTest {
@Before
public void setUp() {
try {
- when(daoFactory.create()).thenReturn(dao);
- when(dao.getGroupPolicyStatus(anyString())).thenReturn(Collections.emptyList());
+ when(policyStatusService.getGroupPolicyStatus(anyString())).thenReturn(Collections.emptyList());
notifier = new MyNotifier(publisher);
@@ -125,7 +122,8 @@ public class PolicyNotifierTest {
@Test
public void testProcessResponseString_Ex() throws PfModelException {
- doThrow(new PfModelException(Status.BAD_REQUEST, "expected exception")).when(tracker).loadByGroup(anyString());
+ doThrow(new PfModelRuntimeException(Status.BAD_REQUEST, "expected exception")).when(tracker)
+ .loadByGroup(anyString());
assertThatCode(() -> notifier.processResponse(PDP1, GROUP_A, Set.of(), Set.of())).doesNotThrowAnyException();
}
@@ -155,20 +153,23 @@ public class PolicyNotifierTest {
@Test
public void testMakeDeploymentTracker() throws PfModelException {
// make real object, which will invoke the real makeXxx() methods
- new PolicyNotifier(publisher, daoFactory).processResponse(PDP1, GROUP_A, Set.of(), Set.of());
+ PolicyNotifier policyNotifier = new PolicyNotifier(policyStatusService);
+ policyNotifier.setPublisher(publisher);
+ policyNotifier.processResponse(PDP1, GROUP_A, Set.of(), Set.of());
- verify(dao).getGroupPolicyStatus(GROUP_A);
+ verify(policyStatusService).getGroupPolicyStatus(GROUP_A);
}
private class MyNotifier extends PolicyNotifier {
public MyNotifier(Publisher<PolicyNotification> publisher) throws PfModelException {
- super(publisher, daoFactory);
+ super(policyStatusService);
+ super.setPublisher(publisher);
}
@Override
- protected DeploymentStatus makeDeploymentTracker(PolicyModelsProvider dao) {
+ protected DeploymentStatus makeDeploymentTracker() {
return tracker;
}
}