aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java30
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java28
2 files changed, 34 insertions, 24 deletions
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 a032af650..8591d0470 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 @@ 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);
}
}
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 34ffc4c75..3783c1ba3 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 @@ 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();
}
}