summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumerTest.java')
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumerTest.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumerTest.java
new file mode 100644
index 000000000..dd44da7dd
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumerTest.java
@@ -0,0 +1,86 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.service.engine.event.impl.eventrequestor;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.onap.policy.apex.service.engine.event.PeeredReference;
+import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
+import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.producer.ApexFileEventProducer;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+
+public class EventRequestorConsumerTest {
+ private EventRequestorConsumer consumer;
+
+ @Before
+ public void setUp() throws Exception {
+ consumer = new EventRequestorConsumer();
+ }
+
+ @Test
+ public void initNoCarrierTechnologyParameters() {
+ final String consumerName = RandomStringUtils.randomAlphabetic(6);
+ final EventHandlerParameters eventHandlerParameters = new EventHandlerParameters();
+
+ assertThatThrownBy(() -> consumer.init(consumerName, eventHandlerParameters, null))
+ .isInstanceOf(ApexEventException.class);
+ }
+
+ @Test
+ public void initNoPeered() {
+ final String consumerName = RandomStringUtils.randomAlphabetic(6);
+ final EventHandlerParameters eventHandlerParameters = new EventHandlerParameters();
+ eventHandlerParameters.setCarrierTechnologyParameters(new EventRequestorCarrierTechnologyParameters());
+
+ assertThatThrownBy(() -> consumer.init(consumerName, eventHandlerParameters, null))
+ .isInstanceOf(ApexEventException.class);
+ }
+
+ @Test
+ public void getName() throws ApexEventException {
+ final String consumerName = RandomStringUtils.randomAlphabetic(6);
+ final EventHandlerParameters eventHandlerParameters = new EventHandlerParameters();
+ eventHandlerParameters.setCarrierTechnologyParameters(new EventRequestorCarrierTechnologyParameters());
+ eventHandlerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
+
+ consumer.init(consumerName, eventHandlerParameters, null);
+ final String actual = consumer.getName();
+
+ assertEquals(consumerName, actual);
+ }
+
+ @Test
+ public void getSetPeeeredReference() {
+ final PeeredReference peeredReference =
+ new PeeredReference(EventHandlerPeeredMode.REQUESTOR, new ApexFileEventConsumer(),
+ new ApexFileEventProducer());
+ consumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference);
+
+ final PeeredReference actual = consumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR);
+
+ assertEquals(peeredReference, actual);
+ }
+} \ No newline at end of file