summaryrefslogtreecommitdiffstats
path: root/appc-provider
diff options
context:
space:
mode:
Diffstat (limited to 'appc-provider')
-rw-r--r--appc-provider/appc-provider-bundle/pom.xml58
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java108
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java70
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java87
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderClientTest.java99
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderLcmTest.java1118
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderTest.java225
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/ResponseHeaderBuilderTest.java38
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/topology/TopologyServiceTest.java157
9 files changed, 1758 insertions, 202 deletions
diff --git a/appc-provider/appc-provider-bundle/pom.xml b/appc-provider/appc-provider-bundle/pom.xml
index 53c883527..8feb9d056 100644
--- a/appc-provider/appc-provider-bundle/pom.xml
+++ b/appc-provider/appc-provider-bundle/pom.xml
@@ -23,7 +23,7 @@
============LICENSE_END=========================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>appc-provider</artifactId>
@@ -40,7 +40,8 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Export-Package>org.opendaylight.controller.config.yang.config.sample_provider.impl</Export-Package>
+ <Export-Package>org.opendaylight.controller.config.yang.config.sample_provider.impl
+ </Export-Package>
<Export-Package>org.openecomp.appc.provider</Export-Package>
<!-- <Import-Package>!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.apache.log,*;resolution:=optional</Import-Package> -->
<!-- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false,domain-model-lib,appc-command-executor-api,appc-request-handler-api</Embed-Dependency> -->
@@ -73,14 +74,20 @@
<configuration>
<codeGenerators>
<generator>
- <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+ <codeGeneratorClass>
+ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ </codeGeneratorClass>
<outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
<additionalConfiguration>
- <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+ <namespaceToPackage1>
+ urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+ </namespaceToPackage1>
</additionalConfiguration>
</generator>
<generator>
- <codeGeneratorClass>org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+ <codeGeneratorClass>
+ org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl
+ </codeGeneratorClass>
<outputBaseDir>${salGeneratorPath}</outputBaseDir>
</generator>
</codeGenerators>
@@ -146,7 +153,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
@@ -163,18 +170,18 @@
<version>${project.version}</version>
<type>bundle</type>
<scope>provided</scope>
-<!-- <exclusions> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.openecomp.appc</groupId> -->
-<!-- <artifactId>domain-model-lib</artifactId> -->
-<!-- </exclusion> -->
-<!-- </exclusions> -->
+ <!-- <exclusions> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.openecomp.appc</groupId> -->
+ <!-- <artifactId>domain-model-lib</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- </exclusions> -->
</dependency>
<dependency>
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-common</artifactId>
<version>${project.version}</version>
-<!-- <classifier>jar-with-dependencies</classifier> -->
+ <!-- <classifier>jar-with-dependencies</classifier> -->
</dependency>
<dependency>
<groupId>org.openecomp.appc</groupId>
@@ -183,11 +190,11 @@
</dependency>
<!-- ADDED THIS ARTIFACT TO BE ABLE TO FIND org.openecomp.appc.domainmodel.lcm -->
-<!-- <dependency> -->
-<!-- <groupId>org.openecomp.appc</groupId> -->
-<!-- <artifactId>domain-model-lib</artifactId> -->
-<!-- <version>${project.version}</version> -->
-<!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.openecomp.appc</groupId> -->
+ <!-- <artifactId>domain-model-lib</artifactId> -->
+ <!-- <version>${project.version}</version> -->
+ <!-- </dependency> -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
@@ -241,6 +248,21 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- TEMP CODE -->
<dependency>
<groupId>org.json</groupId>
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
index 9989bddbc..2fd3b4f8d 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
@@ -9,65 +9,53 @@
* 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.openecomp.appc.provider;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.common.util.concurrent.Futures;
-import org.json.JSONObject;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
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.openecomp.appc.rev160104.*;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.AppcProviderService;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.EvacuateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.EvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.ModifyConfigInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.ModifyConfigOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.SnapshotInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.VmstatuscheckInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.VmstatuscheckOutput;
import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.request.header.CommonRequestHeader;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.responseattributes.StatusBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.responseheader.ResponseHeaderBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.config.payload.ConfigPayload;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.openecomp.appc.Constants;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
-import org.openecomp.appc.executor.objects.LCMCommandStatus;
-import org.openecomp.appc.executor.objects.Params;
import org.openecomp.appc.i18n.Msg;
-import org.openecomp.appc.provider.lcm.util.RequestInputBuilder;
-import org.openecomp.appc.provider.lcm.util.ValidationService;
import org.openecomp.appc.provider.topology.TopologyService;
-import org.openecomp.appc.requesthandler.RequestHandler;
-import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
-import org.openecomp.appc.requesthandler.objects.RequestHandlerOutput;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.status.Status;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.Action;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.TimeZone;
+
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -110,8 +98,6 @@ public class AppcProvider implements AutoCloseable, AppcProviderService {
private final ExecutorService executor;
- private ListenerRegistration<DataChangeListener> dclServices;
-
/**
* The ODL data store broker. Provides access to a conceptual data tree store and also provides the ability to
* subscribe for changes to data under a given branch of the tree.
@@ -181,14 +167,13 @@ public class AppcProvider implements AutoCloseable, AppcProviderService {
logger.info(Msg.COMPONENT_TERMINATED, appName, "provider");
}
+ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input) {
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ ConfigPayload data = input.getConfigPayload();
+ RpcResult<ModifyConfigOutput> result = getTopologyService().modifyConfig(hdr, data);
+ return Futures.immediateFuture(result);
+ }
-public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input){
- CommonRequestHeader hdr = input.getCommonRequestHeader();
- ConfigPayload data = input.getConfigPayload();
- TopologyService topology = new TopologyService(this);
- RpcResult<ModifyConfigOutput> result = topology.modifyConfig(hdr, data);
- return Futures.immediateFuture(result);
-}
/**
* Rebuilds a specific VNF
*
@@ -200,8 +185,7 @@ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput inpu
CommonRequestHeader hdr = input.getCommonRequestHeader();
VnfResource vnf = input.getVnfResource();
- TopologyService topology = new TopologyService(this);
- RpcResult<RebuildOutput> result = topology.rebuild(hdr, vnf);
+ RpcResult<RebuildOutput> result = getTopologyService().rebuild(hdr, vnf);
return Futures.immediateFuture(result);
}
@@ -215,8 +199,7 @@ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput inpu
CommonRequestHeader hdr = input.getCommonRequestHeader();
VnfResource vnf = input.getVnfResource();
- TopologyService topology = new TopologyService(this);
- RpcResult<RestartOutput> result = topology.restart(hdr, vnf);
+ RpcResult<RestartOutput> result = getTopologyService().restart(hdr, vnf);
return Futures.immediateFuture(result);
}
@@ -230,8 +213,7 @@ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput inpu
CommonRequestHeader hdr = input.getCommonRequestHeader();
VnfResource vnf = input.getVnfResource();
- TopologyService topology = new TopologyService(this);
- RpcResult<MigrateOutput> result = topology.migrate(hdr, vnf);
+ RpcResult<MigrateOutput> result = getTopologyService().migrate(hdr, vnf);
return Futures.immediateFuture(result);
}
@@ -242,10 +224,7 @@ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput inpu
*/
@Override
public Future<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) {
- CommonRequestHeader hdr = input.getCommonRequestHeader();
- VnfResource vnf = input.getVnfResource();
- TopologyService topology = new TopologyService(this);
return null;
}
@@ -259,23 +238,24 @@ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput inpu
CommonRequestHeader hdr = input.getCommonRequestHeader();
VnfResource vnf = input.getVnfResource();
- TopologyService topology = new TopologyService(this);
- RpcResult<SnapshotOutput> result = topology.snapshot(hdr, vnf);
+ RpcResult<SnapshotOutput> result = getTopologyService().snapshot(hdr, vnf);
return Futures.immediateFuture(result);
}
-
-
+
/**
* Checks status of a VM
- */
+ */
@Override
public Future<RpcResult<VmstatuscheckOutput>> vmstatuscheck(VmstatuscheckInput input) {
- CommonRequestHeader hdr = input.getCommonRequestHeader();
- VnfResource vnf = input.getVnfResource();
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
- TopologyService topology = new TopologyService(this);
- RpcResult<VmstatuscheckOutput> result = topology.vmstatuscheck(hdr, vnf);
- return Futures.immediateFuture(result);
- }
+ TopologyService topology = getTopologyService();
+ RpcResult<VmstatuscheckOutput> result = getTopologyService().vmstatuscheck(hdr, vnf);
+ return Futures.immediateFuture(result);
+ }
-}
+ TopologyService getTopologyService() {
+ return new TopologyService(this);
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
index 370ed5287..b13a74201 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
@@ -503,25 +503,6 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
return buildStatus(statusCode, statusMessage);
}
- private RequestHandlerOutput executeRequest(RequestHandlerInput request){
- RequestHandler handler = getRequestHandler();
- RequestHandlerOutput requestHandlerOutput;
- if (handler != null) {
- try {
- requestHandlerOutput = handler.handleRequest(request);
- } catch (Exception e) {
- logger.info("UNEXPECTED FAILURE while executing " + request.getRequestContext().getAction().name());
- requestHandlerOutput = createErrorRequestHandlerObj(request,
- LCMCommandStatus.UNEXPECTED_ERROR, Msg.EXCEPTION_CALLING_DG, e);
- }
- } else {
- String errorMsg = "LCM request cannot be processed at the moment because APPC isn't running";
- requestHandlerOutput = createErrorRequestHandlerObj(request,
- LCMCommandStatus.REJECTED, Msg.REQUEST_HANDLER_UNAVAILABLE, new APPCException(errorMsg));
- }
- return requestHandlerOutput;
- }
-
private RequestHandlerOutput createErrorRequestHandlerObj(RequestHandlerInput request,
LCMCommandStatus cmdStatus,
Msg msg,
@@ -1006,33 +987,39 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
public Future<RpcResult<CheckLockOutput>> checkLock(CheckLockInput input) {
logger.debug("Input received : " + input.toString());
CheckLockOutputBuilder outputBuilder = new CheckLockOutputBuilder();
- String action = Action.CheckLock.toString() ;
+ String action = Action.CheckLock.toString();
String rpcName = Action.CheckLock.name().toLowerCase();
- RequestHandlerOutput requestHandlerOutput=null;
- Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
- if(null == status) {
+ RequestHandlerOutput requestHandlerOutput = null;
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(),
+ input.getAction(), action);
+ if (null == status) {
try {
- RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
- requestHandlerOutput=executeRequest(request);
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input
+ .getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action)
+ .rpcName(rpcName).build();
+ requestHandlerOutput = executeRequest(request);
status = buildStatusWithDispatcherOutput(requestHandlerOutput);
- logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s",
+ input.getActionIdentifiers(), status.getCode(), status.getMessage()));
} catch (ParseException e) {
status = buildParsingErrorStatus(e);
LoggingUtils.logErrorMessage(
- LoggingConstants.TargetNames.APPC_PROVIDER,
- String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
- this.getClass().getName());
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
}
}
outputBuilder.setCommonHeader(input.getCommonHeader());
outputBuilder.setStatus(status);
- if(requestHandlerOutput.getResponseContext().getStatus().getCode() == 400) {
- outputBuilder.setLocked(CheckLockOutput.Locked.valueOf(requestHandlerOutput.getResponseContext().getAdditionalContext().get("locked").toUpperCase()));
+ if (requestHandlerOutput != null && requestHandlerOutput.getResponseContext().getStatus().getCode() == 400) {
+ outputBuilder.setLocked(CheckLockOutput.Locked.valueOf(requestHandlerOutput.getResponseContext()
+ .getAdditionalContext().get("locked").toUpperCase()));
}
- RpcResult<CheckLockOutput> result = RpcResultBuilder.<CheckLockOutput> status(true).withResult(outputBuilder.build()).build();
+ RpcResult<CheckLockOutput> result = RpcResultBuilder.<CheckLockOutput>status(true)
+ .withResult(outputBuilder.build()).build();
return Futures.immediateFuture(result);
}
@@ -1191,5 +1178,22 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
.toLowerCase();
}
-
+ RequestHandlerOutput executeRequest(RequestHandlerInput request){
+ RequestHandler handler = getRequestHandler();
+ RequestHandlerOutput requestHandlerOutput;
+ if (handler != null) {
+ try {
+ requestHandlerOutput = handler.handleRequest(request);
+ } catch (Exception e) {
+ logger.info("UNEXPECTED FAILURE while executing " + request.getRequestContext().getAction().name());
+ requestHandlerOutput = createErrorRequestHandlerObj(request,
+ LCMCommandStatus.UNEXPECTED_ERROR, Msg.EXCEPTION_CALLING_DG, e);
+ }
+ } else {
+ String errorMsg = "LCM request cannot be processed at the moment because APPC isn't running";
+ requestHandlerOutput = createErrorRequestHandlerObj(request,
+ LCMCommandStatus.REJECTED, Msg.REQUEST_HANDLER_UNAVAILABLE, new APPCException(errorMsg));
+ }
+ return requestHandlerOutput;
+ }
}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java
deleted file mode 100644
index e5eb5875e..000000000
--- a/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java
+++ /dev/null
@@ -1,87 +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.openecomp.appc;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-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.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.openecomp.appc.provider.AppcProvider;
-
-/**
- * Defines a unit test class which tests the provider. This class leverages the AbstractDataBrokerTest class which
- * starts a real MD-SAL implementation to use inside of your unit tests. This is not an exhaustive test, but rather is
- * used to illustrate how one can leverage the AbstractDataBrokerTest to test MD-SAL providers/listeners.
- */
-public class AppcProviderTest extends AbstractDataBrokerTest {
-
- private ExecutorService threadPool = Executors.newSingleThreadExecutor();
- 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;
- NotificationProviderService nps = null;
- RpcProviderRegistry registry = null;
-
- provider = new AppcProvider(dataBroker, nps, registry);
- }
-
- /**
- * Shuts down our provider, testing close code. @After runs after every @Test method below.
- */
- @After
- public void stop() throws Exception {
- if (provider != null) {
- provider.close();
- }
- }
-
- /**
- * This validates that when a task is created, the run count is initialized to 0
- */
- @Ignore
- @Test
- public void sampleUnitTest() {
- // This is where you add your unit testing. You can access "DataBroker" as
- // needed to create items etc.
- // This a "Real" data broker.
- }
-}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderClientTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderClientTest.java
new file mode 100644
index 000000000..99d3122a2
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderClientTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============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.openecomp.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/openecomp/appc/provider/AppcProviderLcmTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderLcmTest.java
new file mode 100644
index 000000000..11ab106e1
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderLcmTest.java
@@ -0,0 +1,1118 @@
+/*-
+ * ============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.openecomp.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.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.openecomp.appc.lcm.rev160108.AuditInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.AuditOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.CheckLockInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.CheckLockOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigBackupDeleteInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigBackupDeleteOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigBackupInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigBackupOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigExportInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigExportOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigModifyInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigModifyOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigRestoreInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigRestoreOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigScaleoutInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigScaleoutOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigureInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ConfigureOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.EvacuateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.EvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.HealthCheckInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.HealthCheckOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.LiveUpgradeInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.LiveUpgradeOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.LockInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.LockOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.MigrateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.RebuildInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.RestartInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.RollbackInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.RollbackOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.SnapshotInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.SoftwareUploadInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.SoftwareUploadOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StartApplicationInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StartApplicationOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StartInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StartOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StopApplicationInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StopApplicationOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StopInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.StopOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.SyncInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.SyncOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.TerminateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.TerminateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.TestInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.TestOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.UnlockInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.UnlockOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.ZULU;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.action.identifiers.ActionIdentifiersBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.StatusBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.openecomp.appc.domainmodel.lcm.ResponseContext;
+import org.openecomp.appc.executor.objects.LCMCommandStatus;
+import org.openecomp.appc.provider.lcm.util.ValidationService;
+import org.openecomp.appc.requesthandler.objects.RequestHandlerOutput;
+import org.osgi.framework.FrameworkUtil;
+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.time.Clock;
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.Map;
+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.powermock.api.mockito.PowerMockito.mockStatic;
+
+/**
+ * Integration Test class for AppcProviderLcm.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({FrameworkUtil.class, AppcProviderLcm.class, ValidationService.class})
+public class AppcProviderLcmTest extends AbstractDataBrokerTest {
+ private Status successStatus = new StatusBuilder().setCode(400).setMessage("success").build();
+ private Status failStatus = new StatusBuilder().setCode(401).setMessage("failure").build();
+
+ private AppcProviderLcm appcProviderLcm;
+ private DataBroker dataBroker;
+ @Spy
+ private ValidationService validationService = ValidationService.getInstance();
+ @Mock
+ private RequestHandlerOutput requestHandlerOutput;
+ @Mock
+ private ResponseContext responseContext;
+ @Mock
+ private org.openecomp.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);
+ PowerMockito.doReturn(rpcRegistration).when(registry).addRpcImplementation(any(), any());
+ appcProviderLcm = spy(new AppcProviderLcm(dataBroker, nps, registry));
+ //mock validationService
+ mockStatic(ValidationService.class);
+ PowerMockito.when(ValidationService.getInstance()).thenReturn(validationService);
+
+ doReturn(successlcmStatus).when(responseContext).getStatus();
+ doReturn(400).when(successlcmStatus).getCode();
+ doReturn("success").when(successlcmStatus).getMessage();
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ ExecutorService executorService = Whitebox.getInternalState(appcProviderLcm, "executor");
+ Assert.assertNotNull(executorService);
+ BindingAwareBroker.RpcRegistration 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(400 == 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.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(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(400 == 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.restart(restartInput);
+ 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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()
+ == results.get().getResult().getStatus().getCode());
+ verify(appcProviderLcm, times(1)).executeRequest(any());
+ }
+
+ @Test
+ public void testConfigScaleout() 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());
+
+ ConfigScaleoutInput configScaleoutInput = mock(ConfigScaleoutInput.class);
+ doReturn(newCommonHeader("request-id-test")).when(configScaleoutInput).getCommonHeader();
+ doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id"))
+ .when(configScaleoutInput).getActionIdentifiers();
+
+ Future<RpcResult<ConfigScaleoutOutput>> results = appcProviderLcm.configScaleout(configScaleoutInput);
+ Assert.assertTrue(400 == 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.configScaleout(configScaleoutInput);
+ 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(configScaleoutInput).getActionIdentifiers();
+ results = appcProviderLcm.configScaleout(configScaleoutInput);
+ Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()
+ == results.get().getResult().getStatus().getCode());
+ verify(appcProviderLcm, times(1)).executeRequest(any());
+ }
+
+ @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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(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(400 == 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.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(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()
+ == results.get().getResult().getStatus().getCode());
+ verify(appcProviderLcm, times(1)).executeRequest(any());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (appcProviderLcm != null) {
+ appcProviderLcm.close();
+ }
+ }
+
+ 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) {
+ CommonHeaderBuilder commonHeaderBuilder = new CommonHeaderBuilder();
+ commonHeaderBuilder.setRequestId(requestId);
+ commonHeaderBuilder.setApiVer("2.0.0");
+ commonHeaderBuilder.setOriginatorId("originatortest");
+ commonHeaderBuilder.setTimestamp(ZULU.getDefaultInstance(LocalDateTime.now(Clock.systemUTC()).toString() +
+ "Z"));
+ return commonHeaderBuilder.build();
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderTest.java
new file mode 100644
index 000000000..e6f47b7ea
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/AppcProviderTest.java
@@ -0,0 +1,225 @@
+/*-
+ * ============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.openecomp.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.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.openecomp.appc.rev160104.EvacuateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.EvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.ModifyConfigInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.ModifyConfigOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.SnapshotInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.VmstatuscheckInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.VmstatuscheckOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.request.header.CommonRequestHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.openecomp.appc.provider.topology.TopologyService;
+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.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;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({AppcProvider.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);
+ PowerMockito.doReturn(rpcRegistration).when(registry).addRpcImplementation(any(), any());
+
+ provider = spy(new AppcProvider(dataBroker, nps, registry));
+
+ PowerMockito.doReturn(topologyService).when(provider).getTopologyService();
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ ExecutorService executorService = Whitebox.getInternalState(provider, "executor");
+ Assert.assertNotNull(executorService);
+ BindingAwareBroker.RpcRegistration 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);
+ PowerMockito.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/openecomp/appc/provider/ResponseHeaderBuilderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/ResponseHeaderBuilderTest.java
new file mode 100644
index 000000000..fad60a239
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/ResponseHeaderBuilderTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.openecomp.appc.provider;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.response.header.CommonResponseHeader;
+
+public class ResponseHeaderBuilderTest {
+
+ @Test
+ public void buildHeader() throws Exception {
+ CommonResponseHeader commonResponseHeader = ResponseHeaderBuilder.buildHeader(true, "request-id", "reason", 1L);
+ Assert.assertNotNull(commonResponseHeader.getCompleted());
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/topology/TopologyServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/topology/TopologyServiceTest.java
new file mode 100644
index 000000000..215b10a31
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/provider/topology/TopologyServiceTest.java
@@ -0,0 +1,157 @@
+/*-
+ * ============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.openecomp.appc.provider.topology;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.UUID;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.request.header.CommonRequestHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.provider.AppcProvider;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.internal.verification.VerificationModeFactory.times;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.spy;
+import static org.powermock.api.mockito.PowerMockito.verifyPrivate;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({TopologyService.class, ConfigurationFactory.class})
+public class TopologyServiceTest {
+ @Mock
+ private AppcProvider appcProvider;
+ private TopologyService topologyService;
+
+ @Before
+ public void setUp() throws Exception {
+ mockStatic(ConfigurationFactory.class);
+ Configuration configuration = mock(Configuration.class);
+ when(ConfigurationFactory.getConfiguration()).thenReturn(configuration);
+ doReturn("NODE_NAME").when(configuration).getProperty("appc.provider.vfodl.url");
+
+ topologyService = spy(new TopologyService(appcProvider));
+ }
+
+ @Test
+ public void modifyConfig() throws Exception {
+ CommonRequestHeader commonRequestHeader = mock(CommonRequestHeader.class);
+ doReturn("request-id").when(commonRequestHeader).getServiceRequestId();
+ ConfigPayload configPayload = mock(ConfigPayload.class);
+ doReturn("url").when(configPayload).getConfigUrl();
+ doReturn("configJson").when(configPayload).getConfigJson();
+ PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
+
+ topologyService.modifyConfig(commonRequestHeader, configPayload);
+
+ verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ }
+
+ @Test
+ public void migrate() throws Exception {
+ CommonRequestHeader commonRequestHeader = mock(CommonRequestHeader.class);
+ doReturn("request-id").when(commonRequestHeader).getServiceRequestId();
+ VnfResource vnfResource = mock(VnfResource.class);
+ UUID uuid = mock(UUID.class);
+ doReturn("uuid-value").when(uuid).getValue();
+ doReturn(uuid).when(vnfResource).getVmId();
+ PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
+
+ topologyService.migrate(commonRequestHeader, vnfResource);
+
+ verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ }
+
+ @Test
+ public void restart() throws Exception {
+ CommonRequestHeader commonRequestHeader = mock(CommonRequestHeader.class);
+ doReturn("request-id").when(commonRequestHeader).getServiceRequestId();
+ VnfResource vnfResource = mock(VnfResource.class);
+ UUID uuid = mock(UUID.class);
+ doReturn("uuid-value").when(uuid).getValue();
+ doReturn(uuid).when(vnfResource).getVmId();
+ PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
+
+ topologyService.restart(commonRequestHeader, vnfResource);
+
+ verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ }
+
+ @Test
+ public void rebuild() throws Exception {
+ CommonRequestHeader commonRequestHeader = mock(CommonRequestHeader.class);
+ doReturn("request-id").when(commonRequestHeader).getServiceRequestId();
+ VnfResource vnfResource = mock(VnfResource.class);
+ UUID uuid = mock(UUID.class);
+ doReturn("uuid-value").when(uuid).getValue();
+ doReturn(uuid).when(vnfResource).getVmId();
+ PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
+
+ topologyService.rebuild(commonRequestHeader, vnfResource);
+
+ verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ }
+
+ @Test
+ public void snapshot() throws Exception {
+ CommonRequestHeader commonRequestHeader = mock(CommonRequestHeader.class);
+ doReturn("request-id").when(commonRequestHeader).getServiceRequestId();
+ VnfResource vnfResource = mock(VnfResource.class);
+ UUID uuid = mock(UUID.class);
+ doReturn("uuid-value").when(uuid).getValue();
+ doReturn(uuid).when(vnfResource).getVmId();
+ PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
+
+ topologyService.snapshot(commonRequestHeader, vnfResource);
+
+ verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ }
+
+ @Test
+ public void vmstatuscheck() throws Exception {
+ CommonRequestHeader commonRequestHeader = mock(CommonRequestHeader.class);
+ doReturn("request-id").when(commonRequestHeader).getServiceRequestId();
+ VnfResource vnfResource = mock(VnfResource.class);
+ UUID uuid = mock(UUID.class);
+ doReturn("uuid-value").when(uuid).getValue();
+ doReturn(uuid).when(vnfResource).getVmId();
+ PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
+
+ topologyService.vmstatuscheck(commonRequestHeader, vnfResource);
+
+ verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ }
+
+} \ No newline at end of file