diff options
Diffstat (limited to 'services/services-onappf/src/test')
4 files changed, 71 insertions, 14 deletions
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterCommandLineArguments.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterCommandLineArguments.java new file mode 100644 index 000000000..e564d38e4 --- /dev/null +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterCommandLineArguments.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.services.onappf; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class TestApexStarterCommandLineArguments { + + /** + * Test method for {@link org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments + * #getPropertyFilePath()}. + * Assert custom option was added to options object from super. + */ + @Test + public void testCommandLineHasPropertyFileOption() { + String[] args = {"-p", "someFile.json"}; + ApexStarterCommandLineArguments sut = new ApexStarterCommandLineArguments(args); + assertEquals("someFile.json", sut.getPropertyFilePath()); + } + + /** + * Test method for {@link org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments#version()}. + * Assert method consults version.txt from Apex module. + */ + @Test + public void testVersion() { + String[] args = {"-v"}; + ApexStarterCommandLineArguments sut = new ApexStarterCommandLineArguments(args); + assertThat(sut.version()).startsWith("ONAP Policy Framework Apex Starter Service"); + } + +} diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java index 1d491ea03..b4308b8b9 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ @@ -45,6 +45,7 @@ import org.onap.policy.apex.services.onappf.handler.ApexEngineHandler; import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup; import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.utils.cmd.CommandLineException; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.pdp.concepts.PdpStateChange; @@ -73,9 +74,10 @@ public class TestPdpStateChangeListener { * @throws ApexStarterException if some error occurs while starting up the apex starter * @throws FileNotFoundException if the file is missing * @throws IOException if IO exception occurs + * @throws CommandLineException if any parsing of args has errors */ @Before - public void setUp() throws ApexStarterException, FileNotFoundException, IOException { + public void setUp() throws ApexStarterException, FileNotFoundException, IOException, CommandLineException { pdpUpdateMessageListener = new PdpUpdateListener(); pdpStateChangeListener = new PdpStateChangeListener(); Registry.newRegistry(); diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java index d9b8fc09c..28e230ebb 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ @@ -44,6 +44,7 @@ import org.onap.policy.apex.services.onappf.handler.PdpMessageHandler; import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup; import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.utils.cmd.CommandLineException; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.pdp.concepts.PdpStateChange; @@ -72,9 +73,10 @@ public class TestPdpUpdateListener { * @throws ApexStarterException if some error occurs while starting up the apex starter * @throws FileNotFoundException if the file is missing * @throws IOException if IO exception occurs + * @throws CommandLineException if any parsing of args has errors */ @Before - public void setUp() throws ApexStarterException, FileNotFoundException, IOException { + public void setUp() throws ApexStarterException, FileNotFoundException, IOException, CommandLineException { Registry.newRegistry(); final String[] apexStarterConfigParameters = {"-c", "src/test/resources/ApexStarterConfigParametersNoop.json"}; final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments(); diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java index d39cbecf0..dd424c15b 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java @@ -1,7 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 Nordix Foundation + * Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +28,7 @@ import java.io.FileNotFoundException; import org.junit.Test; import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments; import org.onap.policy.apex.services.onappf.exception.ApexStarterException; +import org.onap.policy.common.utils.cmd.CommandLineException; import org.onap.policy.common.utils.coder.CoderException; /** @@ -39,7 +39,7 @@ import org.onap.policy.common.utils.coder.CoderException; public class TestApexStarterParameterHandler { @Test - public void testParameterHandlerNoParameterFile() throws ApexStarterException { + public void testParameterHandlerNoParameterFile() throws ApexStarterException, CommandLineException { final String[] emptyArgumentString = { "-c", "src/test/resources/NoParametersFile.json" }; final ApexStarterCommandLineArguments emptyArguments = new ApexStarterCommandLineArguments(); @@ -51,7 +51,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testParameterHandlerEmptyParameters() throws ApexStarterException { + public void testParameterHandlerEmptyParameters() throws ApexStarterException, CommandLineException { final String[] noArgumentString = { "-c", "src/test/resources/NoParameters.json" }; final ApexStarterCommandLineArguments noArguments = new ApexStarterCommandLineArguments(); @@ -62,7 +62,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testParameterHandlerInvalidParameters() throws ApexStarterException { + public void testParameterHandlerInvalidParameters() throws ApexStarterException, CommandLineException { final String[] invalidArgumentString = { "-c", "src/test/resources/InvalidParameters.json" }; final ApexStarterCommandLineArguments invalidArguments = new ApexStarterCommandLineArguments(); @@ -74,7 +74,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testParameterHandlerNoParameters() throws ApexStarterException { + public void testParameterHandlerNoParameters() throws ApexStarterException, CommandLineException { final String[] noArgumentString = { "-c", "src/test/resources/EmptyConfigParameters.json" }; final ApexStarterCommandLineArguments noArguments = new ApexStarterCommandLineArguments(); @@ -85,7 +85,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testApexStarterParameterGroup() throws ApexStarterException { + public void testApexStarterParameterGroup() throws ApexStarterException, CommandLineException { final String[] apexStarterConfigParameters = { "-c", "src/test/resources/ApexStarterConfigParameters.json" }; final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments(); @@ -97,7 +97,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testApexStarterParameterGroup_InvalidName() throws ApexStarterException { + public void testApexStarterParameterGroup_InvalidName() throws ApexStarterException, CommandLineException { final String[] apexStarterConfigParameters = { "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" }; @@ -110,7 +110,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testApexStarterVersion() throws ApexStarterException { + public void testApexStarterVersion() throws ApexStarterException, CommandLineException { final String[] apexStarterConfigParameters = { "-v" }; final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments(); final String version = arguments.parse(apexStarterConfigParameters); @@ -118,7 +118,7 @@ public class TestApexStarterParameterHandler { } @Test - public void testApexStarterHelp() throws ApexStarterException { + public void testApexStarterHelp() throws ApexStarterException, CommandLineException { final String[] apexStarterConfigParameters = { "-h" }; final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments(); final String help = arguments.parse(apexStarterConfigParameters); |