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>
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
index f9b9497..e584085 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
@@ -79,8 +79,11 @@
@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);
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
index 21be883..ad89783 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
@@ -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 @@
@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();
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
index 0e9c71c..69c2d47 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
@@ -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 @@
DirectoryUtils.emptyDirectory(new File("/i/dont/exist"));
File tempDir = Files.createTempDirectory("test").toFile();
+ assertNotNull(tempDir);
Files.createTempDirectory(tempDir.toPath(), "testsubprefix");
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
index 8d85f4e..1477982 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
@@ -23,6 +23,7 @@
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 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);
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
index a032af6..8591d04 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
@@ -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 @@
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 @@
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);
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
index 34ffc4c..3783c1b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
@@ -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 @@
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 @@
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 @@
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();
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
index bbebbc3..edb4a1a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
@@ -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 @@
@Test
public void testStart() {
- apexKafkaConsumer.start();
+ assertThatCode(apexKafkaConsumer::start).doesNotThrowAnyException();
}
@Test
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java
index 520c956..ab20f4b 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java
@@ -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 @@
@Test
public void test() throws Exception {
// verify that constructor does not throw an exception
- Whitebox.invokeConstructor(ApexStarterConstants.class);
+ assertThatCode(() -> Whitebox.invokeConstructor(ApexStarterConstants.class)).doesNotThrowAnyException();
}
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
index 927c1c3..adcec02 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
@@ -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 @@
@Test
public void testApexStarter_Help() {
final String[] apexStarterConfigParameters = { "-h" };
- ApexStarterMain.main(apexStarterConfigParameters);
+ assertThatCode(() -> ApexStarterMain.main(apexStarterConfigParameters)).doesNotThrowAnyException();
}
@Test
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
index 1bdd075..937a89d 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
@@ -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 @@
* @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();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
index a06c49f..108416b 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
@@ -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 @@
*/
@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();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
index f62c7e3..76b3835 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
@@ -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 @@
*/
@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();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
index bb24ed9..499dc59 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
@@ -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 @@
*/
@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();
}
}
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 1263dc4..24a9f60 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 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 58c860d..5e2b051 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 @@
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 8ff1855..6faafe7 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 @@
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 ab14c66..80980bb 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 @@
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 @@
@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 2433e3c..1dc8d53 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 @@
// 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 797c7c1..c653cd0 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 @@
////
////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 @@
// 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[]