diff options
Diffstat (limited to 'plugins')
11 files changed, 7 insertions, 708 deletions
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml index 1e639fe01..824ea281a 100644 --- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml +++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. + Modifications Copyright (C) 2022 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -37,12 +38,6 @@ <version>${version.hazelcast}</version> </dependency> <dependency> - <groupId>org.onap.policy.apex-pdp.core</groupId> - <artifactId>core-infrastructure</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId> <artifactId>plugins-context-distribution-hazelcast</artifactId> <version>${project.version}</version> @@ -55,4 +50,4 @@ <scope>test</scope> </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/pom.xml deleted file mode 100644 index d50e25cac..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 Ericsson. All rights reserved. - ================================================================================ - 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========================================================= ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId> - <artifactId>plugins-event-carrier</artifactId> - <version>2.7.1-SNAPSHOT</version> - </parent> - - <artifactId>plugins-event-carrier-websocket</artifactId> - <name>${project.artifactId}</name> - <description>[${project.parent.artifactId}] Plugin for handling events being transported over web sockets</description> - - <dependencies> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project>
\ No newline at end of file diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java deleted file mode 100644 index c776e154f..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============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.plugins.event.carrier.websocket; - -import java.util.Properties; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventReceiver; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Concrete implementation an Apex event consumer that receives events using Kafka. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ApexWebSocketConsumer extends ApexPluginsEventConsumer implements WsStringMessageListener { - private static final int WEB_SOCKET_WAIT_SLEEP_TIME = 100; - - // Get a reference to the logger - private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketConsumer.class); - - // The web socket messager, may be WS a server or a client - private WsStringMessager wsStringMessager; - - // The event receiver that will receive events from this consumer - private ApexEventReceiver eventReceiver; - - // The number of events read to date - private int eventsRead = 0; - - @Override - public void init(final String consumerName, final EventHandlerParameters consumerParameters, - final ApexEventReceiver incomingEventReceiver) throws ApexEventException { - this.eventReceiver = incomingEventReceiver; - this.name = consumerName; - - // Check and get the Kafka Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) { - LOGGER.warn("specified consumer properties are not applicable to a web socket consumer"); - throw new ApexEventException("specified consumer properties are not applicable to a web socket consumer"); - } - - // The Web Socket properties - WebSocketCarrierTechnologyParameters webSocketConsumerProperties = - (WebSocketCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); - - // Check if this is a server or a client Web Socket - if (webSocketConsumerProperties.isWsClient()) { - // Create a WS client - wsStringMessager = new WsStringMessageClient(webSocketConsumerProperties.getHost(), - webSocketConsumerProperties.getPort()); - } else { - wsStringMessager = new WsStringMessageServer(webSocketConsumerProperties.getPort()); - } - - // Start reception of event strings on the web socket - try { - wsStringMessager.start(this); - } catch (final MessagingException e) { - LOGGER.warn("could not start web socket consumer", e); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void run() { - while (consumerThread.isAlive() && !stopOrderedFlag) { - ThreadUtilities.sleep(WEB_SOCKET_WAIT_SLEEP_TIME); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void stop() { - if (wsStringMessager != null) { - wsStringMessager.stop(); - } - stopOrderedFlag = true; - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String eventString) { - try { - eventReceiver.receiveEvent(new Properties(), eventString); - eventsRead++; - } catch (final Exception e) { - final String errorMessage = "Error sending event " + name + '_' + eventsRead + ", " + e.getMessage() - + ", event:\n" + eventString; - LOGGER.warn(errorMessage, e); - } - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java deleted file mode 100644 index 6256ec425..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============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.plugins.event.carrier.websocket; - -import java.util.Properties; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Concrete implementation of an Apex event producer that sends events using a web socket. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ApexWebSocketProducer extends ApexPluginsEventProducer implements WsStringMessageListener { - // Get a reference to the logger - private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketProducer.class); - - // The web socket messager, may be WS a server or a client - private WsStringMessager wsStringMessager; - - @Override - public void init(final String producerName, final EventHandlerParameters producerParameters) - throws ApexEventException { - this.name = producerName; - - // Check and get the web socket Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) { - String message = - "specified producer properties for " + this.name + "are not applicable to a web socket producer"; - LOGGER.warn(message); - throw new ApexEventException("specified producer properties are not applicable to a web socket producer"); - } - // The Web Socket properties - WebSocketCarrierTechnologyParameters webSocketProducerProperties = - (WebSocketCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); - - // Check if this is a server or a client Web Socket - if (webSocketProducerProperties.isWsClient()) { - // Create a WS client - wsStringMessager = new WsStringMessageClient(webSocketProducerProperties.getHost(), - webSocketProducerProperties.getPort()); - } else { - wsStringMessager = new WsStringMessageServer(webSocketProducerProperties.getPort()); - } - - // Start reception of event strings on the web socket - try { - wsStringMessager.start(this); - } catch (final MessagingException e) { - String message = "could not start web socket producer (" + this.name + ")"; - LOGGER.warn(message, e); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void sendEvent(final long executionId, final Properties executionProperties, final String eventName, - final Object event) { - super.sendEvent(executionId, executionProperties, eventName, event); - - wsStringMessager.sendString((String) event); - } - - /** - * {@inheritDoc}. - */ - @Override - public void stop() { - if (wsStringMessager != null) { - wsStringMessager.stop(); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String messageString) { - String message = "received message \"" + messageString + "\" on web socket producer (" + this.name - + ") , no messages should be received on a web socket producer"; - LOGGER.warn(message); - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java deleted file mode 100644 index 89588ec37..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.plugins.event.carrier.websocket; - -import lombok.Getter; -import org.apache.commons.lang3.StringUtils; -import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.parameters.annotations.Max; -import org.onap.policy.common.parameters.annotations.Min; -import org.onap.policy.models.base.Validated; - -/** - * Apex parameters for Kafka as an event carrier technology. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -@Getter -public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters { - // @formatter:off - private static final int MIN_USER_PORT = 1024; - private static final int MAX_USER_PORT = 65535; - - /** The label of this carrier technology. */ - public static final String WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL = "WEBSOCKET"; - - /** The producer plugin class for the web socket carrier technology. */ - public static final String WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS = ApexWebSocketProducer.class.getName(); - - /** The consumer plugin class for the web socket carrier technology. */ - public static final String KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS = ApexWebSocketConsumer.class.getName(); - - // Default parameter values - private static final String DEFAULT_HOST = "localhost"; - private static final int DEFAULT_PORT = -1; - - // Web socket parameters - private boolean wsClient = true; - private String host = DEFAULT_HOST; - @Min(MIN_USER_PORT) - @Max(MAX_USER_PORT) - private int port = DEFAULT_PORT; - // @formatter:on - - /** - * Constructor to create a web socket carrier technology parameters instance and register the instance with the - * parameter service. - */ - public WebSocketCarrierTechnologyParameters() { - super(); - - // Set the carrier technology properties for the web socket carrier technology - this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL); - this.setEventProducerPluginClass(WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS); - this.setEventConsumerPluginClass(KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS); - } - - /** - * {@inheritDoc}. - */ - @Override - public BeanValidationResult validate() { - final BeanValidationResult result = super.validate(); - - if (wsClient && StringUtils.isBlank(host)) { - result.addResult("host", host, ValidationStatus.INVALID, Validated.IS_BLANK); - } - - return result; - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/package-info.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/package-info.java deleted file mode 100644 index 9555ea447..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * 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========================================================= - */ - -/** - * Implements the APEX event carrier technology plugin for web sockets. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ - -package org.onap.policy.apex.plugins.event.carrier.websocket; diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumerTest.java deleted file mode 100644 index 3021b8af2..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumerTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Samsung. All rights reserved. - * Modifications Copyright (C) 2019 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.plugins.event.carrier.websocket; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.stubbing.Answer; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventProducer; -import org.onap.policy.apex.service.engine.event.ApexEventReceiver; -import org.onap.policy.apex.service.engine.event.PeeredReference; -import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; - -public class ApexWebSocketConsumerTest { - - ApexWebSocketConsumer apexWebSocketConsumer = null; - EventHandlerParameters consumerParameters = null; - ApexEventReceiver incomingEventReceiver = null; - ApexEventProducer apexWebSocketProducer = null; - WebSocketCarrierTechnologyParameters webSocketCarrierTechnologyParameters = null; - - /** - * Set up testing. - * - * @throws Exception on test set up errors. - */ - @Before - public void setUp() throws Exception { - apexWebSocketConsumer = new ApexWebSocketConsumer(); - consumerParameters = new EventHandlerParameters(); - apexWebSocketProducer = new ApexWebSocketProducer(); - apexWebSocketConsumer.start(); - } - - @After - public void tearDown() { - apexWebSocketConsumer.stop(); - } - - @Test(expected = ApexEventException.class) - public void testInitWithNonWebSocketCarrierTechnologyParameters() throws ApexEventException { - consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {}); - apexWebSocketConsumer.init("TestApexWebSocketConsumer", consumerParameters, - incomingEventReceiver); - } - - @Test - public void testInitWithWebSocketCarrierTechnologyParameters() throws ApexEventException { - webSocketCarrierTechnologyParameters = new WebSocketCarrierTechnologyParameters(); - consumerParameters.setCarrierTechnologyParameters(webSocketCarrierTechnologyParameters); - apexWebSocketConsumer.init("TestApexWebSocketConsumer", consumerParameters, - incomingEventReceiver); - assertEquals("TestApexWebSocketConsumer", apexWebSocketConsumer.getName()); - } - - @Test - public void testGetName() { - assertNull(apexWebSocketConsumer.getName()); - } - - @Test - public void testGetPeeredReference() { - assertNull(apexWebSocketConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR)); - } - - @Test - public void testSetPeeredReference() { - PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR, - apexWebSocketConsumer, apexWebSocketProducer); - apexWebSocketConsumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference); - assertNotNull(apexWebSocketConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR)); - } - - @Test - public void testReceiveString() { - MockitoAnnotations.initMocks(this); - ApexWebSocketConsumer apexWebSocketConsumerMock = Mockito.mock(ApexWebSocketConsumer.class); - - Mockito.doAnswer((Answer<?>) invocation -> { - Object[] args = invocation.getArguments(); - assertEquals("TestRecieveString", args[0]); - return null; - }).when(apexWebSocketConsumerMock).receiveString("TestRecieveString"); - - apexWebSocketConsumerMock.receiveString("TestRecieveString"); - - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducerTest.java deleted file mode 100644 index d4b3114d5..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducerTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Samsung. All rights reserved. - * Modifications Copyright (C) 2019 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.plugins.event.carrier.websocket; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.stubbing.Answer; -import org.onap.policy.apex.service.engine.event.ApexEventConsumer; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventReceiver; -import org.onap.policy.apex.service.engine.event.PeeredReference; -import org.onap.policy.apex.service.engine.event.SynchronousEventCache; -import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; - -public class ApexWebSocketProducerTest { - - ApexWebSocketProducer apexWebSocketProducer = null; - EventHandlerParameters producerParameters = null; - ApexEventReceiver incomingEventReceiver = null; - ApexEventConsumer apexWebSocketConsumer = null; - WebSocketCarrierTechnologyParameters webSocketCarrierTechnologyParameters = null; - SynchronousEventCache synchronousEventCache = null; - private static final long DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT = 1000; - - /** - * Set up testing. - * - * @throws Exception on test set up errors. - */ - @Before - public void setUp() throws Exception { - apexWebSocketConsumer = new ApexWebSocketConsumer(); - producerParameters = new EventHandlerParameters(); - apexWebSocketProducer = new ApexWebSocketProducer(); - } - - @After - public void tearDown() { - apexWebSocketProducer.stop(); - } - - @Test(expected = ApexEventException.class) - public void testInitWithNonWebSocketCarrierTechnologyParameters() throws ApexEventException { - producerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {}); - apexWebSocketProducer.init("TestApexWebSocketProducer", producerParameters); - } - - @Test - public void testInitWithWebSocketCarrierTechnologyParameters() throws ApexEventException { - webSocketCarrierTechnologyParameters = new WebSocketCarrierTechnologyParameters(); - producerParameters.setCarrierTechnologyParameters(webSocketCarrierTechnologyParameters); - apexWebSocketProducer.init("TestApexWebSocketProducer", producerParameters); - assertEquals("TestApexWebSocketProducer", apexWebSocketProducer.getName()); - } - - @Test - public void testGetName() { - assertNull(apexWebSocketProducer.getName()); - } - - @Test - public void testGetPeeredReference() { - assertNull(apexWebSocketProducer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR)); - } - - @Test - public void testSetPeeredReference() { - PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR, - apexWebSocketConsumer, apexWebSocketProducer); - apexWebSocketProducer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference); - assertNotNull(apexWebSocketProducer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR)); - } - - @Test(expected = NullPointerException.class) - public void testSendEvent() throws ApexEventException { - producerParameters - .setCarrierTechnologyParameters(new WebSocketCarrierTechnologyParameters() {}); - synchronousEventCache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, - apexWebSocketConsumer, apexWebSocketProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT); - apexWebSocketProducer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, - synchronousEventCache); - apexWebSocketProducer.sendEvent(1000L, null, "TestApexWebSocketProducer", "apexEvent"); - } - - @Test - public void testReceiveString() { - MockitoAnnotations.initMocks(this); - ApexWebSocketProducer apexWebSocketProducerMock = Mockito.mock(ApexWebSocketProducer.class); - - Mockito.doAnswer((Answer<?>) invocation -> { - Object[] args = invocation.getArguments(); - assertEquals("TestRecieveString", args[0]); - return null; - }).when(apexWebSocketProducerMock).receiveString("TestRecieveString"); - - apexWebSocketProducerMock.receiveString("TestRecieveString"); - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParametersTest.java deleted file mode 100644 index f318c000a..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/test/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParametersTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Samsung. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.plugins.event.carrier.websocket; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.common.parameters.ValidationResult; - -public class WebSocketCarrierTechnologyParametersTest { - - WebSocketCarrierTechnologyParameters webSocketCarrierTechnologyParameters = null; - ValidationResult result = null; - - /** - * Set up testing. - * - * @throws Exception on test set up errors. - */ - @Before - public void setUp() throws Exception { - webSocketCarrierTechnologyParameters = new WebSocketCarrierTechnologyParameters(); - } - - @Test - public void testWebSocketCarrierTechnologyParameters() { - assertNotNull(webSocketCarrierTechnologyParameters); - } - - @Test - public void testValidate() { - result = webSocketCarrierTechnologyParameters.validate(); - assertNotNull(result); - assertFalse(result.getStatus().isValid()); - } - -} diff --git a/plugins/plugins-event/plugins-event-carrier/pom.xml b/plugins/plugins-event/plugins-event-carrier/pom.xml index 02e9af622..6949815f1 100644 --- a/plugins/plugins-event/plugins-event-carrier/pom.xml +++ b/plugins/plugins-event/plugins-event-carrier/pom.xml @@ -2,7 +2,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. - Modifications Copyright (C) 2020 Nordix Foundation. + Modifications Copyright (C) 2020,2022 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -36,11 +36,10 @@ <modules> <module>plugins-event-carrier-kafka</module> - <module>plugins-event-carrier-websocket</module> <module>plugins-event-carrier-jms</module> <module>plugins-event-carrier-restclient</module> <module>plugins-event-carrier-restserver</module> <module>plugins-event-carrier-restrequestor</module> <module>plugins-event-carrier-grpc</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/plugins/plugins-executor/pom.xml b/plugins/plugins-executor/pom.xml index daf982d48..f2e9633e5 100644 --- a/plugins/plugins-executor/pom.xml +++ b/plugins/plugins-executor/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. + Modifications Copyright (C) 2022 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ <dependencies> <dependency> <groupId>org.onap.policy.apex-pdp.core</groupId> - <artifactId>core-engine</artifactId> + <artifactId>core</artifactId> <version>${project.version}</version> </dependency> </dependencies> @@ -47,4 +48,4 @@ <!--module>plugins-executor-jython</module--> <module>plugins-executor-mvel</module> </modules> -</project>
\ No newline at end of file +</project> |