From c6152aa0eec8c0062489501cf3e12f87423ac592 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Mon, 9 Mar 2020 11:16:49 -0400 Subject: Fixing package naming to fix MANIFEST.MF Reafactoring POM Files Change-Id: Ib2eaaca2ee81d8354ccff4de10f7d6f77c8a82bf Issue-ID: CCSDK-2166 Signed-off-by: Singal, Kapil (ks220y) --- sdnr/northbound/CMNotify/provider/pom.xml | 155 +++++++++--------- .../sdnr/northbound/CMNotify/CMNotifyClient.java | 100 ------------ .../sdnr/northbound/CMNotify/CMNotifyProvider.java | 176 --------------------- .../sdnr/northbound/cmnotify/CMNotifyClient.java | 100 ++++++++++++ .../sdnr/northbound/cmnotify/CMNotifyProvider.java | 176 +++++++++++++++++++++ .../OSGI-INF/blueprint/impl-blueprint.xml | 4 +- .../org/opendaylight/blueprint/impl-blueprint.xml | 4 +- .../northbound/CMNotify/CMNotifyClientTest.java | 85 ---------- .../sdnr/northbound/CMNotify/TestCMNotify.java | 105 ------------ .../northbound/cmnotify/CMNotifyClientTest.java | 85 ++++++++++ .../sdnr/northbound/cmnotify/TestCMNotify.java | 105 ++++++++++++ sdnr/wt/data-provider/setup/pom.xml | 8 +- sdnr/wt/featureaggregator/installer/pom.xml | 4 +- 13 files changed, 552 insertions(+), 555 deletions(-) delete mode 100644 sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClient.java delete mode 100644 sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyProvider.java create mode 100644 sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClient.java create mode 100644 sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyProvider.java delete mode 100644 sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClientTest.java delete mode 100644 sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/TestCMNotify.java create mode 100644 sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClientTest.java create mode 100644 sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/TestCMNotify.java diff --git a/sdnr/northbound/CMNotify/provider/pom.xml b/sdnr/northbound/CMNotify/provider/pom.xml index 28a15af71..81a410a19 100644 --- a/sdnr/northbound/CMNotify/provider/pom.xml +++ b/sdnr/northbound/CMNotify/provider/pom.xml @@ -44,16 +44,15 @@ - + org.onap.ccsdk.sli.core @@ -62,9 +61,9 @@ pom import - + org.onap.ccsdk.features.sdnr.northbound @@ -76,7 +75,6 @@ org.opendaylight.controller sal-binding-config - org.opendaylight.controller sal-binding-api @@ -118,76 +116,75 @@ utils-provider ${sdnctl.sli.version} ---> - - org.opendaylight.controller - sal-binding-api - - - - org.onap.ccsdk.sli.core - sli-common - provided - - - org.onap.ccsdk.sli.core - sli-provider - provided - - - org.opendaylight.controller - sal-test-model - test - - - org.opendaylight.controller - sal-binding-broker-impl - test - - - org.opendaylight.controller - sal-binding-broker-impl - test-jar - tests - test - - - junit - junit - test - - - org.mockito - mockito-core - test - - - org.testng - testng - test - + --> + + org.opendaylight.controller + sal-binding-api + - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-core-api - + + org.onap.ccsdk.sli.core + sli-common + provided + + + org.onap.ccsdk.sli.core + sli-provider + provided + + + org.opendaylight.controller + sal-test-model + test + + + org.opendaylight.controller + sal-binding-broker-impl + test + + + org.opendaylight.controller + sal-binding-broker-impl + test-jar + tests + test + + + junit + junit + test + + + org.mockito + mockito-core + test + + + org.testng + testng + test + - - org.opendaylight.yangtools - yang-data-impl - + + org.opendaylight.controller + sal-common-util + + + org.opendaylight.controller + sal-core-api + - - org.opendaylight.controller - sal-binding-broker-impl - test-jar - tests - test - + + org.opendaylight.yangtools + yang-data-impl + + + org.opendaylight.controller + sal-binding-broker-impl + test-jar + tests + test + diff --git a/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClient.java b/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClient.java deleted file mode 100644 index a098904fc..000000000 --- a/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClient.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.features.sdnr.northbound.CMNotify; - -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; - -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CMNotifyClient { - - private static final Logger LOG = LoggerFactory.getLogger(CMNotifyClient.class); - - private SvcLogicService svcLogicService = null; - - public CMNotifyClient(final SvcLogicService svcLogicService) { - this.svcLogicService = svcLogicService; - } - - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - return svcLogicService.hasGraph(module, rpc, version, mode); - } - - // Client for NbrlistChangeNotification - - public Properties execute(String module, String rpc, String version, String mode, - NbrlistChangeNotificationOutputBuilder serviceData) throws SvcLogicException { - - Properties parms = new Properties(); - - return execute(module, rpc, version, mode, serviceData, parms); - } - - public Properties execute(String module, String rpc, String version, String mode, - NbrlistChangeNotificationOutputBuilder serviceData, Properties parms) throws SvcLogicException { - Properties localProp; - localProp = MdsalHelper.toProperties(parms, serviceData); - - if (LOG.isDebugEnabled()) { - LOG.debug("Parameters passed to SLI"); - - for (Object key : localProp.keySet()) { - String parmName = (String) key; - String parmValue = localProp.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - - } - } - - Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); - - if (LOG.isDebugEnabled()) { - LOG.debug("Parameters returned by SLI"); - - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - - } - } - if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { - return respProps; - } - - MdsalHelper.toBuilder(respProps, serviceData); - - return respProps; - } - - - -} diff --git a/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyProvider.java b/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyProvider.java deleted file mode 100644 index 083b82ee4..000000000 --- a/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyProvider.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.features.sdnr.northbound.CMNotify; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Properties; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.CMNOTIFYAPIService; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; - -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Defines a base implementation for your provider. This class extends from a helper class which - * provides storage for the most commonly used components of the MD-SAL. Additionally the base class - * provides some basic logging and initialization / clean up methods. - * - */ -public class CMNotifyProvider implements AutoCloseable, CMNOTIFYAPIService { - - private static final Logger LOG = LoggerFactory.getLogger(CMNotifyProvider.class); - - private static final String APPLICATION_NAME = "CMNotify-api"; - private static final String NBRLIST_CHANGE_NOTIFICATION = "nbrlist-change-notification"; - - - private final ExecutorService executor; - protected DataBroker dataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - protected BindingAwareBroker.RpcRegistration rpcRegistration; - private final CMNotifyClient CMNotifyClient; - - public CMNotifyProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService, - final RpcProviderRegistry rpcProviderRegistry, final CMNotifyClient CMNotifyClient) { - - LOG.info("Creating provider for {}", APPLICATION_NAME); - executor = Executors.newFixedThreadPool(1); - this.dataBroker = dataBroker; - this.notificationService = notificationPublishService; - this.rpcRegistry = rpcProviderRegistry; - this.CMNotifyClient = CMNotifyClient; - initialize(); - } - - public void initialize() { - LOG.info("Initializing provider for {}", APPLICATION_NAME); - rpcRegistration = rpcRegistry.addRpcImplementation(CMNOTIFYAPIService.class, this); - LOG.info("Initialization complete for {}", APPLICATION_NAME); - } - - protected void initializeChild() { - // Override if you have custom initialization intelligence - } - - @Override - public void close() throws Exception { - LOG.info("Closing provider for {}", APPLICATION_NAME); - executor.shutdown(); - rpcRegistration.close(); - LOG.info("Successfully closed provider for {}", APPLICATION_NAME); - } - - // RPC nbrlist-change-notification - - @Override - public ListenableFuture> nbrlistChangeNotification(NbrlistChangeNotificationInput input) { - final String svcOperation = "nbrlist-change-notification"; - - Properties parms = new Properties(); - NbrlistChangeNotificationOutputBuilder serviceDataBuilder = (NbrlistChangeNotificationOutputBuilder) getServiceData(NBRLIST_CHANGE_NOTIFICATION); - - LOG.info("Reached RPC nbrlist-change-notification"); - - LOG.info(svcOperation + " called."); - - if (input == null) { - LOG.debug("exiting " + svcOperation + " because of invalid input"); - serviceDataBuilder.setResponseCode("Input is null"); - RpcResult rpcResult = - RpcResultBuilder.status(true).withResult(serviceDataBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // add input to parms - LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); - NbrlistChangeNotificationInputBuilder inputBuilder = new NbrlistChangeNotificationInputBuilder(input); - MdsalHelper.toProperties(parms, inputBuilder.build()); - - LOG.info("Printing SLI parameters to be passed"); - - // iterate properties file to get key-value pairs - for (String key : parms.stringPropertyNames()) { - String value = parms.getProperty(key); - LOG.info("The SLI parameter in " + key + " is: " + value); - } - - // Call SLI sync method - try { - if (CMNotifyClient.hasGraph("CM-NOTIFY-API", svcOperation, null, "sync")) { - LOG.info("CMNotifyClient has a Directed Graph for '" + svcOperation + "'"); - try { - CMNotifyClient.execute("CM-NOTIFY-API", svcOperation, null, "sync", serviceDataBuilder, parms); - } catch (Exception e) { - LOG.error("Caught exception executing service logic for " + svcOperation, e); - serviceDataBuilder.setResponseCode("500"); - } - } else { - LOG.error("No service logic active for CMNotify: '" + svcOperation + "'"); - serviceDataBuilder.setResponseCode("503"); - } - } catch (Exception e) { - LOG.error("Caught exception looking for service logic", e); - serviceDataBuilder.setResponseCode("500"); - } - - String errorCode = serviceDataBuilder.getResponseCode(); - - if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); - } else { - LOG.info("Returned SUCCESS for " + svcOperation + " "); - serviceDataBuilder.setResponseMessage("CM Notification Executed and RuntimeDB Updated. "); - } - - RpcResult rpcResult = - RpcResultBuilder.status(true).withResult(serviceDataBuilder.build()).build(); - - LOG.info("Successful exit from nbrlist-change-notification "); - - return Futures.immediateFuture(rpcResult); - } - - - protected Builder getServiceData(String svcOperation) { - switch (svcOperation) { - case NBRLIST_CHANGE_NOTIFICATION: - return new NbrlistChangeNotificationOutputBuilder(); - } - return null; - } -} diff --git a/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClient.java b/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClient.java new file mode 100644 index 000000000..e4c94f3a8 --- /dev/null +++ b/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClient.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.features.sdnr.northbound.cmnotify; + +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CMNotifyClient { + + private static final Logger LOG = LoggerFactory.getLogger(CMNotifyClient.class); + + private SvcLogicService svcLogicService = null; + + public CMNotifyClient(final SvcLogicService svcLogicService) { + this.svcLogicService = svcLogicService; + } + + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { + return svcLogicService.hasGraph(module, rpc, version, mode); + } + + // Client for NbrlistChangeNotification + + public Properties execute(String module, String rpc, String version, String mode, + NbrlistChangeNotificationOutputBuilder serviceData) throws SvcLogicException { + + Properties parms = new Properties(); + + return execute(module, rpc, version, mode, serviceData, parms); + } + + public Properties execute(String module, String rpc, String version, String mode, + NbrlistChangeNotificationOutputBuilder serviceData, Properties parms) throws SvcLogicException { + Properties localProp; + localProp = MdsalHelper.toProperties(parms, serviceData); + + if (LOG.isDebugEnabled()) { + LOG.debug("Parameters passed to SLI"); + + for (Object key : localProp.keySet()) { + String parmName = (String) key; + String parmValue = localProp.getProperty(parmName); + + LOG.debug(parmName + " = " + parmValue); + + } + } + + Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); + + if (LOG.isDebugEnabled()) { + LOG.debug("Parameters returned by SLI"); + + for (Object key : respProps.keySet()) { + String parmName = (String) key; + String parmValue = respProps.getProperty(parmName); + + LOG.debug(parmName + " = " + parmValue); + + } + } + if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { + return respProps; + } + + MdsalHelper.toBuilder(respProps, serviceData); + + return respProps; + } + + + +} diff --git a/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyProvider.java b/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyProvider.java new file mode 100644 index 000000000..7317ac4b8 --- /dev/null +++ b/sdnr/northbound/CMNotify/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyProvider.java @@ -0,0 +1,176 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.features.sdnr.northbound.cmnotify; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import java.util.Properties; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.CMNOTIFYAPIService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; + +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Defines a base implementation for your provider. This class extends from a helper class which + * provides storage for the most commonly used components of the MD-SAL. Additionally the base class + * provides some basic logging and initialization / clean up methods. + * + */ +public class CMNotifyProvider implements AutoCloseable, CMNOTIFYAPIService { + + private static final Logger LOG = LoggerFactory.getLogger(CMNotifyProvider.class); + + private static final String APPLICATION_NAME = "CMNotify-api"; + private static final String NBRLIST_CHANGE_NOTIFICATION = "nbrlist-change-notification"; + + + private final ExecutorService executor; + protected DataBroker dataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + protected BindingAwareBroker.RpcRegistration rpcRegistration; + private final CMNotifyClient CMNotifyClient; + + public CMNotifyProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService, + final RpcProviderRegistry rpcProviderRegistry, final CMNotifyClient CMNotifyClient) { + + LOG.info("Creating provider for {}", APPLICATION_NAME); + executor = Executors.newFixedThreadPool(1); + this.dataBroker = dataBroker; + this.notificationService = notificationPublishService; + this.rpcRegistry = rpcProviderRegistry; + this.CMNotifyClient = CMNotifyClient; + initialize(); + } + + public void initialize() { + LOG.info("Initializing provider for {}", APPLICATION_NAME); + rpcRegistration = rpcRegistry.addRpcImplementation(CMNOTIFYAPIService.class, this); + LOG.info("Initialization complete for {}", APPLICATION_NAME); + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + LOG.info("Closing provider for {}", APPLICATION_NAME); + executor.shutdown(); + rpcRegistration.close(); + LOG.info("Successfully closed provider for {}", APPLICATION_NAME); + } + + // RPC nbrlist-change-notification + + @Override + public ListenableFuture> nbrlistChangeNotification(NbrlistChangeNotificationInput input) { + final String svcOperation = "nbrlist-change-notification"; + + Properties parms = new Properties(); + NbrlistChangeNotificationOutputBuilder serviceDataBuilder = (NbrlistChangeNotificationOutputBuilder) getServiceData(NBRLIST_CHANGE_NOTIFICATION); + + LOG.info("Reached RPC nbrlist-change-notification"); + + LOG.info(svcOperation + " called."); + + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); + serviceDataBuilder.setResponseCode("Input is null"); + RpcResult rpcResult = + RpcResultBuilder.status(true).withResult(serviceDataBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // add input to parms + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); + NbrlistChangeNotificationInputBuilder inputBuilder = new NbrlistChangeNotificationInputBuilder(input); + MdsalHelper.toProperties(parms, inputBuilder.build()); + + LOG.info("Printing SLI parameters to be passed"); + + // iterate properties file to get key-value pairs + for (String key : parms.stringPropertyNames()) { + String value = parms.getProperty(key); + LOG.info("The SLI parameter in " + key + " is: " + value); + } + + // Call SLI sync method + try { + if (CMNotifyClient.hasGraph("CM-NOTIFY-API", svcOperation, null, "sync")) { + LOG.info("CMNotifyClient has a Directed Graph for '" + svcOperation + "'"); + try { + CMNotifyClient.execute("CM-NOTIFY-API", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); + serviceDataBuilder.setResponseCode("500"); + } + } else { + LOG.error("No service logic active for CMNotify: '" + svcOperation + "'"); + serviceDataBuilder.setResponseCode("503"); + } + } catch (Exception e) { + LOG.error("Caught exception looking for service logic", e); + serviceDataBuilder.setResponseCode("500"); + } + + String errorCode = serviceDataBuilder.getResponseCode(); + + if (!("0".equals(errorCode) || "200".equals(errorCode))) { + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); + } else { + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder.setResponseMessage("CM Notification Executed and RuntimeDB Updated. "); + } + + RpcResult rpcResult = + RpcResultBuilder.status(true).withResult(serviceDataBuilder.build()).build(); + + LOG.info("Successful exit from nbrlist-change-notification "); + + return Futures.immediateFuture(rpcResult); + } + + + protected Builder getServiceData(String svcOperation) { + switch (svcOperation) { + case NBRLIST_CHANGE_NOTIFICATION: + return new NbrlistChangeNotificationOutputBuilder(); + } + return null; + } +} diff --git a/sdnr/northbound/CMNotify/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/sdnr/northbound/CMNotify/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml index 2edb6a766..fd036bbd0 100644 --- a/sdnr/northbound/CMNotify/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ b/sdnr/northbound/CMNotify/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml @@ -26,7 +26,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/sdnr/northbound/CMNotify/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/northbound/CMNotify/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 2edb6a766..fd036bbd0 100644 --- a/sdnr/northbound/CMNotify/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/sdnr/northbound/CMNotify/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -26,7 +26,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClientTest.java b/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClientTest.java deleted file mode 100644 index 06955838e..000000000 --- a/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/CMNotifyClientTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 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.ccsdk.features.sdnr.northbound.CMNotify; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import java.util.Properties; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; - -import org.onap.ccsdk.features.sdnr.northbound.CMNotify.CMNotifyClient; - -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CMNotifyClientTest { - - SvcLogicService mockSvcLogicService; - String module = "test-module"; - String rpc = "test-rpc"; - String version = "test-version"; - String mode = "test-mode"; - Properties localProp = new Properties(); - - @Before - public void setUp() throws Exception { - mockSvcLogicService = mock(SvcLogicService.class); - when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true); - } - - @Test - public void testCMNotifyClientConstructor() { - CMNotifyClient CMNotifyClient = new CMNotifyClient(mockSvcLogicService); - assertNotNull(CMNotifyClient); - } - - @Test - public void testHasGraph() throws SvcLogicException { - CMNotifyClient CMNotifyClient = new CMNotifyClient(mockSvcLogicService); - boolean result = CMNotifyClient.hasGraph(module, rpc, version, mode); - assertTrue(result); - } - - @Test - public void testExecuteSvcLogicStatusFailure() throws SvcLogicException { - NbrlistChangeNotificationOutputBuilder serviceData = mock(NbrlistChangeNotificationOutputBuilder.class); - Properties parms = mock(Properties.class); - SvcLogicService svcLogicService = mock(SvcLogicService.class); - Properties properties = new Properties(); - properties.setProperty("SvcLogic.status", "failure"); - when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties); - CMNotifyClient sliClient = new CMNotifyClient(svcLogicService); - Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties); - assertTrue(prop != null); - } -} diff --git a/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/TestCMNotify.java b/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/TestCMNotify.java deleted file mode 100644 index 060d39949..000000000 --- a/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/CMNotify/TestCMNotify.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 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.ccsdk.features.sdnr.northbound.CMNotify; - -import org.junit.Before; -import org.junit.Test; - -import org.onap.ccsdk.features.sdnr.northbound.CMNotify.CMNotifyClient; -import org.onap.ccsdk.features.sdnr.northbound.CMNotify.CMNotifyProvider; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; - -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import java.math.*; - -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; - -import com.google.common.util.concurrent.ListenableFuture; - - - -public class TestCMNotify extends AbstractConcurrentDataBrokerTest { - - private CMNotifyProvider cMNotifyProvider; - private static final Logger LOG = LoggerFactory.getLogger(CMNotifyProvider.class); - - @Before - public void setUp() throws Exception { - if (null == cMNotifyProvider) { - DataBroker dataBroker = getDataBroker(); - NotificationPublishService mockNotification = mock(NotificationPublishService.class); - RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); - CMNotifyClient mockSliClient = mock(CMNotifyClient.class); - cMNotifyProvider = new CMNotifyProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); - } - } - - //Testcase should return error 503 when No service logic active for NbrlistChangeNotification - @Test - public void testNbrlistChangeNotification() { - - NbrlistChangeNotificationInputBuilder inputBuilder = new NbrlistChangeNotificationInputBuilder(); - - inputBuilder.setFapServiceNumberOfEntriesChanged(new BigInteger("1")); - - // TODO: currently initialize SvcLogicServiceClient is failing, need to fix - ListenableFuture> future = cMNotifyProvider - .nbrlistChangeNotification(inputBuilder.build()); - RpcResult rpcResult = null; - try { - rpcResult = future.get(); - } catch (Exception e) { - fail("Error : " + e); - } - LOG.info("result: {}", rpcResult); - assertEquals("503", rpcResult.getResult().getResponseCode()); - } - - //Input parameter validation - @Test - public void testvValidation() { - - ListenableFuture> future = cMNotifyProvider - .nbrlistChangeNotification(null); - RpcResult rpcResult = null; - try { - rpcResult = future.get(); - } catch (Exception e) { - fail("Error : " + e); - } - LOG.info("result: {}", rpcResult); - assertEquals("Input is null", rpcResult.getResult().getResponseCode()); - } -} diff --git a/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClientTest.java b/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClientTest.java new file mode 100644 index 000000000..826d144f0 --- /dev/null +++ b/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/CMNotifyClientTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 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.ccsdk.features.sdnr.northbound.cmnotify; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; + +import org.onap.ccsdk.features.sdnr.northbound.cmnotify.CMNotifyClient; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CMNotifyClientTest { + + SvcLogicService mockSvcLogicService; + String module = "test-module"; + String rpc = "test-rpc"; + String version = "test-version"; + String mode = "test-mode"; + Properties localProp = new Properties(); + + @Before + public void setUp() throws Exception { + mockSvcLogicService = mock(SvcLogicService.class); + when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true); + } + + @Test + public void testCMNotifyClientConstructor() { + CMNotifyClient CMNotifyClient = new CMNotifyClient(mockSvcLogicService); + assertNotNull(CMNotifyClient); + } + + @Test + public void testHasGraph() throws SvcLogicException { + CMNotifyClient CMNotifyClient = new CMNotifyClient(mockSvcLogicService); + boolean result = CMNotifyClient.hasGraph(module, rpc, version, mode); + assertTrue(result); + } + + @Test + public void testExecuteSvcLogicStatusFailure() throws SvcLogicException { + NbrlistChangeNotificationOutputBuilder serviceData = mock(NbrlistChangeNotificationOutputBuilder.class); + Properties parms = mock(Properties.class); + SvcLogicService svcLogicService = mock(SvcLogicService.class); + Properties properties = new Properties(); + properties.setProperty("SvcLogic.status", "failure"); + when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties); + CMNotifyClient sliClient = new CMNotifyClient(svcLogicService); + Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties); + assertTrue(prop != null); + } +} diff --git a/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/TestCMNotify.java b/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/TestCMNotify.java new file mode 100644 index 000000000..36218eb99 --- /dev/null +++ b/sdnr/northbound/CMNotify/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/cmnotify/TestCMNotify.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 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.ccsdk.features.sdnr.northbound.cmnotify; + +import org.junit.Before; +import org.junit.Test; + +import org.onap.ccsdk.features.sdnr.northbound.cmnotify.CMNotifyClient; +import org.onap.ccsdk.features.sdnr.northbound.cmnotify.CMNotifyProvider; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; + +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import java.math.*; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder; + +import com.google.common.util.concurrent.ListenableFuture; + + + +public class TestCMNotify extends AbstractConcurrentDataBrokerTest { + + private CMNotifyProvider cMNotifyProvider; + private static final Logger LOG = LoggerFactory.getLogger(CMNotifyProvider.class); + + @Before + public void setUp() throws Exception { + if (null == cMNotifyProvider) { + DataBroker dataBroker = getDataBroker(); + NotificationPublishService mockNotification = mock(NotificationPublishService.class); + RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); + CMNotifyClient mockSliClient = mock(CMNotifyClient.class); + cMNotifyProvider = new CMNotifyProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); + } + } + + //Testcase should return error 503 when No service logic active for NbrlistChangeNotification + @Test + public void testNbrlistChangeNotification() { + + NbrlistChangeNotificationInputBuilder inputBuilder = new NbrlistChangeNotificationInputBuilder(); + + inputBuilder.setFapServiceNumberOfEntriesChanged(new BigInteger("1")); + + // TODO: currently initialize SvcLogicServiceClient is failing, need to fix + ListenableFuture> future = cMNotifyProvider + .nbrlistChangeNotification(inputBuilder.build()); + RpcResult rpcResult = null; + try { + rpcResult = future.get(); + } catch (Exception e) { + fail("Error : " + e); + } + LOG.info("result: {}", rpcResult); + assertEquals("503", rpcResult.getResult().getResponseCode()); + } + + //Input parameter validation + @Test + public void testvValidation() { + + ListenableFuture> future = cMNotifyProvider + .nbrlistChangeNotification(null); + RpcResult rpcResult = null; + try { + rpcResult = future.get(); + } catch (Exception e) { + fail("Error : " + e); + } + LOG.info("result: {}", rpcResult); + assertEquals("Input is null", rpcResult.getResult().getResponseCode()); + } +} diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml index eb0b17910..591de37e8 100644 --- a/sdnr/wt/data-provider/setup/pom.xml +++ b/sdnr/wt/data-provider/setup/pom.xml @@ -63,9 +63,9 @@ 1.4 - org.slf4j - slf4j-log4j12 - + org.slf4j + slf4j-log4j12 + ${project.groupId} sdnr-wt-common @@ -133,7 +133,7 @@ sdnr-dmt - false + false org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.Program diff --git a/sdnr/wt/featureaggregator/installer/pom.xml b/sdnr/wt/featureaggregator/installer/pom.xml index 620036541..9ac57c41a 100755 --- a/sdnr/wt/featureaggregator/installer/pom.xml +++ b/sdnr/wt/featureaggregator/installer/pom.xml @@ -145,7 +145,7 @@ - + maven-resources-plugin 2.6 @@ -168,7 +168,7 @@ - + -- cgit 1.2.3-korg