diff options
author | 2022-02-07 16:05:17 +0000 | |
---|---|---|
committer | 2022-02-10 10:31:15 +0000 | |
commit | 873803eca00830dc3ecb61e610d90710f64a8242 (patch) | |
tree | 31531d76a87c300577da83bdf86563b78a015fce /main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java | |
parent | ed116b0d61f3195a1b0ed9d38f23e494260977fd (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/rest/TestPdpGroupDeleteProvider.java')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java index 3e9eda8a..449d48f2 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020-2021 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021-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. @@ -47,6 +47,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.pdp.concepts.PdpUpdate; @@ -84,14 +85,14 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper { @Before @Override public void setUp() throws Exception { - super.setUp(); + prov = new MyProvider(); + super.initialize(prov); ident = policy1.getIdentifier(); optIdent = new ToscaConceptIdentifierOptVersion(ident.getName(), null); fullIdent = new ToscaConceptIdentifierOptVersion(ident.getName(), ident.getVersion()); - prov = new MyProvider(); updater = prov.makeUpdater(session, policy1, fullIdent); } @@ -144,12 +145,12 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper { } @Test - public void testDeleteGroup_DaoEx() throws Exception { + public void testDeleteGroup_Ex() throws Exception { PdpGroup group = loadGroup("deleteGroup.json"); when(session.getGroup(GROUP1_NAME)).thenReturn(group); - PfModelException ex = new PfModelException(Status.BAD_REQUEST, EXPECTED_EXCEPTION); + PfModelRuntimeException ex = new PfModelRuntimeException(Status.BAD_REQUEST, EXPECTED_EXCEPTION); doThrow(ex).when(session).deleteGroupFromDb(group); assertThatThrownBy(() -> prov.deleteGroup(GROUP1_NAME)).isSameAs(ex); @@ -162,15 +163,15 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper { */ @Test public void testUndeploy_Full() throws Exception { - when(dao.getFilteredPolicyList(any())).thenReturn(Arrays.asList(policy1)); + when(toscaService.getFilteredPolicyList(any())).thenReturn(Arrays.asList(policy1)); PdpGroup group = loadGroup("undeploy.json"); - when(dao.getFilteredPdpGroups(any())).thenReturn(Arrays.asList(group)); - when(dao.getFilteredPolicyList(any())).thenReturn(Arrays.asList(policy1)); + when(pdpGroupService.getFilteredPdpGroups(any())).thenReturn(Arrays.asList(group)); + when(toscaService.getFilteredPolicyList(any())).thenReturn(Arrays.asList(policy1)); PdpGroupDeleteProvider deleteProvider = new PdpGroupDeleteProvider(); - deleteProvider.initialize(); + super.initialize(deleteProvider); deleteProvider.undeploy(fullIdent, DEFAULT_USER); // should have updated the old group |