@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);
/*
* ============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;
@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();
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;
DirectoryUtils.emptyDirectory(new File("/i/dont/exist"));
File tempDir = Files.createTempDirectory("test").toFile();
+ assertNotNull(tempDir);
Files.createTempDirectory(tempDir.toPath(), "testsubprefix");
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;
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);
/*-
* ============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.
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;
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
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);
}
}
/*-
* ============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.
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;
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
assertNotNull(apexJmsProducer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testSendEvent() throws ApexEventException {
producerParameters.setCarrierTechnologyParameters(new JmsCarrierTechnologyParameters() {});
synchronousEventCache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS,
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();
}
}
/*-
* ============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.
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;
@Test
public void testStart() {
- apexKafkaConsumer.start();
+ assertThatCode(apexKafkaConsumer::start).doesNotThrowAnyException();
}
@Test
/*-
* ============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.
package org.onap.policy.apex.services.onappf;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
import org.junit.Test;
import org.powermock.reflect.Whitebox;
@Test
public void test() throws Exception {
// verify that constructor does not throw an exception
- Whitebox.invokeConstructor(ApexStarterConstants.class);
+ assertThatCode(() -> Whitebox.invokeConstructor(ApexStarterConstants.class)).doesNotThrowAnyException();
}
}
/*-
* ============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.
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;
@Test
public void testApexStarter_Help() {
final String[] apexStarterConfigParameters = { "-h" };
- ApexStarterMain.main(apexStarterConfigParameters);
+ assertThatCode(() -> ApexStarterMain.main(apexStarterConfigParameters)).doesNotThrowAnyException();
}
@Test
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;
* @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();
}
}
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;
*/
@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();
}
}
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;
*/
@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();
}
}
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;
*/
@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();
}
}
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;
public void testModel2Cli() {
final String[] cliArgs = {"-h"};
- Model2CliMain.main(cliArgs);
+ assertThatCode(() -> Model2CliMain.main(cliArgs)).doesNotThrowAnyException();
}
@Test
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;
final String[] EventArgs =
{ "-h" };
- Model2EventMain.main(EventArgs);
+ assertThatCode(() -> Model2EventMain.main(EventArgs)).doesNotThrowAnyException();
}
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;
final String[] EventArgs =
{ "-h" };
- WsClientMain.main(EventArgs);
+ assertThatCode(() -> WsClientMain.main(EventArgs)).doesNotThrowAnyException();
}
@Test
/*-
* ============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.
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;
@Test
public void testappVersion() {
final CliParser cli = new CliParser();
+ assertNotNull(cli);
LOGGER.info(cli.getAppVersion());
}
/*-
* ============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;
// tag::setupParser[]
final CliParser cli = new CliParser();
cli.addOption(CliOptions.VERSION);
+ assertNotNull(cli.getOptions());
final CommandLine cmd = cli.parseCli(args);
// end::setupParser[]
/*-
* ============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.
////
////DO NOT auto-refresh imports or organise imports!
////
-
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.junit.Test;
// 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[]