diff options
Diffstat (limited to 'appc-provider/appc-provider-bundle/src')
19 files changed, 125 insertions, 2362 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java index 62c8ef7cd..91d3a1953 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java @@ -27,27 +27,27 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.util.concurrent.Futures; 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.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.AppcProviderService; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.request.header.CommonRequestHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.config.payload.ConfigPayload; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.vnf.resource.VnfResource; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.EvacuateInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.EvacuateOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.MigrateInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.MigrateOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.ModifyConfigInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.ModifyConfigOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RebuildInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RebuildOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RestartInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RestartOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.SnapshotInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.SnapshotOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.VmstatuscheckInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.VmstatuscheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.request.header.CommonRequestHeader; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.config.payload.ConfigPayload; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.vnf.resource.VnfResource; import org.opendaylight.yangtools.yang.common.RpcResult; import org.onap.appc.Constants; import org.onap.appc.configuration.Configuration; @@ -106,7 +106,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { /** * ODL Notification Service that provides publish/subscribe capabilities for YANG modeled notifications. */ - protected NotificationProviderService notificationService; + protected NotificationPublishService notificationService; /** * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are defined in YANG models. @@ -122,6 +122,8 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * The configuration */ private Configuration configuration = ConfigurationFactory.getConfiguration(); + + private AppcProviderClient appcProviderClient; /** * @param dataBroker2 @@ -131,8 +133,8 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { @SuppressWarnings({ "javadoc", "nls" }) - public AppcProvider(DataBroker dataBroker2, NotificationProviderService notificationProviderService, - RpcProviderRegistry rpcProviderRegistry) { + public AppcProvider(DataBroker dataBroker2, NotificationPublishService notificationProviderService, + RpcProviderRegistry rpcProviderRegistry, AppcProviderClient appcProviderClient) { String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME); logger.info(Msg.COMPONENT_INITIALIZING, appName, "provider"); @@ -141,10 +143,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { dataBroker = dataBroker2; notificationService = notificationProviderService; rpcRegistry = rpcProviderRegistry; - - if (rpcRegistry != null) { - rpcRegistration = rpcRegistry.addRpcImplementation(AppcProviderService.class, this); - } + this.appcProviderClient = appcProviderClient; logger.info(Msg.COMPONENT_INITIALIZED, appName, "provider"); } @@ -176,7 +175,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { /** * Rebuilds a specific VNF * - * @see org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.AppcProviderService#rebuild(org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildInput) + * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#rebuild(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RebuildInput) */ @Override public Future<RpcResult<RebuildOutput>> rebuild(RebuildInput input) { @@ -191,7 +190,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { /** * Restarts a specific VNF * - * @see org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.AppcProviderService#restart(org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartInput) + * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#restart(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RestartInput) */ @Override public Future<RpcResult<RestartOutput>> restart(RestartInput input) { @@ -205,7 +204,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { /** * Migrates a specific VNF * - * @see org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.AppcProviderService#migrate(org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateInput) + * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#migrate(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.MigrateInput) */ @Override public Future<RpcResult<MigrateOutput>> migrate(MigrateInput input) { @@ -219,7 +218,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { /** * Evacuates a specific VNF * - * @see org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateInput) + * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.EvacuateInput) */ @Override public Future<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) { @@ -230,7 +229,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { /** * Evacuates a specific VNF * - * @see org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateInput) + * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.EvacuateInput) */ @Override public Future<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) { @@ -257,4 +256,8 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { TopologyService getTopologyService() { return new TopologyService(this); } + + public AppcProviderClient getClient() { + return appcProviderClient; + } }
\ No newline at end of file diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderClient.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderClient.java index e7b3f1be3..ec8ce478b 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderClient.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderClient.java @@ -48,24 +48,11 @@ public class AppcProviderClient { private final EELFLogger LOG = EELFManager.getInstance().getApplicationLogger(); private final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private SvcLogicService svcLogic = null; + private final SvcLogicService svcLogic; - public AppcProviderClient() { - BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); - // Handle BundleContext returning null - if (bctx == null){ - LOG.warn("Cannot find bundle context for " + SvcLogicService.NAME); - } else { - // Get SvcLogicService reference - ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); - if (sref != null) { - svcLogic = (SvcLogicService) bctx.getService(sref); - - } else { - LOG.warn("Cannot find service reference for " + SvcLogicService.NAME); - - } - } + public AppcProviderClient(final SvcLogicService svcLogicService) { + LOG.info("provider alert: appcprovider client init"); + this.svcLogic = svcLogicService; } public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java index c3606df4f..410a9ea1c 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java @@ -48,8 +48,8 @@ import org.onap.appc.provider.lcm.util.ValidationService; import org.onap.appc.requesthandler.objects.RequestHandlerInput; import org.onap.appc.requesthandler.objects.RequestHandlerOutput; 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.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.*; import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status; @@ -76,7 +76,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, /** * ODL Notification Service that provides publish/subscribe capabilities for YANG modeled notifications. */ - protected NotificationProviderService notificationService; + protected NotificationPublishService notificationService; /** * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are defined in YANG models. @@ -95,7 +95,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @param rpcProviderRegistry */ @SuppressWarnings({"javadoc", "nls"}) - public AppcProviderLcm(DataBroker dataBroker, NotificationProviderService notificationProviderService, + public AppcProviderLcm(DataBroker dataBroker, NotificationPublishService notificationProviderService, RpcProviderRegistry rpcProviderRegistry) { String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME); diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/ResponseHeaderBuilder.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/ResponseHeaderBuilder.java index fa4097648..e579a2d62 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/ResponseHeaderBuilder.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/ResponseHeaderBuilder.java @@ -23,9 +23,9 @@ package org.onap.appc.provider; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.TIMESTAMP; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.response.header.CommonResponseHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.response.header.CommonResponseHeaderBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.TIMESTAMP; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.response.header.CommonResponseHeader; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.response.header.CommonResponseHeaderBuilder; import org.onap.appc.util.Time; import java.text.DateFormat; diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java index a035900f2..74f3296d7 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java @@ -52,22 +52,22 @@ import org.onap.appc.logging.LoggingUtils; import org.onap.appc.provider.AppcProvider; import org.onap.appc.provider.AppcProviderClient; import org.onap.appc.provider.ResponseHeaderBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.UUID; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.request.header.CommonRequestHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.config.payload.ConfigPayload; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.vnf.resource.VnfResource; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.MigrateOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.MigrateOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.ModifyConfigOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.ModifyConfigOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RebuildOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RebuildOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RestartOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RestartOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.SnapshotOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.SnapshotOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.UUID; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.VmstatuscheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.VmstatuscheckOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.request.header.CommonRequestHeader; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.config.payload.ConfigPayload; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.vnf.resource.VnfResource; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.MDC; @@ -625,7 +625,7 @@ public class TopologyService { boolean success; String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME); - AppcProviderClient svcLogicClient = new AppcProviderClient(); + AppcProviderClient svcLogicClient = provider.getClient(); try { if (svcLogicClient.hasGraph(module, method, version, mode)) { try { diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/impl/rev140523/AppcProviderModule.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/impl/rev140523/AppcProviderModule.java deleted file mode 100644 index 0c5ef0113..000000000 --- a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/impl/rev140523/AppcProviderModule.java +++ /dev/null @@ -1,87 +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.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523; - -import org.onap.appc.provider.AppcProvider; - -/** - * This was generated code. It was generated into the source tree because it has to be manually modified. - * - */ -public class AppcProviderModule extends - org.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523.AbstractAppcProviderModule { - - /** - * @param identifier - * @param dependencyResolver - */ - @SuppressWarnings("javadoc") - public AppcProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - /** - * @param identifier - * @param dependencyResolver - * @param oldModule - * @param oldInstance - */ - @SuppressWarnings("javadoc") - public AppcProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, - org.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523.AppcProviderModule oldModule, - java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - /** - * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523.AbstractAppcProviderModule#customValidation() - */ - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - /** - * This method is manually updated to actually invoke the provider implementation - * - * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523.AbstractAppcProviderModule#createInstance() - */ - @Override - public java.lang.AutoCloseable createInstance() { - - final AppcProvider provider = - new AppcProvider(getDataBrokerDependency(), getNotificationServiceDependency(), getRpcRegistryDependency()); - return new AutoCloseable() { - - @Override - public void close() throws Exception { - provider.close(); - } - }; - - } - -} diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/impl/rev140523/AppcProviderModuleFactory.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/impl/rev140523/AppcProviderModuleFactory.java deleted file mode 100644 index 4a16e272b..000000000 --- a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/impl/rev140523/AppcProviderModuleFactory.java +++ /dev/null @@ -1,38 +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========================================================= - */ - -/** - * Generated file Generated from: yang module name: appc-provider-impl yang module local name: appc-provider-impl - * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator Generated at: Tue Sep 01 - * 13:56:34 CDT 2015 Do not modify this file unless it is present under src/main directory - */ -package org.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523; - -/** - * Generated code - * - */ -public class AppcProviderModuleFactory extends - org.opendaylight.yang.gen.v1.org.onap.appc.provider.impl.rev140523.AbstractAppcProviderModuleFactory { - -} diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java deleted file mode 100644 index c733e493b..000000000 --- a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java +++ /dev/null @@ -1,55 +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.opendaylight.yang.gen.v1.org.onap.appc.provider.lcm.impl.rev160108; - -import org.onap.appc.provider.AppcProviderLcm; - -public class AppcProviderLcmModule extends org.opendaylight.yang.gen.v1.org.onap.appc.provider.lcm.impl.rev160108.AbstractAppcProviderLcmModule { - public AppcProviderLcmModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public AppcProviderLcmModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.onap.appc.provider.lcm.impl.rev160108.AppcProviderLcmModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - final AppcProviderLcm provider = - new AppcProviderLcm(getDataBrokerDependency(), getNotificationServiceDependency(), getRpcRegistryDependency()); - return new AutoCloseable() { - - @Override - public void close() throws Exception { - provider.close(); - } - }; - } - -} diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java deleted file mode 100644 index 704336f57..000000000 --- a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/onap/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java +++ /dev/null @@ -1,36 +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========================================================= - */ - -/* -* Generated file -* -* Generated from: yang module name: appc-provider-lcm-impl yang module local name: appc-provider-lcm-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Tue Aug 16 10:40:21 IDT 2016 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.yang.gen.v1.org.onap.appc.provider.lcm.impl.rev160108; -public class AppcProviderLcmModuleFactory extends org.opendaylight.yang.gen.v1.org.onap.appc.provider.lcm.impl.rev160108.AbstractAppcProviderLcmModuleFactory { - -} diff --git a/appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100644 index c47bac7ae..000000000 --- a/appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============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========================================================= - --> - -<!-- - Starter Blueprint Camel Definition appc-aai-adapter-blueprint ---> -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> -<!--<bean id="requestDispatcher" class="org.onap.appc.requesthandler.impl.RequestHandlerImpl" scope="singleton" > -</bean> - -<service id="requestDispatcherService" interface="org.onap.appc.requesthandler.RequestHandler" ref="requestDispatcher"/> - -<reference id="aaiAdapter" availability="mandatory" activation="eager" interface="org.onap.appc.adapter.aai.AAIAdapter"/>--> - -</blueprint> diff --git a/appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml b/appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml deleted file mode 100644 index b7de48c5a..000000000 --- a/appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============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========================================================= - --> - -<!-- vi: set et smarttab sw=4 tabstop=4: --> -<snapshot> - <configuration> - <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> - <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> - <module> - - <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang - file The prefix: inside type should match the prefix of the yang file. --> - <type xmlns:prefix="org:onap:appc:provider:impl"> - prefix:appc-provider-impl - </type> - <name>appc-provider-impl</name> - - <!-- The following sections contain bindings to services defined in - the *-provider-impl yang file. For example the rpc-registry is required because - we have a dependency (or augmentation) named "rpc-registry" and which binds - to the md-sa-binding-registry. If you remove those dependencies from the - yang file then you can remove them from here. --> - <rpc-registry> - <type - xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type> - <name>binding-rpc-broker</name> - </rpc-registry> - - <data-broker> - <type - xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type> - <name>binding-data-broker</name> - </data-broker> - - <notification-service> - <type - xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding"> - binding:binding-notification-service - </type> - <name>binding-notification-broker</name> - </notification-service> - </module> - - <module> - - <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang - file The prefix: inside type should match the prefix of the yang file. --> - <type xmlns:prefix="org:onap:appc:provider:lcm:impl"> - prefix:appc-provider-lcm-impl - </type> - <name>appc-provider-lcm-impl</name> - - <!-- The following sections contain bindings to services defined in - the *-provider-impl yang file. For example the rpc-registry is required because - we have a dependency (or augmentation) named "rpc-registry" and which binds - to the md-sa-binding-registry. If you remove those dependencies from the - yang file then you can remove them from here. --> - <rpc-registry> - <type - xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type> - <name>binding-rpc-broker</name> - </rpc-registry> - - <data-broker> - <type - xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type> - <name>binding-data-broker</name> - </data-broker> - - <notification-service> - <type - xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding"> - binding:binding-notification-service - </type> - <name>binding-notification-broker</name> - </notification-service> - </module> - - - </modules> - </data> - - </configuration> - - <!-- Required capabilities are basically a listing of all modules that need - to be imported before our service can be resolved. Capabilities for dependencies - defined above are implied which is why we do not have define a required capability - for the data broker, for example. --> - <!-- <required-capabilities> --> - <!-- <capability>appc:training:sample:provider:impl?module=sample-provider-impl&revision=2014-05-23</capability> --> - <!-- </required-capabilities> --> - <required-capabilities> - <capability>org:onap:appc:provider:impl?module=appc-provider-impl&revision=2014-05-23 - </capability> - <capability>org:onap:appc:provider:lcm:impl?module=appc-provider-lcm-impl&revision=2016-01-08 - </capability> - </required-capabilities> - -</snapshot> diff --git a/appc-provider/appc-provider-bundle/src/main/resources/org/opendaylight/blueprint/provider-blueprint.xml b/appc-provider/appc-provider-bundle/src/main/resources/org/opendaylight/blueprint/provider-blueprint.xml new file mode 100644 index 000000000..0c03369bd --- /dev/null +++ b/appc-provider/appc-provider-bundle/src/main/resources/org/opendaylight/blueprint/provider-blueprint.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ONAP : APPC + ================================================================================ + Copyright (C) 2018 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========================================================= + --> +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" + odl:use-default-for-reference-types="true"> + + <reference id="svcLogicService" + interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService" /> + + <bean id="client" class="org.onap.appc.provider.AppcProviderClient"> + <argument ref="svcLogicService" /> + </bean> + + <reference id="dataBroker" + interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" + odl:type="default" /> + + <reference id="notificationService" + interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService" + odl:type="default" /> + + <reference id="rpcRegistry" + interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" + odl:type="default" /> + + <bean id="provider" class="org.onap.appc.provider.AppcProvider"> + <argument ref="dataBroker" /> + <argument ref="notificationService" /> + <argument ref="rpcRegistry" /> + <argument ref="client" /> + </bean> + <bean id="provider-lcm" class="org.onap.appc.provider.AppcProviderLcm"> + <argument ref="dataBroker" /> + <argument ref="notificationService" /> + <argument ref="rpcRegistry" /> + </bean> + + <odl:rpc-implementation ref="provider"/> + <odl:rpc-implementation ref="provider-lcm"/> + +</blueprint>
\ No newline at end of file diff --git a/appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang b/appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang deleted file mode 100644 index 56d2e70e0..000000000 --- a/appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -module appc-provider-lcm-impl { - - yang-version 1; - namespace "org:onap:appc:provider:lcm:impl"; - prefix "appc-provider-lcm-impl"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } - - description - "This module contains the base YANG definitions for - appc-provider-lcm implementation."; - - revision "2016-01-08" { - description - "Initial revision."; - } - - // This is the definition of the service implementation as a module identity. - identity appc-provider-lcm-impl { - base config:module-type; - - // Specifies the prefix for generated java classes. - config:java-name-prefix AppcProviderLcm; - } - - // Augments the 'configuration' choice node under modules/module. - // We consume the three main services, RPCs, DataStore, and Notifications - augment "/config:modules/config:module/config:configuration" { - case appc-provider-lcm-impl { - when "/config:modules/config:module/config:type = 'appc-provider-lcm-impl'"; - - container rpc-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-rpc-registry; - } - } - } - - container notification-service { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-notification-service; - } - } - } - - container data-broker { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity mdsal:binding-async-data-broker; - } - } - } - } - } -} diff --git a/appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang b/appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang deleted file mode 100644 index 83f6bfffa..000000000 --- a/appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -module appc-provider-impl { - - yang-version 1; - namespace "org:onap:appc:provider:impl"; - prefix "appc-provider-impl"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } - - description - "This module contains the base YANG definitions for - appc-provider implementation."; - - revision "2014-05-23" { - description - "Initial revision."; - } - - // This is the definition of the service implementation as a module identity. - identity appc-provider-impl { - base config:module-type; - - // Specifies the prefix for generated java classes. - config:java-name-prefix AppcProvider; - } - - // Augments the 'configuration' choice node under modules/module. - // We consume the three main services, RPCs, DataStore, and Notifications - augment "/config:modules/config:module/config:configuration" { - case appc-provider-impl { - when "/config:modules/config:module/config:type = 'appc-provider-impl'"; - - container rpc-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-rpc-registry; - } - } - } - - container notification-service { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-notification-service; - } - } - } - - container data-broker { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity mdsal:binding-async-data-broker; - } - } - } - } - } -} diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderClientTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderClientTest.java deleted file mode 100644 index 58ccc4735..000000000 --- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderClientTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.provider; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; -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.powermock.reflect.Whitebox; - -import java.util.Properties; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.powermock.api.mockito.PowerMockito.mockStatic; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({AppcProviderClient.class, FrameworkUtil.class}) -public class AppcProviderClientTest { - @Mock - private SvcLogicService svcLogicService; - @Mock - private AppcProviderClient appcProviderClient; - - @Before - public void setUp() throws Exception { - // Prepare all mocks - mockStatic(FrameworkUtil.class); - Bundle mockedBundle = mock(Bundle.class); - PowerMockito.when(FrameworkUtil.getBundle(SvcLogicService.class)).thenReturn(mockedBundle); - - BundleContext mockedBundleContext = mock(BundleContext.class); - Mockito.when(mockedBundle.getBundleContext()).thenReturn(mockedBundleContext); - - ServiceReference svcRef = mock(ServiceReference.class); - Mockito.when(mockedBundleContext.getServiceReference(SvcLogicService.NAME)).thenReturn(svcRef); - - Mockito.when(mockedBundleContext.getService(svcRef)).thenReturn(svcLogicService); - - appcProviderClient = new AppcProviderClient(); - } - - @Test - public void testNonArgumentConstructor() { - AppcProviderClient appcProviderClient = new AppcProviderClient(); - Assert.assertEquals(Whitebox.getInternalState(appcProviderClient, "svcLogic"), svcLogicService); - } - - @Test - public void hasGraph() throws Exception { - doReturn(true).when(svcLogicService).hasGraph(any(), any(), any(), any()); - boolean hasGraph = appcProviderClient.hasGraph("test-module", "test-rpc", "test-version", "test-mode"); - Assert.assertTrue(hasGraph); - } - - @Test - public void execute() throws Exception { - Properties properties = new Properties(); - appcProviderClient.execute("test-module", "test-rpc", "test-version", "test-mode", properties); - verify(svcLogicService, times(1)).execute("test-module", "test-rpc", "test-version", "test-mode", - properties); - } - -}
\ No newline at end of file diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java deleted file mode 100644 index 5c308d27b..000000000 --- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java +++ /dev/null @@ -1,1421 +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.provider; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AuditInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AuditOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.CheckLockInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.CheckLockOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupDeleteInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupDeleteOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigExportInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigExportOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigModifyInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigModifyOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigRestoreInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigRestoreOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigureInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigureOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleOutInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleOutOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleOutOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.EvacuateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.EvacuateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.HealthCheckInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.HealthCheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LiveUpgradeInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LiveUpgradeOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LockInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LockOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.MigrateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.MigrateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QuiesceTrafficInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QuiesceTrafficOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QuiesceTrafficOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ResumeTrafficInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ResumeTrafficOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ResumeTrafficOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePreCheckInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePreCheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePreCheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeSoftwareInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeSoftwareOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeSoftwareOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePostCheckInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePostCheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePostCheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackupInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackupOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackupOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackoutInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackoutOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackoutOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebuildInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebuildOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RestartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RestartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RollbackInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RollbackOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SnapshotInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SnapshotOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SoftwareUploadInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SoftwareUploadOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartApplicationInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartApplicationOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopApplicationInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopApplicationOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SyncInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SyncOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TerminateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TerminateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TestInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TestOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UnlockInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UnlockOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ZULU; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiersBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeaderBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status; -import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.StatusBuilder; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.onap.appc.domainmodel.lcm.ResponseContext; -import org.onap.appc.executor.objects.LCMCommandStatus; -import org.onap.appc.provider.lcm.service.*; -import org.onap.appc.provider.lcm.util.ValidationService; -import org.onap.appc.requesthandler.objects.RequestHandlerOutput; -import org.onap.appc.provider.Whitebox; -import java.text.DateFormat; -import java.text.SimpleDateFormat; - -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Integration Test class for AppcProviderLcm. - */ - -@SuppressWarnings("deprecation") -@RunWith(MockitoJUnitRunner.class) -public class AppcProviderLcmTest extends AbstractDataBrokerTest { - private Status successStatus = new StatusBuilder().setCode(400).setMessage("success").build(); - private Status failStatus = new StatusBuilder().setCode(302) - .setMessage("MISSING MANDATORY PARAMETER - Parameter/s common-header , action is/are missing").build(); - - private AppcProviderLcm appcProviderLcm; - private DataBroker dataBroker; - @Spy - private ValidationService validationService = ValidationService.getInstance(); - @Mock - private RequestHandlerOutput requestHandlerOutput; - @Mock - private ResponseContext responseContext; - @Mock - private org.onap.appc.domainmodel.lcm.Status successlcmStatus; - - /** - * The @Before annotation is defined in the AbstractDataBrokerTest class. The method setupWithDataBroker is invoked - * from inside the @Before method and is used to initialize the databroker with objects for a test runs. In our case - * we use this oportunity to create an instance of our provider and initialize it (which registers it as a listener - * etc). This method runs before every @Test method below. - */ - @Override - protected void setupWithDataBroker(DataBroker dataBroker) { - super.setupWithDataBroker(dataBroker); - - this.dataBroker = dataBroker; - } - - @Before - public void setUp() throws Exception { - //mock appcProviderLcm - NotificationProviderService nps = mock(NotificationProviderService.class); - RpcProviderRegistry registry = mock(RpcProviderRegistry.class); - BindingAwareBroker.RpcRegistration rpcRegistration = mock(BindingAwareBroker.RpcRegistration.class); - doReturn(rpcRegistration).when(registry).addRpcImplementation(any(), any()); - appcProviderLcm = spy(new AppcProviderLcm(dataBroker, nps, registry)); - //mock validationService - //mockStatic(ValidationService.class); - //when(ValidationService.getInstance()).thenReturn(validationService); - - doReturn(successlcmStatus).when(responseContext).getStatus(); - doReturn(400).when(successlcmStatus).getCode(); - doReturn("success").when(successlcmStatus).getMessage(); - } - - @After - public void tearDown() throws Exception { - if (appcProviderLcm != null) { - appcProviderLcm.close(); - } - } - - @Test - public void testConstructor() throws Exception { - Object executorService = Whitebox.getInternalState(appcProviderLcm, "executor"); - Assert.assertNotNull(executorService); - Object internalRpcRegistration = Whitebox.getInternalState(appcProviderLcm, - "rpcRegistration"); - Assert.assertNotNull(internalRpcRegistration); - } - - @Test - public void testClose() throws Exception { - ExecutorService executorService = spy(Executors.newFixedThreadPool(1)); - Whitebox.setInternalState(appcProviderLcm, "executor", executorService); - BindingAwareBroker.RpcRegistration rpcRegistration = mock(BindingAwareBroker.RpcRegistration.class); - Whitebox.setInternalState(appcProviderLcm, "rpcRegistration", rpcRegistration); - appcProviderLcm.close(); - verify(executorService, times(1)).shutdown(); - verify(rpcRegistration, times(1)).close(); - } - - @Test - public void testRebuild() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - RebuildInput rebuildInput = mock(RebuildInput.class); - doReturn(newCommonHeader("request-id-test")).when(rebuildInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(rebuildInput).getActionIdentifiers(); - - Future<RpcResult<RebuildOutput>> results = appcProviderLcm.rebuild(rebuildInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.rebuild(rebuildInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(rebuildInput).getActionIdentifiers(); - results = appcProviderLcm.rebuild(rebuildInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testRestart() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - RestartInput restartInput = mock(RestartInput.class); - doReturn(newCommonHeader("request-id-test")).when(restartInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(restartInput).getActionIdentifiers(); - - Future<RpcResult<RestartOutput>> results = appcProviderLcm.restart(restartInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.restart(restartInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(restartInput).getActionIdentifiers(); - results = appcProviderLcm.restart(restartInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testStartApplication() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - StartApplicationInput startApplicationInput = mock(StartApplicationInput.class); - doReturn(newCommonHeader("request-id-test")).when(startApplicationInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(startApplicationInput).getActionIdentifiers(); - - Future<RpcResult<StartApplicationOutput>> results = appcProviderLcm.startApplication(startApplicationInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.startApplication(startApplicationInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(startApplicationInput).getActionIdentifiers(); - results = appcProviderLcm.startApplication(startApplicationInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testMigrate() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - MigrateInput migrateInput = mock(MigrateInput.class); - doReturn(newCommonHeader("request-id-test")).when(migrateInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(migrateInput).getActionIdentifiers(); - - Future<RpcResult<MigrateOutput>> results = appcProviderLcm.migrate(migrateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.migrate(migrateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(migrateInput).getActionIdentifiers(); - results = appcProviderLcm.migrate(migrateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testEvacuate() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - EvacuateInput evacuateInput = mock(EvacuateInput.class); - doReturn(newCommonHeader("request-id-test")).when(evacuateInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(evacuateInput).getActionIdentifiers(); - - Future<RpcResult<EvacuateOutput>> results = appcProviderLcm.evacuate(evacuateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.evacuate(evacuateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(evacuateInput).getActionIdentifiers(); - results = appcProviderLcm.evacuate(evacuateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testSnapshot() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - SnapshotInput snapshotInput = mock(SnapshotInput.class); - doReturn(newCommonHeader("request-id-test")).when(snapshotInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(snapshotInput).getActionIdentifiers(); - - Future<RpcResult<SnapshotOutput>> results = appcProviderLcm.snapshot(snapshotInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.snapshot(snapshotInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(snapshotInput).getActionIdentifiers(); - results = appcProviderLcm.snapshot(snapshotInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testRollback() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - RollbackInput rollbackInput = mock(RollbackInput.class); - doReturn(newCommonHeader("request-id-test")).when(rollbackInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(rollbackInput).getActionIdentifiers(); - - Future<RpcResult<RollbackOutput>> results = appcProviderLcm.rollback(rollbackInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.rollback(rollbackInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(rollbackInput).getActionIdentifiers(); - results = appcProviderLcm.rollback(rollbackInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testSync() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - SyncInput syncInput = mock(SyncInput.class); - doReturn(newCommonHeader("request-id-test")).when(syncInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(syncInput).getActionIdentifiers(); - - Future<RpcResult<SyncOutput>> results = appcProviderLcm.sync(syncInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.sync(syncInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(syncInput).getActionIdentifiers(); - results = appcProviderLcm.sync(syncInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testTerminate() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - TerminateInput terminateInput = mock(TerminateInput.class); - doReturn(newCommonHeader("request-id-test")).when(terminateInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(terminateInput).getActionIdentifiers(); - - Future<RpcResult<TerminateOutput>> results = appcProviderLcm.terminate(terminateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.terminate(terminateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(terminateInput).getActionIdentifiers(); - results = appcProviderLcm.terminate(terminateInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testConfigure() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigureInput configureInput = mock(ConfigureInput.class); - doReturn(newCommonHeader("request-id-test")).when(configureInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configureInput).getActionIdentifiers(); - - Future<RpcResult<ConfigureOutput>> results = appcProviderLcm.configure(configureInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.configure(configureInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(configureInput).getActionIdentifiers(); - results = appcProviderLcm.configure(configureInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testConfigModify() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigModifyInput configModifyInput = mock(ConfigModifyInput.class); - doReturn(newCommonHeader("request-id-test")).when(configModifyInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configModifyInput).getActionIdentifiers(); - - Future<RpcResult<ConfigModifyOutput>> results = appcProviderLcm.configModify(configModifyInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.configModify(configModifyInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(configModifyInput).getActionIdentifiers(); - results = appcProviderLcm.configModify(configModifyInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testConfigScaleOut() throws Exception { - ConfigScaleOutInput mockInput = mock(ConfigScaleOutInput.class); - ConfigScaleOutOutput mockOutput = mock(ConfigScaleOutOutput.class); - ConfigScaleOutOutputBuilder mockOutputBuilder = mock(ConfigScaleOutOutputBuilder.class); - ConfigScaleOutService mockService = mock(ConfigScaleOutService.class); - - when(mockService.process(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - Future<RpcResult<ConfigScaleOutOutput>> results = appcProviderLcm.configScaleOut(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - } - - @Test - public void testConfigRestore() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigRestoreInput configRestoreInput = mock(ConfigRestoreInput.class); - doReturn(newCommonHeader("request-id-test")).when(configRestoreInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configRestoreInput).getActionIdentifiers(); - - Future<RpcResult<ConfigRestoreOutput>> results = appcProviderLcm.configRestore(configRestoreInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.configRestore(configRestoreInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(configRestoreInput).getActionIdentifiers(); - results = appcProviderLcm.configRestore(configRestoreInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testTest() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - TestInput testInput = mock(TestInput.class); - doReturn(newCommonHeader("request-id-test")).when(testInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(testInput).getActionIdentifiers(); - - Future<RpcResult<TestOutput>> results = appcProviderLcm.test(testInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.test(testInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(testInput).getActionIdentifiers(); - results = appcProviderLcm.test(testInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testStop() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - StopInput stopInput = mock(StopInput.class); - doReturn(newCommonHeader("request-id-stop")).when(stopInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(stopInput).getActionIdentifiers(); - - Future<RpcResult<StopOutput>> results = appcProviderLcm.stop(stopInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.stop(stopInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(stopInput).getActionIdentifiers(); - results = appcProviderLcm.stop(stopInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testStart() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - StartInput startInput = mock(StartInput.class); - doReturn(newCommonHeader("request-id-start")).when(startInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(startInput).getActionIdentifiers(); - - Future<RpcResult<StartOutput>> results = appcProviderLcm.start(startInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.start(startInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(startInput).getActionIdentifiers(); - results = appcProviderLcm.start(startInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testAudit() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - AuditInput auditInput = mock(AuditInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(auditInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(auditInput).getActionIdentifiers(); - - Future<RpcResult<AuditOutput>> results = appcProviderLcm.audit(auditInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.audit(auditInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(auditInput).getActionIdentifiers(); - results = appcProviderLcm.audit(auditInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testSoftwareUpload() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - SoftwareUploadInput softwareUploadInput = mock(SoftwareUploadInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(softwareUploadInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(softwareUploadInput).getActionIdentifiers(); - - Future<RpcResult<SoftwareUploadOutput>> results = appcProviderLcm.softwareUpload(softwareUploadInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.softwareUpload(softwareUploadInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(softwareUploadInput).getActionIdentifiers(); - results = appcProviderLcm.softwareUpload(softwareUploadInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testHealthCheck() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - HealthCheckInput healthCheckInput = mock(HealthCheckInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(healthCheckInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(healthCheckInput).getActionIdentifiers(); - - Future<RpcResult<HealthCheckOutput>> results = appcProviderLcm.healthCheck(healthCheckInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.healthCheck(healthCheckInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(healthCheckInput).getActionIdentifiers(); - results = appcProviderLcm.healthCheck(healthCheckInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testLiveUpgrade() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - LiveUpgradeInput liveUpgradeInput = mock(LiveUpgradeInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(liveUpgradeInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(liveUpgradeInput).getActionIdentifiers(); - - Future<RpcResult<LiveUpgradeOutput>> results = appcProviderLcm.liveUpgrade(liveUpgradeInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.liveUpgrade(liveUpgradeInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(liveUpgradeInput).getActionIdentifiers(); - results = appcProviderLcm.liveUpgrade(liveUpgradeInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testLock() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - LockInput lockInput = mock(LockInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(lockInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(lockInput).getActionIdentifiers(); - - Future<RpcResult<LockOutput>> results = appcProviderLcm.lock(lockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.lock(lockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(lockInput).getActionIdentifiers(); - results = appcProviderLcm.lock(lockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testUnlock() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - UnlockInput unlockInput = mock(UnlockInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(unlockInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(unlockInput).getActionIdentifiers(); - - Future<RpcResult<UnlockOutput>> results = appcProviderLcm.unlock(unlockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.unlock(unlockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(unlockInput).getActionIdentifiers(); - results = appcProviderLcm.unlock(unlockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testCheckLock() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - Map<String, String> additionalContext = new HashMap<>(); - additionalContext.put("locked", "true"); - doReturn(additionalContext).when(responseContext).getAdditionalContext(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - CheckLockInput checkLockInput = mock(CheckLockInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(checkLockInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(checkLockInput).getActionIdentifiers(); - - Future<RpcResult<CheckLockOutput>> results = appcProviderLcm.checkLock(checkLockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.checkLock(checkLockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(checkLockInput).getActionIdentifiers(); - results = appcProviderLcm.checkLock(checkLockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testConfigBackup() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigBackupInput configBackupInput = mock(ConfigBackupInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(configBackupInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configBackupInput).getActionIdentifiers(); - - Future<RpcResult<ConfigBackupOutput>> results = appcProviderLcm.configBackup(configBackupInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.configBackup(configBackupInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(configBackupInput).getActionIdentifiers(); - results = appcProviderLcm.configBackup(configBackupInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testConfigBackupDelete() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigBackupDeleteInput configBackupDeleteInput = mock(ConfigBackupDeleteInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(configBackupDeleteInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configBackupDeleteInput).getActionIdentifiers(); - - Future<RpcResult<ConfigBackupDeleteOutput>> results = appcProviderLcm.configBackupDelete - (configBackupDeleteInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.configBackupDelete(configBackupDeleteInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(configBackupDeleteInput).getActionIdentifiers(); - results = appcProviderLcm.configBackupDelete(configBackupDeleteInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testConfigExport() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigExportInput configExportInput = mock(ConfigExportInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(configExportInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configExportInput).getActionIdentifiers(); - - Future<RpcResult<ConfigExportOutput>> results = appcProviderLcm.configExport - (configExportInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.configExport(configExportInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(configExportInput).getActionIdentifiers(); - results = appcProviderLcm.configExport(configExportInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testStopApplication() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - StopApplicationInput stopApplicationInput = mock(StopApplicationInput.class); - doReturn(newCommonHeader("request-id-aduit")).when(stopApplicationInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(stopApplicationInput).getActionIdentifiers(); - - Future<RpcResult<StopApplicationOutput>> results = appcProviderLcm.stopApplication - (stopApplicationInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // Validation failed - doReturn(failStatus).when(validationService).validateInput(any(), any(), any()); - results = appcProviderLcm.stopApplication(stopApplicationInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //Assert.assertEquals(failStatus, results.get().getResult().getStatus()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - - // parse exception - doReturn(null).when(validationService).validateInput(any(), any(), any()); - doReturn(null).when(stopApplicationInput).getActionIdentifiers(); - results = appcProviderLcm.stopApplication(stopApplicationInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - Assert.assertTrue(303 == LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()); - //Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode() - // == results.get().getResult().getStatus().getCode()); - //verify(appcProviderLcm, times(1)).executeRequest(any()); - } - - @Test - public void testQuery() throws Exception { - QueryInput mockInput = mock(QueryInput.class); - QueryOutput mockOutput = mock(QueryOutput.class); - QueryOutputBuilder mockQueryOutputBuilder = mock(QueryOutputBuilder.class); - QueryService mockQuery = mock(QueryService.class); - - //whenNew(QueryService.class).withNoArguments().thenReturn(mockQuery); - when(mockQuery.process(mockInput)).thenReturn(mockQueryOutputBuilder); - when(mockQueryOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<QueryOutput>> results = appcProviderLcm.query(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockQuery, times(1)).process(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testReboot() throws Exception { - RebootInput mockInput = mock(RebootInput.class); - RebootOutput mockOutput = mock(RebootOutput.class); - RebootOutputBuilder mockRebootOutputBuilder = mock(RebootOutputBuilder.class); - RebootService mockReboot = mock(RebootService.class); - - //whenNew(RebootService.class).withNoArguments().thenReturn(mockReboot); - when(mockReboot.reboot(mockInput)).thenReturn(mockRebootOutputBuilder); - when(mockRebootOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<RebootOutput>> results = appcProviderLcm.reboot(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockReboot, times(1)).process(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testAttachVolume() throws Exception { - AttachVolumeInput mockInput = mock(AttachVolumeInput.class); - AttachVolumeOutput mockOutput = mock(AttachVolumeOutput.class); - AttachVolumeOutputBuilder mockOutputBuilder = mock(AttachVolumeOutputBuilder.class); - VolumeService mockVolumeService = mock(VolumeService.class); - - //whenNew(VolumeService.class).withArguments(true).thenReturn(mockVolumeService); - when(mockVolumeService.attachVolume(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<AttachVolumeOutput>> results = appcProviderLcm.attachVolume(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockVolumeService, times(1)).attachVolume(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testDetachVolume() throws Exception { - DetachVolumeInput mockInput = mock(DetachVolumeInput.class); - DetachVolumeOutput mockOutput = mock(DetachVolumeOutput.class); - DetachVolumeOutputBuilder mockOutputBuilder = mock(DetachVolumeOutputBuilder.class); - VolumeService mockVolumeService = mock(VolumeService.class); - - //whenNew(VolumeService.class).withArguments(false).thenReturn(mockVolumeService); - when(mockVolumeService.detachVolume(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<DetachVolumeOutput>> results = appcProviderLcm.detachVolume(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockVolumeService, times(1)).detachVolume(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testQuiesceTraffic() throws Exception { - QuiesceTrafficInput mockInput = mock(QuiesceTrafficInput.class); - QuiesceTrafficOutput mockOutput = mock(QuiesceTrafficOutput.class); - QuiesceTrafficOutputBuilder mockOutputBuilder = mock(QuiesceTrafficOutputBuilder.class); - QuiesceTrafficService mockService = mock(QuiesceTrafficService.class); - - //whenNew(QuiesceTrafficService.class).withNoArguments().thenReturn(mockService); - when(mockService.process(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<QuiesceTrafficOutput>> results = appcProviderLcm.quiesceTraffic(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).process(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testResumeTraffic() throws Exception { - ResumeTrafficInput mockInput = mock(ResumeTrafficInput.class); - ResumeTrafficOutput mockOutput = mock(ResumeTrafficOutput.class); - ResumeTrafficOutputBuilder mockOutputBuilder = mock(ResumeTrafficOutputBuilder.class); - ResumeTrafficService mockService = mock(ResumeTrafficService.class); - - //whenNew(ResumeTrafficService.class).withNoArguments().thenReturn(mockService); - when(mockService.process(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<ResumeTrafficOutput>> results = appcProviderLcm.resumeTraffic(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).process(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testUpgradePreCheck() throws Exception { - UpgradePreCheckInput mockInput = mock(UpgradePreCheckInput.class); - UpgradePreCheckOutput mockOutput = mock(UpgradePreCheckOutput.class); - UpgradePreCheckOutputBuilder mockOutputBuilder = mock(UpgradePreCheckOutputBuilder.class); - UpgradeService mockService = mock(UpgradeService.class); - - //whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService); - when(mockService.upgradePreCheck(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<UpgradePreCheckOutput>> results = appcProviderLcm.upgradePreCheck(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).upgradePreCheck(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - - @Test - public void testUpgradePostCheck() throws Exception { - UpgradePostCheckInput mockInput = mock(UpgradePostCheckInput.class); - UpgradePostCheckOutput mockOutput = mock(UpgradePostCheckOutput.class); - UpgradePostCheckOutputBuilder mockOutputBuilder = mock(UpgradePostCheckOutputBuilder.class); - UpgradeService mockService = mock(UpgradeService.class); - - //whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService); - when(mockService.upgradePostCheck(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<UpgradePostCheckOutput>> results = appcProviderLcm.upgradePostCheck(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).upgradePostCheck(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testUpgradeSoftware() throws Exception { - UpgradeSoftwareInput mockInput = mock(UpgradeSoftwareInput.class); - UpgradeSoftwareOutput mockOutput = mock(UpgradeSoftwareOutput.class); - UpgradeSoftwareOutputBuilder mockOutputBuilder = mock(UpgradeSoftwareOutputBuilder.class); - UpgradeService mockService = mock(UpgradeService.class); - - //whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService); - when(mockService.upgradeSoftware(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<UpgradeSoftwareOutput>> results = appcProviderLcm.upgradeSoftware(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).upgradeSoftware(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testUpgradeBackup() throws Exception { - UpgradeBackupInput mockInput = mock(UpgradeBackupInput.class); - UpgradeBackupOutput mockOutput = mock(UpgradeBackupOutput.class); - UpgradeBackupOutputBuilder mockOutputBuilder = mock(UpgradeBackupOutputBuilder.class); - UpgradeService mockService = mock(UpgradeService.class); - - //whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService); - when(mockService.upgradeBackup(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<UpgradeBackupOutput>> results = appcProviderLcm.upgradeBackup(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).upgradeBackup(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testUpgradeBackout() throws Exception { - UpgradeBackoutInput mockInput = mock(UpgradeBackoutInput.class); - UpgradeBackoutOutput mockOutput = mock(UpgradeBackoutOutput.class); - UpgradeBackoutOutputBuilder mockOutputBuilder = mock(UpgradeBackoutOutputBuilder.class); - UpgradeService mockService = mock(UpgradeService.class); - - //whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService); - when(mockService.upgradeBackout(mockInput)).thenReturn(mockOutputBuilder); - when(mockOutputBuilder.build()).thenReturn(mockOutput); - - Future<RpcResult<UpgradeBackoutOutput>> results = appcProviderLcm.upgradeBackout(mockInput); - Assert.assertTrue(302 == results.get().getResult().getStatus().getCode()); - //verify(mockService, times(1)).upgradeBackout(mockInput); - //Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult()); - } - - @Test - public void testTimestampFormatShort() throws Exception { - // Validation success - doReturn("Success").when(successlcmStatus).getMessage(); - doReturn(responseContext).when(requestHandlerOutput).getResponseContext(); - doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any()); - doReturn(null).when(validationService).validateInput(any(), any(), any()); - - ConfigExportInput configExportInput = mock(ConfigExportInput.class); - long epochWithZeroFractionalSeconds = 1529495219000l; - doReturn(newCommonHeader("request-id-aduit", epochWithZeroFractionalSeconds)).when(configExportInput).getCommonHeader(); - doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id")) - .when(configExportInput).getActionIdentifiers(); - - Future<RpcResult<ConfigExportOutput>> results = appcProviderLcm.configExport - (configExportInput); - Assert.assertEquals(302, (int)results.get().getResult().getStatus().getCode()); - } - - private ActionIdentifiers newActionIdentifier(String vnfId, String vnfcId, String vserverId) { - ActionIdentifiersBuilder actionIdentifiersBuilder = new ActionIdentifiersBuilder(); - actionIdentifiersBuilder.setVnfId(vnfId); - actionIdentifiersBuilder.setVnfcName(vnfcId); - actionIdentifiersBuilder.setVserverId(vserverId); - return actionIdentifiersBuilder.build(); - } - - private CommonHeader newCommonHeader(String requestId) { - return newCommonHeader(requestId, System.currentTimeMillis()); - } - - private CommonHeader newCommonHeader(String requestId, long epoch) { - CommonHeaderBuilder commonHeaderBuilder = new CommonHeaderBuilder(); - commonHeaderBuilder.setRequestId(requestId); - commonHeaderBuilder.setApiVer("2.0.0"); - commonHeaderBuilder.setOriginatorId("originatortest"); - DateFormat ZULU_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'"); - ZULU_FORMATTER.setTimeZone(TimeZone.getTimeZone("UTC")); - commonHeaderBuilder.setTimestamp(ZULU.getDefaultInstance(ZULU_FORMATTER.format(epoch))); - return commonHeaderBuilder.build(); - } -} diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderTest.java deleted file mode 100644 index e8e35e4f2..000000000 --- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderTest.java +++ /dev/null @@ -1,222 +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.provider; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.request.header.CommonRequestHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.config.payload.ConfigPayload; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.vnf.resource.VnfResource; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.onap.appc.provider.topology.TopologyService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.lang.reflect.Field; -import org.onap.appc.provider.Whitebox; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -@RunWith(MockitoJUnitRunner.class) -public class AppcProviderTest extends AbstractDataBrokerTest { - - @Mock - private CommonRequestHeader commonRequestHeader; - @Mock - private ConfigPayload configPayload; - @Mock - private VnfResource vnfResource; - @Mock - private TopologyService topologyService; - - private AppcProvider provider; - private DataBroker dataBroker; - - - /** - * The @Before annotation is defined in the AbstractDataBrokerTest class. The method setupWithDataBroker is invoked - * from inside the @Before method and is used to initialize the databroker with objects for a test runs. In our case - * we use this oportunity to create an instance of our provider and initialize it (which registers it as a listener - * etc). This method runs before every @Test method below. - */ - @Override - protected void setupWithDataBroker(DataBroker dataBroker) { - super.setupWithDataBroker(dataBroker); - - this.dataBroker = dataBroker; - } - - @Before - public void setUp() throws Exception { - NotificationProviderService nps = mock(NotificationProviderService.class); - RpcProviderRegistry registry = mock(RpcProviderRegistry.class); - BindingAwareBroker.RpcRegistration rpcRegistration = mock(BindingAwareBroker.RpcRegistration.class); - - doReturn(rpcRegistration).when(registry).addRpcImplementation(any(), any()); - - provider = spy(new AppcProvider(dataBroker, nps, registry)); - - doReturn(topologyService).when(provider).getTopologyService(); - } - - @Test - public void testConstructor() throws Exception { - Object executorService = Whitebox.getInternalState(provider, "executor"); - Assert.assertNotNull(executorService); - Object internalRpcRegistration = Whitebox.getInternalState(provider,"rpcRegistration"); - Assert.assertNotNull(internalRpcRegistration); - } - - @Test - public void testClose() throws Exception { - ExecutorService executorService = spy(Executors.newFixedThreadPool(1)); - Whitebox.setInternalState(provider, "executor", executorService); - BindingAwareBroker.RpcRegistration rpcRegistration = mock(BindingAwareBroker.RpcRegistration.class); - Whitebox.setInternalState(provider, "rpcRegistration", rpcRegistration); - provider.close(); - - verify(executorService, times(1)).shutdown(); - verify(rpcRegistration, times(1)).close(); - } - - @Test - public void testModifyConfig() throws Exception { - ModifyConfigInput modifyConfigInput = mock(ModifyConfigInput.class); - doReturn(commonRequestHeader).when(modifyConfigInput).getCommonRequestHeader(); - doReturn(configPayload).when(modifyConfigInput).getConfigPayload(); - // mock output - RpcResult<ModifyConfigOutput> modifyConfigOutput = mock(RpcResult.class); - doReturn(modifyConfigOutput).when(topologyService).modifyConfig(any(), any()); - - Future<RpcResult<ModifyConfigOutput>> rpcResultFuture = provider.modifyConfig(modifyConfigInput); - - Assert.assertNotNull(rpcResultFuture); - } - - @Test - public void testRebuild() throws Exception { - RebuildInput input = mock(RebuildInput.class); - RpcResult<RebuildOutput> output = mock(RpcResult.class); - doReturn(vnfResource).when(input).getVnfResource(); - doReturn(output).when(topologyService).rebuild(any(), any()); - - Future<RpcResult<RebuildOutput>> rpcResultFuture = provider.rebuild(input); - - Assert.assertNotNull(rpcResultFuture); - } - - @Test - public void testRestart() throws Exception { - RestartInput input = mock(RestartInput.class); - RpcResult<RestartOutput> output = mock(RpcResult.class); - doReturn(vnfResource).when(input).getVnfResource(); - doReturn(output).when(topologyService).restart(any(), any()); - - Future<RpcResult<RestartOutput>> rpcResultFuture = provider.restart(input); - - Assert.assertNotNull(rpcResultFuture); - } - - @Test - public void testMigrate() throws Exception { - MigrateInput input = mock(MigrateInput.class); - RpcResult<MigrateOutput> output = mock(RpcResult.class); - doReturn(vnfResource).when(input).getVnfResource(); - doReturn(output).when(topologyService).migrate(any(), any()); - - Future<RpcResult<MigrateOutput>> rpcResultFuture = provider.migrate(input); - - Assert.assertNotNull(rpcResultFuture); - } - - @Test - public void testEvacuate() throws Exception { - EvacuateInput input = mock(EvacuateInput.class); - doReturn(vnfResource).when(input).getVnfResource(); - - Future<RpcResult<EvacuateOutput>> rpcResultFuture = provider.evacuate(input); - - Assert.assertNull(rpcResultFuture); - } - - @Test - public void testSnapshot() throws Exception { - SnapshotInput input = mock(SnapshotInput.class); - RpcResult<SnapshotOutput> output = mock(RpcResult.class); - doReturn(vnfResource).when(input).getVnfResource(); - doReturn(output).when(topologyService).snapshot(any(), any()); - - Future<RpcResult<SnapshotOutput>> rpcResultFuture = provider.snapshot(input); - - Assert.assertNotNull(rpcResultFuture); - } - - @Test - public void testVmstatuscheck() throws Exception { - VmstatuscheckInput input = mock(VmstatuscheckInput.class); - RpcResult<VmstatuscheckOutput> output = mock(RpcResult.class); - doReturn(vnfResource).when(input).getVnfResource(); - doReturn(output).when(topologyService).vmstatuscheck(any(), any()); - - Future<RpcResult<VmstatuscheckOutput>> rpcResultFuture = provider.vmstatuscheck(input); - - Assert.assertNotNull(rpcResultFuture); - } - - @After - public void tearDown() throws Exception { - if (provider != null) { - provider.close(); - } - } -}
\ No newline at end of file diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/ResponseHeaderBuilderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/ResponseHeaderBuilderTest.java index 496f9ea99..f262d91f8 100644 --- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/ResponseHeaderBuilderTest.java +++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/ResponseHeaderBuilderTest.java @@ -25,7 +25,7 @@ package org.onap.appc.provider; import org.junit.Assert; import org.junit.Test; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.response.header.CommonResponseHeader; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.response.header.CommonResponseHeader; public class ResponseHeaderBuilderTest { diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java index 96703efa8..f3014e264 100644 --- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java +++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java @@ -27,10 +27,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.UUID; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.request.header.CommonRequestHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.config.payload.ConfigPayload; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.vnf.resource.VnfResource; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.UUID; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.request.header.CommonRequestHeader; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.config.payload.ConfigPayload; +import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.vnf.resource.VnfResource; import org.onap.appc.configuration.Configuration; import org.onap.appc.configuration.ConfigurationFactory; import org.onap.appc.provider.AppcProvider; |