diff options
author | Jim Hahn <jrh3@att.com> | 2020-07-28 17:58:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-07-28 17:58:22 +0000 |
commit | 32eae2731c8ac4e7b7787ca620cf19f2b7e5ddd6 (patch) | |
tree | bebf9f80cb26bacd24eda18dfdd21d7c429bf644 /plugins | |
parent | 2169b3fbf66153ea7e066ba0057585822208d6f4 (diff) | |
parent | b2e2d5f8daeefb08873d11de44cb4cfe7cfab03a (diff) |
Merge "SONAR assertions apex-pdp"
Diffstat (limited to 'plugins')
4 files changed, 39 insertions, 25 deletions
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 8d85f4ecb..147798227 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 @@ 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); 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(); } } 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 bbebbc3b8..edb4a1a7b 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 @@ public class ApexKafkaConsumerTest { @Test public void testStart() { - apexKafkaConsumer.start(); + assertThatCode(apexKafkaConsumer::start).doesNotThrowAnyException(); } @Test |