diff options
Diffstat (limited to 'main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java index 9ae64452..f172222d 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,8 @@ package org.onap.policy.pap.main.rest; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -32,9 +33,9 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Set; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -66,7 +67,7 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { private MyProvider prov; - @AfterClass + @AfterAll public static void tearDownAfterClass() { Registry.newRegistry(); } @@ -77,7 +78,7 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { * @throws Exception if an error occurs */ @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); @@ -96,15 +97,15 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { Pdp pdp1 = new Pdp(); pdp1.setInstanceId(PDP1); - subgroup.setPdpInstances(Arrays.asList(pdp1)); + subgroup.setPdpInstances(List.of(pdp1)); // this subgroup should never be touched PdpSubGroup subgroup0 = new PdpSubGroup(); subgroup0.setPdpType(MY_SUBGROUP0); - subgroup0.setPolicies(Collections.unmodifiableList(Arrays.asList(ident1, ident2, ident3, ident4))); - subgroup.setPdpInstances(Arrays.asList(pdp1)); + subgroup0.setPolicies(List.of(ident1, ident2, ident3, ident4)); + subgroup.setPdpInstances(List.of(pdp1)); - group.setPdpSubgroups(Arrays.asList(subgroup0, subgroup)); + group.setPdpSubgroups(List.of(subgroup0, subgroup)); when(session.getGroup(MY_GROUP)).thenReturn(group); when(session.getPolicy(any())).thenReturn(policy1); @@ -114,15 +115,15 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { @Test public void testUndeployPolicies() throws PfModelException { - subgroup.setPolicies(new LinkedList<>(Arrays.asList(ident1, ident2, ident3, ident4))); + subgroup.setPolicies(new LinkedList<>(List.of(ident1, ident2, ident3, ident4))); - prov.undeploy(MY_GROUP, MY_SUBGROUP, Arrays.asList(ident1, ident2)); + prov.undeploy(MY_GROUP, MY_SUBGROUP, List.of(ident1, ident2)); // group should have been updated verify(session).update(group); // subgroup should only have remaining policies - assertEquals(Arrays.asList(ident3, ident4).toString(), subgroup.getPolicies().toString()); + assertEquals(List.of(ident3, ident4).toString(), subgroup.getPolicies().toString()); // should have generated PDP-UPDATE for the PDP verify(session).addUpdate(any()); @@ -133,10 +134,10 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { */ @Test public void testUndeployPoliciesUnchanged() throws PfModelException { - List<ToscaConceptIdentifier> origlist = Arrays.asList(ident3, ident4); + List<ToscaConceptIdentifier> origlist = List.of(ident3, ident4); subgroup.setPolicies(new LinkedList<>(origlist)); - prov.undeploy(MY_GROUP, MY_SUBGROUP, Arrays.asList(ident1, ident2)); + prov.undeploy(MY_GROUP, MY_SUBGROUP, List.of(ident1, ident2)); // group NOT should have been updated verify(session, never()).update(group); @@ -154,11 +155,11 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { @Test public void testUndeployPoliciesGroupNotFound() throws PfModelException { // force exception to be thrown if the list is changed - subgroup.setPolicies(Collections.unmodifiableList(Arrays.asList(ident1, ident2, ident3, ident4))); + subgroup.setPolicies(Collections.unmodifiableList(List.of(ident1, ident2, ident3, ident4))); when(session.getGroup(any())).thenReturn(null); - prov.undeploy(MY_GROUP, MY_SUBGROUP, Arrays.asList(ident1, ident2)); + prov.undeploy(MY_GROUP, MY_SUBGROUP, List.of(ident1, ident2)); // group should have been updated verify(session, never()).update(group); @@ -173,11 +174,11 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { @Test public void testUndeployPoliciesSubGroupNotFound() throws PfModelException { // force exception to be thrown if the list is changed - subgroup.setPolicies(Collections.unmodifiableList(Arrays.asList(ident1, ident2, ident3, ident4))); + subgroup.setPolicies(Collections.unmodifiableList(List.of(ident1, ident2, ident3, ident4))); subgroup.setPdpType(MY_SUBGROUP + "X"); - prov.undeploy(MY_GROUP, MY_SUBGROUP, Arrays.asList(ident1, ident2)); + prov.undeploy(MY_GROUP, MY_SUBGROUP, List.of(ident1, ident2)); // group should have been updated verify(session, never()).update(group); @@ -186,9 +187,9 @@ public class TestPolicyUndeployerImpl extends ProviderSuper { verify(session, never()).addUpdate(any()); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testMakeUpdater() { - prov.makeUpdater(null, null, null); + assertThrows(UnsupportedOperationException.class, () -> prov.makeUpdater(null, null, null)); } |