diff options
author | waynedunican <wayne.dunican@est.tech> | 2020-07-24 09:46:36 +0100 |
---|---|---|
committer | waynedunican <wayne.dunican@est.tech> | 2020-07-27 13:28:30 +0100 |
commit | b2e2d5f8daeefb08873d11de44cb4cfe7cfab03a (patch) | |
tree | be45f7f5bf18fe4a1a1b1b430a4089a1d1a316c2 /tools | |
parent | ba58c5bad6075f7bc902de80190cc6770a209bb6 (diff) |
SONAR assertions apex-pdp
Ensure assertions are present in test cases
Issue-ID: POLICY-2706
Change-Id: I3673a7668564401d2136450b0bdd7a013605dd7c
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'tools')
6 files changed, 18 insertions, 5 deletions
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java index 1263dc4fd..24a9f60ce 100644 --- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java +++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.tools.model.generator.model2cli; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -37,7 +38,7 @@ public class Model2CliTest { public void testModel2Cli() { final String[] cliArgs = {"-h"}; - Model2CliMain.main(cliArgs); + assertThatCode(() -> Model2CliMain.main(cliArgs)).doesNotThrowAnyException(); } @Test diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java index 58c860d1c..5e2b05124 100644 --- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java +++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.tools.model.generator.model2event; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -38,7 +39,7 @@ public class Model2EventTest { final String[] EventArgs = { "-h" }; - Model2EventMain.main(EventArgs); + assertThatCode(() -> Model2EventMain.main(EventArgs)).doesNotThrowAnyException(); } diff --git a/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java b/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java index 8ff185504..6faafe759 100644 --- a/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java +++ b/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.tools.simple.wsclient; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; @@ -38,7 +39,7 @@ public class WsClientTest { final String[] EventArgs = { "-h" }; - WsClientMain.main(EventArgs); + assertThatCode(() -> WsClientMain.main(EventArgs)).doesNotThrowAnyException(); } @Test 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 ab14c66c5..80980bb34 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 @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ package org.onap.policy.apex.tools.common; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertNotNull; import org.apache.commons.cli.Option; import org.junit.Test; @@ -42,6 +44,7 @@ public class CliParserTest { @Test public void testappVersion() { final CliParser cli = new CliParser(); + assertNotNull(cli); LOGGER.info(cli.getAppVersion()); } diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java index 2433e3c5c..1dc8d53ef 100644 --- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java +++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +21,14 @@ package org.onap.policy.apex.tools.common.docs; +import static org.junit.Assert.assertNotNull; + //// //// NOTE: This file contains tags for ASCIIDOC //// DO NOT REMOVE any of those tag lines, e.g. ////// tag::** ////// end::** //// - import org.apache.commons.cli.CommandLine; import org.junit.Test; import org.onap.policy.apex.tools.common.CliOptions; @@ -51,6 +53,7 @@ public class ExampleAppVersionTest { // tag::setupParser[] final CliParser cli = new CliParser(); cli.addOption(CliOptions.VERSION); + assertNotNull(cli.getOptions()); final CommandLine cmd = cli.parseCli(args); // end::setupParser[] diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java index 797c7c1e8..c653cd0b2 100644 --- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java +++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,8 @@ package org.onap.policy.apex.tools.common.docs; +import static org.junit.Assert.assertNotNull; + //// ////NOTE: This file contains tags for ASCIIDOC ////DO NOT REMOVE any of those tag lines, e.g. @@ -28,7 +31,6 @@ package org.onap.policy.apex.tools.common.docs; //// ////DO NOT auto-refresh imports or organise imports! //// - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; import org.junit.Test; @@ -62,9 +64,11 @@ public class ExampleCliParserTest { // tag::setCli[] final CliParser cli = new CliParser(); + assertNotNull(cli); cli.addOption(CliOptions.HELP); cli.addOption(CliOptions.VERSION); cli.addOption(CliOptions.MODELFILE); + assertNotNull(cli.getOptions()); // end::setCli[] // tag::parseCli[] |