From 790ddb83355800cc037ea1ea3ca8610bb78018d5 Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Tue, 29 Oct 2019 12:50:10 -0700 Subject: Change code to use dmaap microservice Change method calls that used to go to the dmaap adapter, to now go to the appc service communicator, which connects to the dmaap micro service. Change-Id: I619fcb408e14fa0b926950192463d9c92ab7dbba Signed-off-by: Patrick Brady Issue-ID: APPC-1744 --- .../appc-rest-adapter-bundle/pom.xml | 5 + appc-adapters/pom.xml | 3 +- appc-dg-util/appc-dg-util-bundle/pom.xml | 5 - appc-dg/appc-dg-shared/appc-dg-common/pom.xml | 41 +-------- .../dg/common/impl/DCAEReporterPluginImpl.java | 12 +-- .../common/impl/IntermediateMessageSenderImpl.java | 37 ++------ .../resources/OSGI-INF/blueprint/blueprint.xml | 4 +- .../dg/common/impl/DCAEReporterPluginImplTest.java | 40 +++----- .../onap/appc/dg/common/impl/EventSenderMock.java | 67 -------------- .../impl/IntermediateMessageSenderImplTest.java | 50 +++------- .../onap/appc/dg/common/impl/MockEventSender.java | 52 +++++++++++ .../appc-command-executor-core/pom.xml | 5 - .../appc-request-handler-core/pom.xml | 14 +-- .../messageadapter/impl/MessageAdapterImpl.java | 67 ++------------ .../impl/MessageAdapterImplTest.java | 84 ++++++----------- .../appc/requesthandler/RequestHandlerTest.java | 14 +-- .../impl/LocalRequestHanlderTestHelper.java | 13 +-- .../onap-appc-request-handler/pom.xml | 4 +- appc-oam/appc-oam-bundle/pom.xml | 15 +-- .../appc/oam/messageadapter/MessageAdapter.java | 101 ++++----------------- .../oam/messageadapter/MessageAdapterTest.java | 79 +--------------- appc-sdc-listener/appc-sdc-listener-bundle/pom.xml | 8 +- .../artifacts/impl/AbstractArtifactProcessor.java | 12 +-- .../artifacts/impl/ArtifactProcessorFactory.java | 4 +- .../artifacts/impl/ConfigArtifactProcessor.java | 4 +- .../artifacts/impl/LicenseArtifactProcessor.java | 4 +- .../artifacts/impl/ToscaCsarArtifactProcessor.java | 4 +- .../org/onap/appc/sdc/listener/SdcCallback.java | 4 +- .../impl/TestAbstractArtifactProcessor.java | 2 +- .../sdc/artifacts/impl/TestArtifactProcessor.java | 2 +- .../impl/TestConfigArtifcatProcessor.java | 2 +- .../impl/TestLicenseArtifactProcessor.java | 4 +- .../impl/TestToscaCsarArtifactProcessor.java | 2 +- .../onap/appc/sdc/listener/SdcCallbackTest.java | 2 +- pom.xml | 2 +- .../dmaapService/AuthenticationConfig.java | 23 ++++- 36 files changed, 211 insertions(+), 580 deletions(-) delete mode 100644 appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/EventSenderMock.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/MockEventSender.java diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml index 7286ec9d8..d6168a3f4 100644 --- a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml +++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml @@ -49,6 +49,11 @@ appc-common-bundle ${project.version} + + org.onap.appc + appc-service-communicator-bundle + ${project.version} + javax javaee-api diff --git a/appc-adapters/pom.xml b/appc-adapters/pom.xml index ee88e66f7..0e06886c3 100644 --- a/appc-adapters/pom.xml +++ b/appc-adapters/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"); @@ -35,7 +35,6 @@ appc-chef-adapter appc-rest-adapter appc-iaas-adapter - appc-dmaap-adapter appc-netconf-adapter appc-ssh-adapter appc-rest-healthcheck-adapter diff --git a/appc-dg-util/appc-dg-util-bundle/pom.xml b/appc-dg-util/appc-dg-util-bundle/pom.xml index f59079a57..f57a544d5 100644 --- a/appc-dg-util/appc-dg-util-bundle/pom.xml +++ b/appc-dg-util/appc-dg-util-bundle/pom.xml @@ -158,11 +158,6 @@ org.json json - - org.onap.appc - appc-dmaap-adapter-bundle - ${project.version} - org.onap.appc appc-netconf-adapter-bundle 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 @@ org.onap.appc - appc-message-adapter-api + appc-service-communicator-bundle ${project.version} - provided - - - - equinoxSDK381 - org.eclipse.osgi - - - - - org.onap.appc - appc-dmaap-adapter-bundle - ${project.version} - provided - - - - equinoxSDK381 - org.eclipse.osgi - - - - - org.onap.appc - appc-message-adapter-factory - ${project.version} - provided - - - - equinoxSDK381 - org.eclipse.osgi - - org.onap.ccsdk.sli.core @@ -224,8 +190,7 @@ appc-dg-common org.onap.appc.dg.common,org.onap.appc.dg.common.objects,org.onap.appc.dg.common.utils org.onap.appc.dg.common.impl.* - org.onap.appc.adapter.message.*,org.onap.appc.adapter.factory.*,org.onap.appc.adapter.messaging.*, - *;resolution:=optional + org.onap.appc.srvcomm.messaging.event,org.onap.appc.srvcomm.messaging,*;resolution:=optional 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 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 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 @@ + interface="org.onap.appc.srvcomm.messaging.event.EventSender"/> 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 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.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 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 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.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; + } + +} diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml index d8c0201ae..8a77af83a 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml @@ -65,11 +65,6 @@ appc-data-access-lib ${project.version} - - org.onap.appc - appc-dmaap-adapter-bundle - ${project.version} - org.onap.appc appc-lifecycle-management-api diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml index e61bf1dd5..5bdf34e74 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml @@ -49,19 +49,7 @@ org.onap.appc - appc-dmaap-adapter-bundle - ${project.version} - provided - - - org.onap.appc - appc-message-adapter-api - ${project.version} - provided - - - org.onap.appc - appc-message-adapter-factory + appc-service-communicator-bundle ${project.version} provided diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/messageadapter/impl/MessageAdapterImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/messageadapter/impl/MessageAdapterImpl.java index 8c518fec4..65f51552a 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/messageadapter/impl/MessageAdapterImpl.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/messageadapter/impl/MessageAdapterImpl.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,12 +25,6 @@ package org.onap.appc.messageadapter.impl; - -import org.onap.appc.adapter.factory.MessageService; -import org.onap.appc.adapter.message.MessageAdapterFactory; -import org.onap.appc.adapter.message.Producer; -import org.onap.appc.configuration.Configuration; -import org.onap.appc.configuration.ConfigurationFactory; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonProcessingException; @@ -39,23 +33,12 @@ import org.onap.appc.domainmodel.lcm.ResponseContext; import org.onap.appc.domainmodel.lcm.VNFOperation; import org.onap.appc.messageadapter.MessageAdapter; import org.onap.appc.requesthandler.conv.Converter; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; - -import java.util.HashSet; -import java.util.Properties; +import org.onap.appc.srvcomm.messaging.MessagingConnector; public class MessageAdapterImpl implements MessageAdapter{ - private MessageService messageService; - private Producer producer; + private MessagingConnector messageService; private String partition ; - private Configuration configuration; - private HashSet pool; - private String writeTopic; - private String apiKey; - private String apiSecret; private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterImpl.class); @@ -65,44 +48,12 @@ public class MessageAdapterImpl implements MessageAdapter{ @Override public void init(){ logger.debug("MessageAdapterImpl - init"); - this.producer = getProducer(); - } - - private Producer getProducer() { - configuration = ConfigurationFactory.getConfiguration(); - Properties properties = configuration.getProperties(); - updateProperties(properties); - - BundleContext ctx = FrameworkUtil.getBundle(MessageAdapterImpl.class).getBundleContext(); - if (ctx != null) { - ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName()); - if (svcRef != null) { - producer = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopic, apiKey, apiSecret); - } - } - return producer; + this.messageService = new MessagingConnector(); } - - - private void updateProperties(Properties props) { - if (logger.isTraceEnabled()) { - logger.trace("Entering to updateProperties with Properties = " + ObjectUtils.toString(props)); - } - pool = new HashSet<>(); - if (props != null) { - // readTopic = props.getProperty("dmaap.topic.read"); - writeTopic = props.getProperty("appc.LCM.topic.write"); - apiKey = props.getProperty("appc.LCM.client.key"); - apiSecret = props.getProperty("appc.LCM.client.secret"); - messageService = MessageService.parse(props.getProperty("message.service.type")); - // READ_TIMEOUT = Integer.valueOf(props.getProperty("dmaap.topic.read.timeout", String.valueOf(READ_TIMEOUT))); - String hostnames = props.getProperty("appc.LCM.poolMembers"); - if (hostnames != null && !hostnames.isEmpty()) { - for (String name : hostnames.split(",")) { - pool.add(name); - } - } - } + + public void init(MessagingConnector connector) { + logger.debug("MessageAdapterImpl - init"); + this.messageService = connector; } /** @@ -125,7 +76,7 @@ public class MessageAdapterImpl implements MessageAdapter{ logger.debug("DMaaP Response = " + jsonMessage); } logger.debug("Before Invoking producer.post(): jsonMessage is::" + jsonMessage); - success = producer.post(this.partition, jsonMessage); + success = messageService.publishMessage("appc.LCM", this.partition, jsonMessage); logger.debug("After Invoking producer.post()"); } catch (JsonProcessingException e1) { logger.error("Error generating Json from DMaaP message " + e1.getMessage()); diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/messageadapter/impl/MessageAdapterImplTest.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/messageadapter/impl/MessageAdapterImplTest.java index d5c3534b3..81c00269a 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/messageadapter/impl/MessageAdapterImplTest.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/messageadapter/impl/MessageAdapterImplTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 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 @@ -21,81 +23,47 @@ package org.onap.appc.messageadapter.impl; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; + +import javax.ws.rs.core.Response.Status; + import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; -import org.onap.appc.adapter.message.MessageAdapterFactory; -import org.onap.appc.adapter.message.Producer; -import org.onap.appc.configuration.Configuration; -import org.onap.appc.configuration.ConfigurationFactory; -import org.onap.appc.requesthandler.conv.Converter; -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; +import org.onap.appc.domainmodel.lcm.CommonHeader; +import org.onap.appc.domainmodel.lcm.ResponseContext; +import org.onap.appc.domainmodel.lcm.VNFOperation; +import org.onap.appc.srvcomm.messaging.MessagingConnector; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonProcessingException; -import com.att.eelf.configuration.EELFLogger.Level; -@RunWith(PowerMockRunner.class) -@PrepareForTest({FrameworkUtil.class, Converter.class}) public class MessageAdapterImplTest { - private Configuration mockConfig = ConfigurationFactory.getConfiguration(); - 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 Producer producer = Mockito.mock(Producer.class); + private final MessagingConnector connector = Mockito.mock(MessagingConnector.class); private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterImpl.class); - private MessageAdapterImpl impl; - + private final MessageAdapterImpl impl = new MessageAdapterImpl(); + @Before - public void setUp() throws Exception { - logger.setLevel(Level.TRACE); - impl = PowerMockito.spy(new MessageAdapterImpl()); - //originalLogger = (EELFLogger) Whitebox.getInternalState(MessageAdapterImpl.class, "logger"); - Whitebox.setInternalState(impl, "configuration", mockConfig); - PowerMockito.mockStatic(FrameworkUtil.class); - PowerMockito.when(FrameworkUtil.getBundle(MessageAdapterImpl.class)).thenReturn(bundleService); - PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext); - PowerMockito.when(bundleContext.getServiceReference(MessageAdapterFactory.class.getName())).thenReturn(sref); - PowerMockito.when(bundleContext.getService(sref)).thenReturn(producer); - PowerMockito.mockStatic(Converter.class); - PowerMockito.when(Converter.convAsyncResponseToDmaapOutgoingMessageJsonString( - Mockito.any(), Mockito.any(), Mockito.any())).thenReturn("{}"); + public void setUp() { + impl.init(connector); } @Test public void testSuccess() throws JsonProcessingException { - PowerMockito.when(Converter.convAsyncResponseToDmaapOutgoingMessageJsonString( - Mockito.any(), Mockito.any(), Mockito.any())).thenReturn("{}"); - Mockito.when(producer.post(Mockito.anyString(), Mockito.anyString())).thenReturn(true); - Whitebox.setInternalState(impl, "producer", producer); - Whitebox.setInternalState(impl, "partition", "PARTITION"); - assertTrue(impl.post(null, null, null)); - } - @Test - public void testJsonException() throws JsonProcessingException { - PowerMockito.when(Converter.convAsyncResponseToDmaapOutgoingMessageJsonString( - Mockito.any(), Mockito.any(), Mockito.any())).thenThrow(new JsonProcessingException("TEST") {}); - Whitebox.setInternalState(impl, "partition", "PARTITION"); - assertFalse(impl.post(null, null, null)); + ResponseContext context = new ResponseContext(); + context.setPayload("payload"); + org.onap.appc.domainmodel.lcm.Status status = new org.onap.appc.domainmodel.lcm.Status(); + status.setCode(200); + status.setMessage("success"); + context.setStatus(status); + CommonHeader commonHeader = new CommonHeader(); + commonHeader.setRequestId("test123"); + commonHeader.setSubRequestId("test456"); + context.setCommonHeader(commonHeader); + Mockito.when(connector.publishMessage(Mockito.any(), Mockito.any(),Mockito.any())).thenReturn(true); + assertTrue(impl.post(VNFOperation.Start, "test", context)); } - @Test - public void testException() throws JsonProcessingException { - PowerMockito.when(Converter.convAsyncResponseToDmaapOutgoingMessageJsonString( - Mockito.any(), Mockito.any(), Mockito.any())).thenThrow(new RuntimeException()); - Whitebox.setInternalState(impl, "partition", "PARTITION"); - assertFalse(impl.post(null, null, null)); - } } diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/RequestHandlerTest.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/RequestHandlerTest.java index 2c410320f..89bb13f7c 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/RequestHandlerTest.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/RequestHandlerTest.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 * ============================================================================= @@ -31,8 +31,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mockito; -import org.onap.appc.adapter.factory.DmaapMessageAdapterFactoryImpl; -import org.onap.appc.adapter.message.MessageAdapterFactory; import org.onap.appc.configuration.Configuration; import org.onap.appc.configuration.ConfigurationFactory; import org.onap.appc.domainmodel.lcm.ActionIdentifiers; @@ -97,12 +95,6 @@ public class RequestHandlerTest { private LockManager lockManager; private Configuration configuration; - 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 MessageAdapterFactory factory = new DmaapMessageAdapterFactoryImpl(); - - @Before public void init() throws Exception { configuration = ConfigurationFactory.getConfiguration(); @@ -112,10 +104,6 @@ public class RequestHandlerTest { configuration.setProperty("appc.LCM.client.secret" , "TEST"); PowerMockito.mockStatic(FrameworkUtil.class); - PowerMockito.when(FrameworkUtil.getBundle(MessageAdapterImpl.class)).thenReturn(bundleService); - PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext); - PowerMockito.when(bundleContext.getServiceReference(MessageAdapterFactory.class.getName())).thenReturn(sref); - PowerMockito.when(bundleContext.getService(sref)).thenReturn(factory); requestHandler = new RequestHandlerImpl(); diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/impl/LocalRequestHanlderTestHelper.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/impl/LocalRequestHanlderTestHelper.java index a6bbe571a..64f9e229b 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/impl/LocalRequestHanlderTestHelper.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/onap/appc/requesthandler/impl/LocalRequestHanlderTestHelper.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 * ============================================================================= @@ -24,8 +24,6 @@ package org.onap.appc.requesthandler.impl; import org.mockito.Mockito; -import org.onap.appc.adapter.message.MessageAdapterFactory; -import org.onap.appc.adapter.message.Producer; import org.onap.appc.domainmodel.lcm.ActionIdentifiers; import org.onap.appc.domainmodel.lcm.ActionLevel; import org.onap.appc.domainmodel.lcm.CommonHeader; @@ -116,14 +114,5 @@ public interface LocalRequestHanlderTestHelper { BundleContext myBundleContext = mock(BundleContext.class); Mockito.when(myBundle.getBundleContext()).thenReturn(myBundleContext); - - ServiceReference svcRef = mock(ServiceReference.class); - Mockito.when(myBundleContext.getServiceReference(MessageAdapterFactory.class.getName())).thenReturn(svcRef); - - Producer producer = mock(Producer.class); - MessageAdapterFactory factory = mock(MessageAdapterFactory.class); - Mockito.when(myBundleContext.getService(svcRef)).thenReturn(factory); - Mockito.when(factory.createProducer(anyCollectionOf(String.class), anyString(), anyString(), anyString())) - .thenReturn(producer); } } diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-features/onap-appc-request-handler/pom.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-features/onap-appc-request-handler/pom.xml index 23334889c..0663bd61c 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-features/onap-appc-request-handler/pom.xml +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-features/onap-appc-request-handler/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-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. @@ -67,7 +67,7 @@ limitations under the License. org.onap.appc - appc-message-adapter-api + appc-service-communicator-bundle ${project.version} diff --git a/appc-oam/appc-oam-bundle/pom.xml b/appc-oam/appc-oam-bundle/pom.xml index 5970f79e6..ef9d46d5e 100644 --- a/appc-oam/appc-oam-bundle/pom.xml +++ b/appc-oam/appc-oam-bundle/pom.xml @@ -175,22 +175,9 @@ json - - - org.onap.appc - appc-message-adapter-api - ${project.version} - provided - - - org.onap.appc - appc-message-adapter-factory - ${project.version} - provided - org.onap.appc - appc-dmaap-adapter-bundle + appc-service-communicator-bundle ${project.version} provided diff --git a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/messageadapter/MessageAdapter.java b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/messageadapter/MessageAdapter.java index 7112b7d99..f3160511f 100644 --- a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/messageadapter/MessageAdapter.java +++ b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/messageadapter/MessageAdapter.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 * ============================================================================= @@ -27,118 +27,51 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.commons.lang.ObjectUtils; -import org.onap.appc.adapter.message.MessageAdapterFactory; -import org.onap.appc.adapter.message.Producer; -import org.onap.appc.configuration.Configuration; -import org.onap.appc.configuration.ConfigurationFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; - -import java.util.HashSet; -import java.util.Properties; +import org.onap.appc.srvcomm.messaging.MessagingConnector; public class MessageAdapter { private final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapter.class); - private final String PROP_APPC_OAM_DISABLED = "appc.OAM.disabled"; - private final String PROP_APPC_OAM_TOPIC_WRITE = "appc.OAM.topic.write"; - private String PROP_APPC_OAM_CLIENT_KEY = "appc.OAM.client.key"; - private String PROP_APPC_OAM_CLIENT_SECRET = "appc.OAM.client.secret"; - private String PROP_APPC_OAM_POOLMEMBERS = "appc.OAM.poolMembers"; + private static final String PROPERTIES_PREFIX = "appc.OAM"; - private Producer producer; + private MessagingConnector messagingConnector; private String partition; - private Configuration configuration; - private HashSet pool; - private String writeTopic; - private String apiKey; - private String apiSecret; private boolean isDisabled; /** * Initialize producer client to post messages using configuration properties. */ public void init() { - configuration = ConfigurationFactory.getConfiguration(); - Properties properties = configuration.getProperties(); - updateProperties(properties); if (isAppcOamPropsListenerEnabled()) { - createProducer(); + messagingConnector = new MessagingConnector(); } else { logger.warn(String.format("The listener %s is disabled and will not be run", "appc.OAM")); } } + + public void init(MessagingConnector connector) { - /** - * Create producer using MessageAdapterFactory which is found through bundle context. - */ - void createProducer() { - BundleContext ctx = FrameworkUtil.getBundle(MessageAdapter.class).getBundleContext(); - if (ctx == null) { - logger.warn("MessageAdapter cannot create producer due to no bundle context."); - return; - } - - ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName()); - if (svcRef == null) { - logger.warn("MessageAdapter cannot create producer due to no MessageAdapterFactory service reference."); - return; - } - - Producer localProducer = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopic, - apiKey, apiSecret); - - for (String url : pool) { - if (url.contains("3905") || url.contains("https")) { - localProducer.useHttps(true); - break; - } + if (isAppcOamPropsListenerEnabled()) { + messagingConnector = connector; + } else { + logger.warn(String.format("The listener %s is disabled and will not be run", "appc.OAM")); } - - producer = localProducer; - - logger.debug("MessageAdapter created producer."); } - /** - * Read property value to set writeTopic, apiKey, apiSecret and pool. - * - * @param props of configuration - */ - private void updateProperties(Properties props) { - logger.trace("Entering to updateProperties with Properties = " + ObjectUtils.toString(props)); - - pool = new HashSet<>(); - if (props != null) { - isDisabled = Boolean.parseBoolean(props.getProperty(PROP_APPC_OAM_DISABLED)); - writeTopic = props.getProperty(PROP_APPC_OAM_TOPIC_WRITE); - apiKey = props.getProperty(PROP_APPC_OAM_CLIENT_KEY); - apiSecret = props.getProperty(PROP_APPC_OAM_CLIENT_SECRET); - String hostnames = props.getProperty(PROP_APPC_OAM_POOLMEMBERS); - if (hostnames != null && !hostnames.isEmpty()) { - for (String name : hostnames.split(",")) { - pool.add(name); - } - } - } - } /** * Get producer. If it is null, call createProducer to create it again. * * @return Producer */ - Producer getProducer() { - if (producer == null) { - // In case, producer was not properly set yet, set it again. - logger.info("Calling createProducer as producer is null."); - createProducer(); + MessagingConnector getMessagingConnector() { + if (messagingConnector == null) { + messagingConnector = new MessagingConnector(); } - return producer; + return messagingConnector; } /** @@ -161,8 +94,8 @@ public class MessageAdapter { logger.debug("UEB Response = " + jsonMessage); } - Producer myProducer = getProducer(); - success = myProducer != null && myProducer.post(this.partition, jsonMessage); + MessagingConnector connector = getMessagingConnector(); + success = connector != null && connector.publishMessage(PROPERTIES_PREFIX, this.partition, jsonMessage); } catch (JsonProcessingException e1) { logger.error("Error generating Json from UEB message " + e1.getMessage()); success = false; diff --git a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/MessageAdapterTest.java b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/MessageAdapterTest.java index bb73dfe8a..122ca9f96 100644 --- a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/MessageAdapterTest.java +++ b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/MessageAdapterTest.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 * ================================================================================ @@ -29,8 +29,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.appc.adapter.message.MessageAdapterFactory; -import org.onap.appc.adapter.message.Producer; import org.onap.appc.configuration.Configuration; import org.mockito.Mockito; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.common.header.CommonHeader; @@ -61,85 +59,15 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic; @PrepareForTest({FrameworkUtil.class, ConfigurationFactory.class, Converter.class}) public class MessageAdapterTest { - private Producer fakeProducer; private MessageAdapter messageAdapter; @Before public final void setup() throws Exception { - fakeProducer = mock(Producer.class); messageAdapter = new MessageAdapter(); } - @Test - public void testGetProducerReturnsNull() throws Exception { - MessageAdapter maSpy = Mockito.spy(messageAdapter); - Mockito.doNothing().when(maSpy).createProducer(); - - Producer producer = maSpy.getProducer(); - Assert.assertTrue("getProducer() did not return null", producer == null); - Producer mySpyProducer = Whitebox.getInternalState(maSpy, "producer"); - Assert.assertTrue("MessageAdapter producer is not null", mySpyProducer == null); - Mockito.verify(maSpy, Mockito.times(1)).createProducer(); - } - - @Test - public void testGetProducerWithExistingProducer() throws Exception { - MessageAdapter maSpy = Mockito.spy(messageAdapter); - Whitebox.setInternalState(maSpy, "producer", fakeProducer); - - Producer producer = maSpy.getProducer(); - Assert.assertTrue("getProducer() returned null", producer == fakeProducer); - Mockito.verify(maSpy, Mockito.times(0)).createProducer(); - } - - @Test - public void testGetProducerWithCreateProducer() throws Exception { - MessageAdapter maSpy = Mockito.spy(messageAdapter); - Whitebox.setInternalState(maSpy, "producer", (Object) null); - HashSet pool = new HashSet<>(); - pool.add("NOT_HTTPS"); - pool.add("https"); - Whitebox.setInternalState(maSpy, "pool", pool); - - // Prepare all mocks - mockStatic(FrameworkUtil.class); - Bundle maBundle = mock(Bundle.class); - PowerMockito.when(FrameworkUtil.getBundle(MessageAdapter.class)).thenReturn(maBundle); - - BundleContext maBundleContext = mock(BundleContext.class); - Mockito.when(maBundle.getBundleContext()).thenReturn(maBundleContext); - - ServiceReference svcRef = mock(ServiceReference.class); - Mockito.when(maBundleContext.getServiceReference(MessageAdapterFactory.class.getName())).thenReturn(svcRef); - - MessageAdapterFactory maFactory = mock(MessageAdapterFactory.class); - Mockito.when(maBundleContext.getService(svcRef)).thenReturn(maFactory); - Mockito.when(maFactory.createProducer(pool, (String) null, null, null)).thenReturn(fakeProducer); - - Producer producer = maSpy.getProducer(); - Assert.assertTrue("getProducer() result does not match", producer == fakeProducer); - Producer mySpyProducer = Whitebox.getInternalState(maSpy, "producer"); - Assert.assertTrue("MessageAdapter producer does not match",mySpyProducer == fakeProducer); - Mockito.verify(maSpy, Mockito.times(1)).createProducer(); - } - - @Test - public void testUpdateProperties() { - MessageAdapter maSpy = Mockito.spy(messageAdapter); - Mockito.doNothing().when(maSpy).createProducer(); - Whitebox.setInternalState(maSpy, "isDisabled", false); - PowerMockito.mockStatic(ConfigurationFactory.class); - Configuration mockConfig = Mockito.mock(Configuration.class); - Properties properties = new Properties(); - properties.setProperty("appc.OAM.poolMembers", "hostname1,hostname2"); - Mockito.when(ConfigurationFactory.getConfiguration()).thenReturn(mockConfig); - Mockito.doReturn(properties).when(mockConfig).getProperties(); - maSpy.init(); - assertEquals(2, ((Set)Whitebox.getInternalState(maSpy, "pool")).size()); - } - @Test public void testPost() throws JsonProcessingException { MessageAdapter maSpy = Mockito.spy(messageAdapter); @@ -158,7 +86,6 @@ public class MessageAdapterTest { Mockito.when(Converter.convAsyncResponseToUebOutgoingMessageJsonString(oamContext)).thenReturn("{cambriaPartition='MSO', rpcName='maintenance_mode'," + " body=Body{output=MaintenanceModeOutput [_commonHeader=CommonHeader, hashCode: 14584991," + " _status=Status, hashCode: 24801521, augmentation=[]]}}"); - Mockito.doNothing().when(maSpy).createProducer(); maSpy.post(oamContext); Mockito.verify(mockLogger).trace(Mockito.contains("Entering to post")); Mockito.verify(mockLogger).trace("Exiting from post with (success = false)"); @@ -180,7 +107,6 @@ public class MessageAdapterTest { Whitebox.setInternalState(maSpy, "logger", mockLogger); PowerMockito.mockStatic(Converter.class); Mockito.when(Converter.convAsyncResponseToUebOutgoingMessageJsonString(oamContext)).thenThrow(new JsonProcessingException("ERROR") {}); - Mockito.doNothing().when(maSpy).createProducer(); maSpy.post(oamContext); Mockito.verify(mockLogger).error(Mockito.contains("Error generating Json from UEB message")); } @@ -201,8 +127,7 @@ public class MessageAdapterTest { Whitebox.setInternalState(maSpy, "logger", mockLogger); PowerMockito.mockStatic(Converter.class); Mockito.when(Converter.convAsyncResponseToUebOutgoingMessageJsonString(oamContext)).thenThrow(new RuntimeException("ERROR")); - Mockito.doNothing().when(maSpy).createProducer(); maSpy.post(oamContext); Mockito.verify(mockLogger).error(Mockito.contains("Error sending message to UEB ERROR"), Mockito.any(RuntimeException.class)); } -} \ No newline at end of file +} diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml b/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml index dff31838e..f74e840a4 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml +++ b/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml @@ -87,13 +87,7 @@ limitations under the License. org.onap.appc - appc-message-adapter-api - ${project.version} - - - - org.onap.appc - appc-message-adapter-factory + appc-service-communicator-bundle ${project.version} diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/AbstractArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/AbstractArtifactProcessor.java index 26092ccdd..87fa88ef0 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/AbstractArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/AbstractArtifactProcessor.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 * ============================================================================= @@ -22,11 +22,11 @@ package org.onap.appc.sdc.artifacts.impl; -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.sdc.listener.Util; import org.onap.appc.exceptions.APPCException; import com.att.eelf.configuration.EELFLogger; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ArtifactProcessorFactory.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ArtifactProcessorFactory.java index 315f4cd2e..11398ee4f 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ArtifactProcessorFactory.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ArtifactProcessorFactory.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 * ============================================================================= @@ -24,7 +24,7 @@ package org.onap.appc.sdc.artifacts.impl; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.onap.appc.adapter.message.EventSender; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.appc.sdc.artifacts.ArtifactProcessor; import org.onap.appc.sdc.artifacts.object.ArtifactType; import org.onap.sdc.api.IDistributionClient; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java index 30b34aeeb..8435b296d 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.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 * ============================================================================= @@ -24,7 +24,7 @@ package org.onap.appc.sdc.artifacts.impl; import java.net.MalformedURLException; import java.net.URI; -import org.onap.appc.adapter.message.EventSender; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.appc.exceptions.APPCException; import org.onap.appc.sdc.artifacts.object.SDCArtifact; import org.onap.appc.sdc.listener.ProviderOperations; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/LicenseArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/LicenseArtifactProcessor.java index bf61f2442..cc3c60e76 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/LicenseArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/LicenseArtifactProcessor.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 * ============================================================================= @@ -22,7 +22,7 @@ package org.onap.appc.sdc.artifacts.impl; -import org.onap.appc.adapter.message.EventSender; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.appc.exceptions.APPCException; import org.onap.appc.licmgr.Constants; import com.att.eelf.configuration.EELFLogger; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java index dbce362ba..94159e146 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.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 * ============================================================================= @@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.apache.commons.lang.StringUtils; -import org.onap.appc.adapter.message.EventSender; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.appc.exceptions.APPCException; import org.onap.appc.sdc.artifacts.helper.DependencyModelGenerator; import org.onap.appc.sdc.artifacts.object.Resource; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java index 516784c66..112878e8f 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.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 * ============================================================================= @@ -26,7 +26,7 @@ package org.onap.appc.sdc.listener; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.onap.appc.adapter.message.EventSender; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.appc.sdc.artifacts.ArtifactProcessor; import org.onap.appc.sdc.artifacts.impl.ArtifactProcessorFactory; import org.onap.sdc.api.IDistributionClient; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestAbstractArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestAbstractArtifactProcessor.java index 1f5e4e141..439b6cde4 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestAbstractArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestAbstractArtifactProcessor.java @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; import org.mockito.Mockito; import org.mockito.internal.util.reflection.Whitebox; import org.mockito.runners.MockitoJUnitRunner; -import org.onap.appc.adapter.message.EventSender; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestArtifactProcessor.java index dc00c37f2..7948d913b 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestArtifactProcessor.java @@ -25,8 +25,8 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.onap.appc.adapter.message.EventSender; import org.onap.appc.sdc.artifacts.object.SDCArtifact; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestConfigArtifcatProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestConfigArtifcatProcessor.java index c11ca746c..0a8fe4162 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestConfigArtifcatProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestConfigArtifcatProcessor.java @@ -28,12 +28,12 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.onap.appc.adapter.message.EventSender; import org.onap.appc.exceptions.APPCException; import org.onap.appc.sdc.artifacts.object.SDCArtifact; import org.onap.appc.sdc.listener.ProviderOperations; import org.onap.appc.sdc.listener.ProviderResponse; import org.onap.appc.sdc.listener.Util; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestLicenseArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestLicenseArtifactProcessor.java index 6f70681f5..751685525 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestLicenseArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestLicenseArtifactProcessor.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 * ============================================================================= @@ -32,10 +32,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mockito; -import org.onap.appc.adapter.message.EventSender; import org.onap.appc.exceptions.APPCException; import org.onap.appc.sdc.artifacts.helper.ArtifactStorageService; import org.onap.appc.sdc.artifacts.object.SDCArtifact; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestToscaCsarArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestToscaCsarArtifactProcessor.java index 738febef6..d97b56839 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestToscaCsarArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/artifacts/impl/TestToscaCsarArtifactProcessor.java @@ -24,11 +24,11 @@ import static org.mockito.Mockito.when; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.onap.appc.adapter.message.EventSender; import org.onap.appc.exceptions.APPCException; import org.onap.appc.sdc.artifacts.helper.ArtifactStorageService; import org.onap.appc.sdc.artifacts.helper.DependencyModelGenerator; import org.onap.appc.sdc.artifacts.object.SDCArtifact; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java index 2dcdb4d1c..1567b7859 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java @@ -29,13 +29,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mockito; -import org.onap.appc.adapter.message.EventSender; import org.onap.appc.sdc.artifacts.helper.ArtifactStorageService; import org.onap.appc.sdc.artifacts.helper.DependencyModelGenerator; import org.onap.appc.sdc.artifacts.impl.ArtifactProcessorFactory; import org.onap.appc.sdc.artifacts.impl.ToscaCsarArtifactProcessor; import org.onap.appc.sdc.artifacts.object.SDCArtifact; import org.onap.appc.sdc.artifacts.object.SDCReference; +import org.onap.appc.srvcomm.messaging.event.EventSender; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.consumer.INotificationCallback; import org.onap.sdc.api.notification.IArtifactInfo; diff --git a/pom.xml b/pom.xml index 30985116c..35d8ff6e2 100644 --- a/pom.xml +++ b/pom.xml @@ -621,8 +621,8 @@ limitations under the License. appc-adapters + appc-service-communicator appc-provider - appc-event-listener appc-sdc-listener appc-lifecycle-management appc-oam diff --git a/services/appc-dmaap-service/appc-dmaap-event-service/src/main/java/org/onap/appc/services/dmaapService/AuthenticationConfig.java b/services/appc-dmaap-service/appc-dmaap-event-service/src/main/java/org/onap/appc/services/dmaapService/AuthenticationConfig.java index 4031a5144..21438e6cb 100644 --- a/services/appc-dmaap-service/appc-dmaap-event-service/src/main/java/org/onap/appc/services/dmaapService/AuthenticationConfig.java +++ b/services/appc-dmaap-service/appc-dmaap-event-service/src/main/java/org/onap/appc/services/dmaapService/AuthenticationConfig.java @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * 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 + * + * 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.services.dmaapService; import java.util.Properties; @@ -17,7 +38,7 @@ public class AuthenticationConfig extends WebSecurityConfigurerAdapter { private final String PROPERTIES_PREFIX = "appc.srvcomm.messaging"; private final String DEFAULT_USER = "appc"; private final String DEFAULT_PASSWORD = "onapappc"; - + @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic(); -- cgit 1.2.3-korg