diff options
Diffstat (limited to 'POLICY-SDK-APP')
-rw-r--r-- | POLICY-SDK-APP/src/test/java/org/onap/policy/model/PDPGroupContainerTest.java | 65 | ||||
-rw-r--r-- | POLICY-SDK-APP/src/test/java/org/onap/policy/model/RolesTest.java | 38 |
2 files changed, 94 insertions, 9 deletions
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/model/PDPGroupContainerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/model/PDPGroupContainerTest.java index 0cfba2cc1..f184bde1b 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/model/PDPGroupContainerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/model/PDPGroupContainerTest.java @@ -2,10 +2,8 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2019 Samsung - * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. 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. * You may obtain a copy of the License at @@ -24,9 +22,11 @@ package org.onap.policy.model; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.doThrow; import com.att.research.xacml.api.pap.PAPException; - +import java.awt.Checkbox; +import java.util.Set; import org.junit.Test; import org.mockito.Mockito; import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener; @@ -35,6 +35,9 @@ import org.onap.policy.xacml.api.pap.OnapPDPGroup; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; public class PDPGroupContainerTest { + private OnapPDPGroup group = Mockito.mock(OnapPDPGroup.class); + private OnapPDPGroup newGroup = Mockito.mock(OnapPDPGroup.class); + private OnapPDP pdp = Mockito.mock(OnapPDP.class); private PAPPolicyEngine engine = Mockito.mock(PAPPolicyEngine.class); private PDPGroupContainer container = new PDPGroupContainer(engine); @@ -46,13 +49,11 @@ public class PDPGroupContainerTest { container.refreshGroups(); assertEquals(container.getGroups().size(), 0); - OnapPDPGroup group = Mockito.mock(OnapPDPGroup.class); container.makeDefault(group); - OnapPDPGroup newGroup = Mockito.mock(OnapPDPGroup.class); container.removeGroup(group, newGroup); - OnapPDP pdp = Mockito.mock(OnapPDP.class); container.updatePDP(pdp); container.updateGroup(group); + container.updateGroup(group, "testUserName"); assertNull(container.getContainerPropertyIds()); assertEquals(container.getItemIds().size(), 0); assertEquals(container.getType(itemId), null); @@ -118,4 +119,50 @@ public class PDPGroupContainerTest { public void testGetItemIds() { container.getItemIds(0, 1); } -} + + @Test + public void testGetType() { + assertEquals(Boolean.class, container.getType("Default")); + assertEquals(Checkbox.class, container.getType("Selected")); + assertEquals(Set.class, container.getType("PDPs")); + assertEquals(Set.class, container.getType("Policies")); + assertEquals(Set.class, container.getType("PIP Configurations")); + assertEquals(String.class, container.getType("Id")); + assertEquals(String.class, container.getType("Name")); + assertEquals(String.class, container.getType("Description")); + assertEquals(String.class, container.getType("Status")); + } + + @Test + public void testContainerPAPExceptions() throws PAPException { + doThrow(PAPException.class).when(engine).getOnapPDPGroups(); + container.refreshGroups(); + + doThrow(PAPException.class).when(engine).setDefaultGroup(group); + container.makeDefault(group); + + doThrow(PAPException.class).when(engine).updatePDP(pdp); + container.updatePDP(pdp); + + doThrow(PAPException.class).when(engine).updateGroup(group); + container.updateGroup(group); + + doThrow(PAPException.class).when(engine).updateGroup(group, "testUserName"); + container.updateGroup(group, "testUserName"); + + doThrow(PAPException.class).when(engine).movePDP(pdp, group); + container.movePDP(pdp, group); + } + + @Test(expected = PAPException.class) + public void testContainerRemoveGroup() throws PAPException { + doThrow(PAPException.class).when(engine).removeGroup(group, newGroup); + container.removeGroup(group, newGroup); + } + + @Test(expected = PAPException.class) + public void testContainerRemovePDP() throws PAPException { + doThrow(PAPException.class).when(engine).removePDP(pdp); + container.removePDP(pdp, group); + } +}
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/model/RolesTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/model/RolesTest.java new file mode 100644 index 000000000..745579af9 --- /dev/null +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/model/RolesTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.model; + +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +import org.junit.Test; + +public class RolesTest { + + @Test + public void testRolesSettersAndGetters() { + final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build(); + validator.validate(RolesTest.class.getPackage().getName(), new FilterPackageInfo()); + } +} |