diff options
Diffstat (limited to 'main/src/test')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java | 39 | ||||
-rw-r--r-- | main/src/test/resources/parameters/PapDbGroup1.json | 36 |
2 files changed, 67 insertions, 8 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java index e49982bf..bf3a2a4e 100644 --- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java +++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,6 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInst import org.onap.policy.common.utils.resources.MessageConstants; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; -import org.onap.policy.pap.main.PolicyPapException; import org.onap.policy.pap.main.PolicyPapRuntimeException; import org.onap.policy.pap.main.parameters.CommonTestData; @@ -59,10 +58,9 @@ public class TestMain { /** * Shuts "main" down. * - * @throws Exception if an error occurs */ @After - public void tearDown() throws Exception { + public void tearDown() { // shut down activator PapActivator activator = Registry.getOrDefault(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class, null); if (activator != null && activator.isAlive()) { @@ -70,20 +68,45 @@ public class TestMain { } } - @Test - public void testMain() throws PolicyPapException { - final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"}; + private void testMainBody(String[] papConfigParameters) { main = new Main(papConfigParameters); assertTrue(main.getParameters().isValid()); assertEquals(CommonTestData.PAP_GROUP_NAME, main.getParameters().getName()); // ensure items were added to the registry assertNotNull(Registry.get(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class)); - main.shutdown(); } @Test + public void testMain() { + final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"}; + testMainBody(papConfigParameters); + } + + @Test + public void testMainCustomGroup() { + final String[] papConfigParameters = { + "-c", + "parameters/PapConfigParameters.json", + "-g", + "parameters/PapDbGroup1.json" + }; + testMainBody(papConfigParameters); + } + + @Test + public void testMainPapDb() { + final String[] papConfigParameters = { + "-c", + "parameters/PapConfigParameters.json", + "-g", + "PapDb.json" + }; + testMainBody(papConfigParameters); + } + + @Test public void testMain_NoArguments() { final String[] papConfigParameters = {}; assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class) diff --git a/main/src/test/resources/parameters/PapDbGroup1.json b/main/src/test/resources/parameters/PapDbGroup1.json new file mode 100644 index 00000000..9a967448 --- /dev/null +++ b/main/src/test/resources/parameters/PapDbGroup1.json @@ -0,0 +1,36 @@ +{ + "groups": [ + { + "name": "group1", + "version": "1.0.0", + "description": "group 1", + "pdpGroupState": "ACTIVE", + "pdpSubgroups": [ + { + "pdpType": "T1", + "supportedPolicyTypes": [ + { + "name": "t1", + "version": "1.0.0" + } + ], + "currentInstanceCount": 0, + "desiredInstanceCount": 1, + "policies": [] + }, + { + "pdpType": "T2", + "supportedPolicyTypes": [ + { + "name": "t2", + "version": "1.0.0" + } + ], + "currentInstanceCount": 0, + "desiredInstanceCount": 1, + "policies": [] + } + ] + } + ] +} |