diff options
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.java | 27 |
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; } } |