aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-common
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-common')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/pom.xml41
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImpl.java12
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java37
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java40
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/EventSenderMock.java67
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImplTest.java50
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/MockEventSender.java52
8 files changed, 98 insertions, 205 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/pom.xml b/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
index d478c83e3..d0b3786ba 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
+++ b/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
@@ -3,7 +3,7 @@
============LICENSE_START=======================================================
ONAP : APPC
================================================================================
- Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
Copyright (C) 2017 Amdocs
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,42 +46,8 @@
</dependency>
<dependency>
<groupId>org.onap.appc</groupId>
- <artifactId>appc-message-adapter-api</artifactId>
+ <artifactId>appc-service-communicator-bundle</artifactId>
<version>${project.version}</version>
- <scope>provided</scope>
- <!-- TODO: WA for fixing build, clueanup dependency tree -->
- <exclusions>
- <exclusion>
- <groupId>equinoxSDK381</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-dmaap-adapter-bundle</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <!-- TODO: WA for fixing build, clueanup dependency tree -->
- <exclusions>
- <exclusion>
- <groupId>equinoxSDK381</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-message-adapter-factory</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <!-- TODO: WA for fixing build, clueanup dependency tree -->
- <exclusions>
- <exclusion>
- <groupId>equinoxSDK381</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
@@ -224,8 +190,7 @@
<Bundle-SymbolicName>appc-dg-common</Bundle-SymbolicName>
<Export-Package>org.onap.appc.dg.common,org.onap.appc.dg.common.objects,org.onap.appc.dg.common.utils</Export-Package>
<Private-Package>org.onap.appc.dg.common.impl.*</Private-Package>
- <Import-Package>org.onap.appc.adapter.message.*,org.onap.appc.adapter.factory.*,org.onap.appc.adapter.messaging.*,
- *;resolution:=optional</Import-Package>
+ <Import-Package>org.onap.appc.srvcomm.messaging.event,org.onap.appc.srvcomm.messaging,*;resolution:=optional</Import-Package>
<Embed-Dependency>appc-dg-mdsal-bundle,appc-dg-domain-model-lib,appc-dg-dependency-model,jackson-dataformat-yaml,jackson-databind,jackson-core,jackson-annotations;scope=compile|runtime;inline=false;artifactId=!org.eclipse.osgi</Embed-Dependency>
<!--Embed-Dependency>eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency-->
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImpl.java
index b244d31db..c69d1fe52 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
@@ -25,11 +25,11 @@ package org.onap.appc.dg.common.impl;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
-import org.onap.appc.adapter.message.EventSender;
-import org.onap.appc.adapter.message.MessageDestination;
-import org.onap.appc.adapter.message.event.EventHeader;
-import org.onap.appc.adapter.message.event.EventMessage;
-import org.onap.appc.adapter.message.event.EventStatus;
+import org.onap.appc.srvcomm.messaging.event.EventSender;
+import org.onap.appc.srvcomm.messaging.MessageDestination;
+import org.onap.appc.srvcomm.messaging.event.EventHeader;
+import org.onap.appc.srvcomm.messaging.event.EventMessage;
+import org.onap.appc.srvcomm.messaging.event.EventStatus;
import org.onap.appc.dg.common.DCAEReporterPlugin;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java
index 4cef62581..3efbc02e3 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* ================================================================================
@@ -36,11 +36,10 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
-import org.onap.appc.adapter.message.MessageAdapterFactory;
-import org.onap.appc.adapter.message.Producer;
import org.onap.appc.configuration.ConfigurationFactory;
import org.onap.appc.dg.common.IntermediateMessageSender;
import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.srvcomm.messaging.MessagingConnector;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -52,8 +51,9 @@ public class IntermediateMessageSenderImpl implements IntermediateMessageSender
private static final String PARAM_MESSAGE = "message";
private static final String ATTR_REQUEST_ID = "input.common-header.request-id";
+ private static final String PROPERTIES_PREFIX = "appc.LCM";
- private Producer producer;
+ private MessagingConnector messageService;
private static final String STATUS = "STATUS";
private static final String FAILURE = "FAILURE";
@@ -64,29 +64,10 @@ public class IntermediateMessageSenderImpl implements IntermediateMessageSender
private static final String MSO = "MSO";
public void init() {
- Properties properties = ConfigurationFactory.getConfiguration().getProperties();
-
- String writeTopic = properties.getProperty("appc.LCM.topic.write");
- String apiKey = properties.getProperty("appc.LCM.client.key");
- String apiSecret = properties.getProperty("appc.LCM.client.secret");
- String hostNames = properties.getProperty("appc.LCM.poolMembers");
-
- logger.debug("Configuration Read : writeTopic = " + writeTopic + ", " +
- "hostNames = " + hostNames);
-
- Set<String> pool = new HashSet<>();
- if (!StringUtils.isEmpty(hostNames)) {
- pool.addAll(Arrays.asList(hostNames.split(",")));
- }
-
- BundleContext ctx = FrameworkUtil.getBundle(IntermediateMessageSenderImpl.class).getBundleContext();
- if (ctx != null) {
- ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
- if (svcRef != null) {
- MessageAdapterFactory messageAdapterFactory = ((MessageAdapterFactory) ctx.getService(svcRef));
- producer = messageAdapterFactory.createProducer(pool, writeTopic, apiKey, apiSecret);
- }
- }
+ messageService = new MessagingConnector();
+ }
+ public void init(MessagingConnector messagingConnector) {
+ messageService = messagingConnector;
}
@Override
@@ -97,7 +78,7 @@ public class IntermediateMessageSenderImpl implements IntermediateMessageSender
validateInputs(params, context);
String jsonMessage = getJsonMessage(params, context);
logger.debug("Constructed JSON Message : " + jsonMessage);
- producer.post("", jsonMessage);
+ messageService.publishMessage(PROPERTIES_PREFIX, "", jsonMessage);
context.setAttribute(prefix + STATUS, SUCCESS);
} catch (Exception e) {
String errorMessage = "Error sending intermediate message to initiator " + e.getMessage();
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index ff6b824f2..a90f463b9 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -3,7 +3,7 @@
============LICENSE_START=======================================================
ONAP : APPC
================================================================================
- Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
================================================================================
Copyright (C) 2017 Amdocs
=============================================================================
@@ -33,7 +33,7 @@
<service id="JsonDgUtil" interface="org.onap.appc.dg.common.JsonDgUtil" ref="JsonDgUtilBean"/>
<reference id="eventSenderReference" availability="mandatory" activation="eager"
- interface="org.onap.appc.adapter.message.EventSender"/>
+ interface="org.onap.appc.srvcomm.messaging.event.EventSender"/>
<bean id="DCAEReporterPluginBean" class="org.onap.appc.dg.common.impl.DCAEReporterPluginImpl"
scope="singleton">
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java
index 95f7ba755..1816f52f9 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* ================================================================================
@@ -30,27 +30,16 @@ import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.Spy;
-import org.onap.appc.adapter.message.EventSender;
-import org.onap.appc.adapter.message.MessageDestination;
-import org.onap.appc.adapter.message.event.EventMessage;
import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.srvcomm.messaging.MessageDestination;
+import org.onap.appc.srvcomm.messaging.event.EventMessage;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(FrameworkUtil.class)
public class DCAEReporterPluginImplTest {
private SvcLogicContext ctx;
private Map<String, String> params;
@@ -59,10 +48,8 @@ public class DCAEReporterPluginImplTest {
private final Bundle bundleService = Mockito.mock(Bundle.class);
private final ServiceReference sref = Mockito.mock(ServiceReference.class);
- @InjectMocks
private DCAEReporterPluginImpl dcaeReporterPlugin;
- @Spy
- private EventSenderMock eventSender = new EventSenderMock();
+ private MockEventSender eventSender;
private String apiVer = "2.0.0";
private String requestId = "123";
@@ -71,11 +58,10 @@ public class DCAEReporterPluginImplTest {
@SuppressWarnings("unchecked")
@Before
public void setUp() throws NoSuchFieldException, IllegalAccessException {
- PowerMockito.mockStatic(FrameworkUtil.class);
- PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
- PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
- PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref);
- PowerMockito.when(bundleContext.<EventSender>getService(sref)).thenReturn(eventSender);
+ eventSender = new MockEventSender();
+ dcaeReporterPlugin = new DCAEReporterPluginImpl();
+ dcaeReporterPlugin.setEventSender(eventSender);
+
}
@Test
@@ -110,7 +96,7 @@ public class DCAEReporterPluginImplTest {
ctx.setAttribute("input.common-header.api-ver", apiVer);
ctx.setAttribute("input.common-header.request-id", requestId);
dcaeReporterPlugin.report(params, ctx);
- EventMessage msg = eventSender.getMsg();
+ EventMessage msg = eventSender.getMessage();
Assert.assertEquals("ERROR DESCRIPTION", msg.getEventStatus().getReason());
}
@@ -120,14 +106,15 @@ public class DCAEReporterPluginImplTest {
params = new HashMap<>();
params.put(Constants.DG_ERROR_CODE, "200");
dcaeReporterPlugin.reportSuccess(params, ctx);
- EventMessage msg = eventSender.getMsg();
+ EventMessage msg = eventSender.getMessage();
Assert.assertEquals(new Integer(500), msg.getEventStatus().getCode());
}
private void errorReasonNullAssert() throws APPCException {
+ eventSender.reset();
dcaeReporterPlugin.report(params, ctx);
MessageDestination destination = eventSender.getDestination();
- EventMessage msg = eventSender.getMsg();
+ EventMessage msg = eventSender.getMessage();
Assert.assertEquals("wrong API version", apiVer, msg.getEventHeader().getApiVer());
Assert.assertEquals("wrong requestId", requestId, msg.getEventHeader().getEventId());
Assert.assertEquals("wrong error message", "Unknown", msg.getEventStatus().getReason());
@@ -135,9 +122,10 @@ public class DCAEReporterPluginImplTest {
}
private void positiveAssert() throws APPCException {
+ eventSender.reset();
dcaeReporterPlugin.report(params, ctx);
MessageDestination destination = eventSender.getDestination();
- EventMessage msg = eventSender.getMsg();
+ EventMessage msg = eventSender.getMessage();
Assert.assertEquals("wrong API version", apiVer, msg.getEventHeader().getApiVer());
Assert.assertEquals("wrong requestId", requestId, msg.getEventHeader().getEventId());
Assert.assertEquals("wrong error message", error, msg.getEventStatus().getReason());
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/EventSenderMock.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/EventSenderMock.java
deleted file mode 100644
index 54959958d..000000000
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/EventSenderMock.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.dg.common.impl;
-
-import java.util.Map;
-import org.onap.appc.adapter.message.EventSender;
-import org.onap.appc.adapter.message.MessageDestination;
-import org.onap.appc.adapter.message.event.EventMessage;
-import org.onap.appc.exceptions.APPCException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-
-public class EventSenderMock implements EventSender {
- EventMessage msg;
- MessageDestination destination;
-
- @Override
- public boolean sendEvent(MessageDestination destination, EventMessage msg) {
- if (destination != null && msg != null){
- this.msg = msg;
- this.destination = destination;
- return true;
- }
- else{
- return false;
- }
- }
-
- @Override
- public boolean sendEvent(MessageDestination destination, EventMessage msg, String eventTopicName) {
- return false;
- }
-
- @Override
- public boolean sendEvent(MessageDestination destination, Map<String, String> params, SvcLogicContext ctx) throws APPCException {
- return false;
- }
-
- public EventMessage getMsg() {
- return msg;
- }
-
- public MessageDestination getDestination() {
- return destination;
- }
-}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImplTest.java
index 74c1ec7a5..33761f9fd 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImplTest.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImplTest.java
@@ -3,7 +3,9 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 Ericsson
- * =============================================================================
+ * ================================================================================
+ * Copyright (C) 2019 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
@@ -24,58 +26,27 @@ package org.onap.appc.dg.common.impl;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.Spy;
-import org.onap.appc.adapter.message.MessageAdapterFactory;
-import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.srvcomm.messaging.MessagingConnector;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(FrameworkUtil.class)
public class IntermediateMessageSenderImplTest {
private SvcLogicContext ctx;
private Map<String, String> params;
- private final BundleContext bundleContext = Mockito.mock(BundleContext.class);
- private final Bundle bundleService = Mockito.mock(Bundle.class);
- private final ServiceReference sref = Mockito.mock(ServiceReference.class);
- private final MessageAdapterFactory mockFactory = Mockito.mock(MessageAdapterFactory.class);
- private final Producer mockProducer = Mockito.mock(Producer.class);
- @InjectMocks
private IntermediateMessageSenderImpl intermediateMessageSenderImpl;
- @Spy
- private EventSenderMock eventSender = new EventSenderMock();
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() throws NoSuchFieldException, IllegalAccessException {
- PowerMockito.mockStatic(FrameworkUtil.class);
- PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
- PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
- PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref);
- PowerMockito.when(bundleContext.<MessageAdapterFactory>getService(sref)).thenReturn(mockFactory);
- PowerMockito.when(mockFactory.createProducer(Matchers.anyCollection(), Mockito.anyString(), Mockito.anyString(),
- Mockito.anyString())).thenReturn(mockProducer);
- }
@Test
public void testSendEmptyMessage() {
- intermediateMessageSenderImpl.init();
+ intermediateMessageSenderImpl = new IntermediateMessageSenderImpl();
+ MessagingConnector msgConn = Mockito.mock(MessagingConnector.class);
+ Mockito.when(msgConn.publishMessage(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(false);
+ intermediateMessageSenderImpl.init(msgConn);
ctx = new SvcLogicContext();
params = new HashMap<>();
intermediateMessageSenderImpl.sendMessage(params, ctx);
@@ -84,7 +55,10 @@ public class IntermediateMessageSenderImplTest {
@Test
public void testSendMessage() {
- intermediateMessageSenderImpl.init();
+ intermediateMessageSenderImpl = new IntermediateMessageSenderImpl();
+ MessagingConnector msgConn = Mockito.mock(MessagingConnector.class);
+ Mockito.when(msgConn.publishMessage(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
+ intermediateMessageSenderImpl.init(msgConn);
ctx = new SvcLogicContext();
ctx.setAttribute("input.common-header.request-id", "REQUEST-ID");
params = new HashMap<>();
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/MockEventSender.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/MockEventSender.java
new file mode 100644
index 000000000..2a795e984
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/MockEventSender.java
@@ -0,0 +1,52 @@
+package org.onap.appc.dg.common.impl;
+
+import org.onap.appc.srvcomm.messaging.MessageDestination;
+import org.onap.appc.srvcomm.messaging.event.EventMessage;
+import org.onap.appc.srvcomm.messaging.event.EventSender;
+
+public class MockEventSender extends EventSender {
+
+ private EventMessage eventMessage;
+ private String topic;
+ private MessageDestination dest;
+ private boolean success = true;
+
+ @Override
+ public boolean sendEvent(MessageDestination destination, EventMessage msg, String eventTopicName) {
+ eventMessage = msg;
+ topic = eventTopicName;
+ dest = destination;
+ return success;
+ }
+
+ @Override
+ public boolean sendEvent(MessageDestination destination, EventMessage msg) {
+ eventMessage = msg;
+ topic = null;
+ dest = destination;
+ return success;
+ }
+ public void reset() {
+ eventMessage = null;
+ topic = null;
+ dest = null;
+ success = true;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public EventMessage getMessage() {
+ return eventMessage;
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+ public MessageDestination getDestination() {
+ return dest;
+ }
+
+}