summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/test/java/org/onap
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-12-13 11:19:06 -0800
committerPatrick Brady <pb071s@att.com>2017-12-13 11:19:17 -0800
commit781b1a6df324419c846c84ea983c18fc8362bfd3 (patch)
tree580008010dd50ca32db2ef6dc2e36628cf8c2b5b /appc-provider/appc-provider-bundle/src/test/java/org/onap
parent161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a (diff)
Third part of onap rename
This part of the commit changes the folder structure on all other folders of appc. Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3 Signed-off-by: Patrick Brady <pb071s@att.com> Issue-ID: APPC-13
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/test/java/org/onap')
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderClientTest.java99
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java1118
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderTest.java225
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/ResponseHeaderBuilderTest.java38
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java157
5 files changed, 1637 insertions, 0 deletions
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderClientTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderClientTest.java
new file mode 100644
index 000000000..58ccc4735
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/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.onap.appc.provider;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Properties;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({AppcProviderClient.class, FrameworkUtil.class})
+public class AppcProviderClientTest {
+ @Mock
+ private SvcLogicService svcLogicService;
+ @Mock
+ private AppcProviderClient appcProviderClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Prepare all mocks
+ mockStatic(FrameworkUtil.class);
+ Bundle mockedBundle = mock(Bundle.class);
+ PowerMockito.when(FrameworkUtil.getBundle(SvcLogicService.class)).thenReturn(mockedBundle);
+
+ BundleContext mockedBundleContext = mock(BundleContext.class);
+ Mockito.when(mockedBundle.getBundleContext()).thenReturn(mockedBundleContext);
+
+ ServiceReference svcRef = mock(ServiceReference.class);
+ Mockito.when(mockedBundleContext.getServiceReference(SvcLogicService.NAME)).thenReturn(svcRef);
+
+ Mockito.when(mockedBundleContext.getService(svcRef)).thenReturn(svcLogicService);
+
+ appcProviderClient = new AppcProviderClient();
+ }
+
+ @Test
+ public void testNonArgumentConstructor() {
+ AppcProviderClient appcProviderClient = new AppcProviderClient();
+ Assert.assertEquals(Whitebox.getInternalState(appcProviderClient, "svcLogic"), svcLogicService);
+ }
+
+ @Test
+ public void hasGraph() throws Exception {
+ doReturn(true).when(svcLogicService).hasGraph(any(), any(), any(), any());
+ boolean hasGraph = appcProviderClient.hasGraph("test-module", "test-rpc", "test-version", "test-mode");
+ Assert.assertTrue(hasGraph);
+ }
+
+ @Test
+ public void execute() throws Exception {
+ Properties properties = new Properties();
+ appcProviderClient.execute("test-module", "test-rpc", "test-version", "test-mode", properties);
+ verify(svcLogicService, times(1)).execute("test-module", "test-rpc", "test-version", "test-mode",
+ properties);
+ }
+
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
new file mode 100644
index 000000000..f25df9c44
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/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.onap.appc.provider;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AuditInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AuditOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.CheckLockInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.CheckLockOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupDeleteInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupDeleteOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigBackupOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigExportInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigExportOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigModifyInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigModifyOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigRestoreInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigRestoreOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleoutInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleoutOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigureInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigureOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.EvacuateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.EvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.HealthCheckInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.HealthCheckOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LiveUpgradeInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LiveUpgradeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LockInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LockOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.MigrateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebuildInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RestartInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RollbackInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RollbackOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SnapshotInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SoftwareUploadInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SoftwareUploadOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartApplicationInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartApplicationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopApplicationInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopApplicationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SyncInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.SyncOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TerminateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TerminateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TestInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.TestOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UnlockInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UnlockOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ZULU;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiersBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.StatusBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.provider.lcm.util.ValidationService;
+import org.onap.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.onap.appc.domainmodel.lcm.Status successlcmStatus;
+
+ /**
+ * The @Before annotation is defined in the AbstractDataBrokerTest class. The method setupWithDataBroker is invoked
+ * from inside the @Before method and is used to initialize the databroker with objects for a test runs. In our case
+ * we use this oportunity to create an instance of our provider and initialize it (which registers it as a listener
+ * etc). This method runs before every @Test method below.
+ */
+ @Override
+ protected void setupWithDataBroker(DataBroker dataBroker) {
+ super.setupWithDataBroker(dataBroker);
+
+ this.dataBroker = dataBroker;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ //mock appcProviderLcm
+ NotificationProviderService nps = mock(NotificationProviderService.class);
+ RpcProviderRegistry registry = mock(RpcProviderRegistry.class);
+ BindingAwareBroker.RpcRegistration rpcRegistration = mock(BindingAwareBroker.RpcRegistration.class);
+ 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/onap/appc/provider/AppcProviderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderTest.java
new file mode 100644
index 000000000..31598c9c9
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/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.onap.appc.provider;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.EvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.ModifyConfigOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.VmstatuscheckOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.request.header.CommonRequestHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.vnf.resource.VnfResource;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.onap.appc.provider.topology.TopologyService;
+import 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/onap/appc/provider/ResponseHeaderBuilderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/ResponseHeaderBuilderTest.java
new file mode 100644
index 000000000..f910a908d
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/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.onap.appc.provider;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.response.header.CommonResponseHeader;
+
+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/onap/appc/provider/topology/TopologyServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java
new file mode 100644
index 000000000..8bb84b544
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/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.onap.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.onap.appc.rev160104.UUID;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.common.request.header.CommonRequestHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.rev160104.vnf.resource.VnfResource;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.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