diff options
Diffstat (limited to 'tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java')
-rw-r--r-- | tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java index 9cd7b71e3..ab14c66c5 100644 --- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java +++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java @@ -20,11 +20,15 @@ package org.onap.policy.apex.tools.common; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.apache.commons.cli.Option; import org.junit.Test; -import org.onap.policy.apex.tools.common.CliParser; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; + /** * Tests for {@link CliParser}. * @@ -40,4 +44,27 @@ public class CliParserTest { final CliParser cli = new CliParser(); LOGGER.info(cli.getAppVersion()); } + + /** + * testAddAndGetOptionException. + */ + @Test + public void testAddAndGetOptionException() { + final CliParser cli = new CliParser(); + assertThatThrownBy(() -> { + cli.addOption(null); + }).isInstanceOf(IllegalStateException.class).hasMessageContaining("CLI parser: given option was null"); + } + + /** + * testParseAndGetCli. + */ + @Test + public void testParseAndGetCli() { + final CliParser cli = new CliParser(); + final Option option = new Option("g", "Good option."); + cli.addOption(option); + cli.parseCli(new String[] {"-g"}); + assertThat(cli.getCommandLine().hasOption("-g")).isTrue(); + } } |