SONAR assertions apex-pdp 49/110549/3
authorwaynedunican <wayne.dunican@est.tech>
Fri, 24 Jul 2020 08:46:36 +0000 (09:46 +0100)
committerwaynedunican <wayne.dunican@est.tech>
Mon, 27 Jul 2020 12:28:30 +0000 (13:28 +0100)
Ensure assertions are present in test cases

Issue-ID: POLICY-2706
Change-Id: I3673a7668564401d2136450b0bdd7a013605dd7c
Signed-off-by: waynedunican <wayne.dunican@est.tech>
19 files changed:
model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java
tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java
tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java
tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java
tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java

index f9b9497..e584085 100644 (file)
@@ -79,8 +79,11 @@ public class EntityTest {
     @Test
     public void testEntityTestBadVals() throws ApexException {
         final DaoParameters daoParameters = new DaoParameters();
+        assertNotNull(daoParameters);
         daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
+        assertEquals("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao", daoParameters.getPluginClass());
         daoParameters.setPersistenceUnit("DaoTest");
+        assertEquals("DaoTest", daoParameters.getPersistenceUnit());
 
         apexDao = new ApexDaoFactory().createApexDao(daoParameters);
         apexDao.init(daoParameters);
index 21be883..ad89783 100644 (file)
@@ -1,25 +1,28 @@
 /*
  * ============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.
  * 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.model.basicmodel.handling;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -33,12 +36,14 @@ public class ApexModelSaverTest {
     @Test
     public void testModelSaver() throws IOException, ApexException {
         AxModel model = new DummyApexBasicModelCreator().getModel();
+        assertNotNull(model);
 
         Path tempPath = Files.createTempDirectory("ApexTest");
+        assertNotNull(tempPath);
 
         ApexModelSaver<AxModel> modelSaver = new ApexModelSaver<AxModel>(AxModel.class, model,
                         tempPath.toAbsolutePath().toString());
-
+        assertNotNull(modelSaver);
         modelSaver.apexModelWriteXml();
         modelSaver.apexModelWriteJson();
 
index 0e9c71c..69c2d47 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.model.utilities;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -35,6 +37,7 @@ public class DirectoryUtilsTest {
         DirectoryUtils.emptyDirectory(new File("/i/dont/exist"));
 
         File tempDir = Files.createTempDirectory("test").toFile();
+        assertNotNull(tempDir);
 
         Files.createTempDirectory(tempDir.toPath(), "testsubprefix");
 
index 8d85f4e..1477982 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.policy.apex.plugins.context.schema.avro;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
 import org.apache.avro.generic.GenericRecord;
@@ -193,6 +194,7 @@ public class AvroSchemaRecordTest {
     public void testVpnRecordReuse() throws IOException {
         final AxContextSchema avroSchema =
                 new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpnReuse);
+        assertNotNull(avroSchema);
         schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
 
         schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
index a032af6..8591d04 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Samsung. All rights reserved.
- *  Modifications Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019-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.
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.plugins.event.carrier.jms;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
@@ -58,22 +60,24 @@ public class ApexJmsConsumerTest {
         apexJmsProducer = new ApexJmsProducer();
     }
 
-    @Test(expected = ApexEventException.class)
+    @Test
     public void testInitWithNonJmsCarrierTechnologyParameters() throws ApexEventException {
         consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {});
-        apexJmsConsumer.init("TestApexJmsConsumer", consumerParameters, incomingEventReceiver);
+        assertThatThrownBy(() -> apexJmsConsumer.init("TestApexJmsConsumer", consumerParameters, incomingEventReceiver))
+            .isInstanceOf(ApexEventException.class);
     }
 
-    @Test(expected = ApexEventException.class)
+    @Test
     public void testInitWithJmsCarrierTechnologyParameters() throws ApexEventException {
         jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
         consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
-        apexJmsConsumer.init("TestApexJmsConsumer", consumerParameters, incomingEventReceiver);
+        assertThatThrownBy(() -> apexJmsConsumer.init("TestApexJmsConsumer", consumerParameters, incomingEventReceiver))
+            .isInstanceOf(ApexEventException.class);
     }
 
     @Test
     public void testStart() {
-        apexJmsConsumer.start();
+        assertThatCode(apexJmsConsumer::start).doesNotThrowAnyException();
     }
 
     @Test
@@ -94,20 +98,20 @@ public class ApexJmsConsumerTest {
         assertNotNull(apexJmsConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
     }
 
-    @Test(expected = ApexEventRuntimeException.class)
+    @Test
     public void testRun() {
-        apexJmsConsumer.run();
-
+        assertThatThrownBy(apexJmsConsumer::run).isInstanceOf(ApexEventRuntimeException.class);
     }
 
-    @Test(expected = ApexEventRuntimeException.class)
+    @Test
     public void testOnMessage() {
         Message jmsMessage = null;
-        apexJmsConsumer.onMessage(jmsMessage);
+        assertThatThrownBy(() -> apexJmsConsumer.onMessage(jmsMessage))
+            .isInstanceOf(ApexEventRuntimeException.class);
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testStop() {
-        apexJmsConsumer.stop();
+        assertThatThrownBy(apexJmsConsumer::stop).isInstanceOf(NullPointerException.class);
     }
 }
index 34ffc4c..3783c1b 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Samsung. All rights reserved.
- *  Modifications Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019-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.
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.plugins.event.carrier.jms;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
@@ -61,17 +63,19 @@ public class ApexJmsProducerTest {
         apexJmsProducer = new ApexJmsProducer();
     }
 
-    @Test(expected = ApexEventException.class)
-    public void testInitWithNonJmsCarrierTechnologyParameters() throws ApexEventException {
+    @Test
+    public void testInitWithNonJmsCarrierTechnologyParameters() {
         producerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {});
-        apexJmsProducer.init("TestApexJmsProducer", producerParameters);
+        assertThatThrownBy(() -> apexJmsProducer.init("TestApexJmsProducer", producerParameters))
+            .isInstanceOf(ApexEventException.class);
     }
 
-    @Test(expected = ApexEventException.class)
+    @Test
     public void testInitWithJmsCarrierTechnologyParameters() throws ApexEventException {
         jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
         producerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
-        apexJmsProducer.init("TestApexJmsProducer", producerParameters);
+        assertThatThrownBy(() -> apexJmsProducer.init("TestApexJmsProducer", producerParameters))
+            .isInstanceOf(ApexEventException.class);
     }
 
     @Test
@@ -92,7 +96,7 @@ public class ApexJmsProducerTest {
         assertNotNull(apexJmsProducer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testSendEvent() throws ApexEventException {
         producerParameters.setCarrierTechnologyParameters(new JmsCarrierTechnologyParameters() {});
         synchronousEventCache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS,
@@ -101,21 +105,23 @@ public class ApexJmsProducerTest {
                 synchronousEventCache);
         ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
                 "testSource", "testTarget");
-        apexJmsProducer.sendEvent(1000L, null, "TestApexJmsProducer", apexEvent);
+        assertThatThrownBy(() -> apexJmsProducer.sendEvent(1000L, null, "TestApexJmsProducer", apexEvent))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = ApexEventRuntimeException.class)
+    @Test
     public void testSendEventWithNonSerializableObject() throws ApexEventException {
         producerParameters.setCarrierTechnologyParameters(new JmsCarrierTechnologyParameters() {});
         synchronousEventCache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS,
                 apexJmsConsumer, apexJmsProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT);
         apexJmsProducer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS,
                 synchronousEventCache);
-        apexJmsProducer.sendEvent(-1L, null, "TestApexJmsProducer", new ApexJmsProducerTest());
+        assertThatThrownBy(() -> apexJmsProducer.sendEvent(-1L, null, "TestApexJmsProducer", new ApexJmsProducerTest()))
+            .isInstanceOf(ApexEventRuntimeException.class);
     }
 
     @Test
     public void testStop() {
-        apexJmsProducer.stop();
+        assertThatCode(apexJmsProducer::stop).doesNotThrowAnyException();
     }
 }
index bbebbc3..edb4a1a 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Samsung. 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,7 @@
 
 package org.onap.policy.apex.plugins.event.carrier.kafka;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -57,7 +59,7 @@ public class ApexKafkaConsumerTest {
 
     @Test
     public void testStart() {
-        apexKafkaConsumer.start();
+        assertThatCode(apexKafkaConsumer::start).doesNotThrowAnyException();
     }
 
     @Test
index 520c956..ab20f4b 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  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.services.onappf;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+
 import org.junit.Test;
 import org.powermock.reflect.Whitebox;
 
@@ -32,6 +35,6 @@ public class TestApexStarterConstants {
     @Test
     public void test() throws Exception {
         // verify that constructor does not throw an exception
-        Whitebox.invokeConstructor(ApexStarterConstants.class);
+        assertThatCode(() -> Whitebox.invokeConstructor(ApexStarterConstants.class)).doesNotThrowAnyException();
     }
 }
index 927c1c3..adcec02 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2020 Nordix Foundation.
+ *  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,7 @@
 
 package org.onap.policy.apex.services.onappf;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -95,7 +97,7 @@ public class TestApexStarterMain {
     @Test
     public void testApexStarter_Help() {
         final String[] apexStarterConfigParameters = { "-h" };
-        ApexStarterMain.main(apexStarterConfigParameters);
+        assertThatCode(() -> ApexStarterMain.main(apexStarterConfigParameters)).doesNotThrowAnyException();
     }
 
     @Test
index 1bdd075..937a89d 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.testsuites.integration.executor.engine;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+
 import java.io.IOException;
 import org.junit.After;
 import org.junit.Before;
@@ -96,8 +98,10 @@ public class TestApexEngineJava {
      * @throws ApexException the apex exception
      */
     @Test
-    public void testApexEngineJava() throws InterruptedException, IOException, ApexException {
-        new TestApexEngine("JAVA", engineParameters);
-        new TestApexEngine("JAVA", engineParameters);
+    public void testApexEngineJava() {
+        assertThatCode(() -> {
+            new TestApexEngine("JAVA", engineParameters);
+            new TestApexEngine("JAVA", engineParameters);
+        }).doesNotThrowAnyException();
     }
 }
index a06c49f..108416b 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.testsuites.integration.executor.engine;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+
 import java.io.IOException;
 import org.junit.After;
 import org.junit.Before;
@@ -95,8 +97,9 @@ public class TestApexEngineJavascript {
      */
     @Test
     public void testApexEngineJavascript() throws ApexException, InterruptedException, IOException {
-
-        new TestApexEngine("JAVASCRIPT", engineParameters);
-        new TestApexEngine("JAVASCRIPT", engineParameters);
+        assertThatCode(() -> {
+            new TestApexEngine("JAVASCRIPT", engineParameters);
+            new TestApexEngine("JAVASCRIPT", engineParameters);
+        }).doesNotThrowAnyException();
     }
 }
index f62c7e3..76b3835 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.testsuites.integration.executor.engine;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+
 import java.io.IOException;
 import org.junit.After;
 import org.junit.Before;
@@ -98,7 +100,9 @@ public class TestApexEngineJython {
      */
     @Test
     public void testApexEngineJython() throws ApexException, InterruptedException, IOException {
-        new TestApexEngine("JAVASCRIPT", engineParameters);
-        new TestApexEngine("JAVASCRIPT", engineParameters);
+        assertThatCode(() -> {
+            new TestApexEngine("JAVASCRIPT", engineParameters);
+            new TestApexEngine("JAVASCRIPT", engineParameters);
+        }).doesNotThrowAnyException();
     }
 }
index bb24ed9..499dc59 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.testsuites.integration.executor.engine;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+
 import java.io.IOException;
 import org.junit.After;
 import org.junit.Before;
@@ -95,7 +97,9 @@ public class TestApexEngineMvel {
      */
     @Test
     public void testApexEngineMvel() throws ApexException, InterruptedException, IOException {
-        new TestApexEngine("MVEL", engineParameters);
-        new TestApexEngine("MVEL", engineParameters);
+        assertThatCode(() -> {
+            new TestApexEngine("MVEL", engineParameters);
+            new TestApexEngine("MVEL", engineParameters);
+        }).doesNotThrowAnyException();
     }
 }
index 1263dc4..24a9f60 100644 (file)
@@ -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
index 58c860d..5e2b051 100644 (file)
@@ -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();
 
     }
 
index 8ff1855..6faafe7 100644 (file)
@@ -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
index ab14c66..80980bb 100644 (file)
@@ -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());
     }
 
index 2433e3c..1dc8d53 100644 (file)
@@ -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.
 
 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[]
 
index 797c7c1..c653cd0 100644 (file)
@@ -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[]