summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/test/java
diff options
context:
space:
mode:
authorAnand <ac204h@att.com>2018-01-04 19:35:51 -0500
committerSkip Wonnell <skip@att.com>2018-01-08 22:09:50 +0000
commit36bcd566167f2f91c0e8e7a304fce5f6bc150776 (patch)
tree7ba7acfee7e520da83a2b6286ea464285bc8cf67 /appc-provider/appc-provider-bundle/src/test/java
parent38d293d605b42f88c9c82319ba848b4b81e45b64 (diff)
Include impacted changes for APPC-346,APPC-348
Issue-ID: APPC-347 Change-Id: I399bc2a1e0dfd481e103032a373bb80fce5baf41 Signed-off-by: Anand <ac204h@att.com>
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/test/java')
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java225
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseServiceTest.java212
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseUtilsTest.java204
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ActionStatusServiceTest.java197
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QueryServiceTest.java175
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QuiesceTrafficServiceTest.java186
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RebootServiceTest.java153
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RequestExecutorTest.java252
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ResumeTrafficServiceTest.java162
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/UpgradeServiceTest.java686
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/VolumeServiceTest.java320
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/util/ValidationServiceTest.java89
12 files changed, 2856 insertions, 5 deletions
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
index f25df9c44..064f5679f 100644
--- 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
@@ -9,15 +9,15 @@
* 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=========================================================
*/
@@ -36,6 +36,9 @@ import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AuditInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AuditOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.CheckLockInput;
@@ -54,6 +57,9 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleoutIn
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.DetachVolumeInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.EvacuateInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.EvacuateOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.HealthCheckInput;
@@ -64,6 +70,33 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LockInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LockOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.MigrateInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QuiesceTrafficInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QuiesceTrafficOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QuiesceTrafficOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ResumeTrafficInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ResumeTrafficOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ResumeTrafficOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePreCheckInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePreCheckOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePreCheckOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeSoftwareInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeSoftwareOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeSoftwareOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePostCheckInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePostCheckOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradePostCheckOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackupInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackupOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackupOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackoutInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackoutOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.UpgradeBackoutOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebuildInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebuildOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RestartInput;
@@ -100,6 +133,7 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.StatusBui
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.onap.appc.domainmodel.lcm.ResponseContext;
import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.provider.lcm.service.*;
import org.onap.appc.provider.lcm.util.ValidationService;
import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
import org.osgi.framework.FrameworkUtil;
@@ -122,13 +156,16 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
/**
* Integration Test class for AppcProviderLcm.
*/
@RunWith(PowerMockRunner.class)
-@PrepareForTest({FrameworkUtil.class, AppcProviderLcm.class, ValidationService.class})
+@PrepareForTest({FrameworkUtil.class, AppcProviderLcm.class, QueryService.class, VolumeService.class,
+ QuiesceTrafficService.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();
@@ -1091,6 +1128,183 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
verify(appcProviderLcm, times(1)).executeRequest(any());
}
+ @Test
+ public void testQuery() throws Exception {
+ QueryInput mockInput = mock(QueryInput.class);
+ QueryOutput mockOutput = mock(QueryOutput.class);
+ QueryOutputBuilder mockQueryOutputBuilder = mock(QueryOutputBuilder.class);
+ QueryService mockQuery = mock(QueryService.class);
+
+ whenNew(QueryService.class).withNoArguments().thenReturn(mockQuery);
+ when(mockQuery.process(mockInput)).thenReturn(mockQueryOutputBuilder);
+ when(mockQueryOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<QueryOutput>> results = appcProviderLcm.query(mockInput);
+ verify(mockQuery, times(1)).process(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testReboot() throws Exception {
+ RebootInput mockInput = mock(RebootInput.class);
+ RebootOutput mockOutput = mock(RebootOutput.class);
+ RebootOutputBuilder mockRebootOutputBuilder = mock(RebootOutputBuilder.class);
+ RebootService mockReboot = mock(RebootService.class);
+
+ whenNew(RebootService.class).withNoArguments().thenReturn(mockReboot);
+ when(mockReboot.process(mockInput)).thenReturn(mockRebootOutputBuilder);
+ when(mockRebootOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<RebootOutput>> results = appcProviderLcm.reboot(mockInput);
+ verify(mockReboot, times(1)).process(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testAttachVolume() throws Exception {
+ AttachVolumeInput mockInput = mock(AttachVolumeInput.class);
+ AttachVolumeOutput mockOutput = mock(AttachVolumeOutput.class);
+ AttachVolumeOutputBuilder mockOutputBuilder = mock(AttachVolumeOutputBuilder.class);
+ VolumeService mockVolumeService = mock(VolumeService.class);
+
+ whenNew(VolumeService.class).withArguments(true).thenReturn(mockVolumeService);
+ when(mockVolumeService.attachVolume(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<AttachVolumeOutput>> results = appcProviderLcm.attachVolume(mockInput);
+ verify(mockVolumeService, times(1)).attachVolume(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testDetachVolume() throws Exception {
+ DetachVolumeInput mockInput = mock(DetachVolumeInput.class);
+ DetachVolumeOutput mockOutput = mock(DetachVolumeOutput.class);
+ DetachVolumeOutputBuilder mockOutputBuilder = mock(DetachVolumeOutputBuilder.class);
+ VolumeService mockVolumeService = mock(VolumeService.class);
+
+ whenNew(VolumeService.class).withArguments(false).thenReturn(mockVolumeService);
+ when(mockVolumeService.detachVolume(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<DetachVolumeOutput>> results = appcProviderLcm.detachVolume(mockInput);
+ verify(mockVolumeService, times(1)).detachVolume(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testQuiesceTraffic() throws Exception {
+ QuiesceTrafficInput mockInput = mock(QuiesceTrafficInput.class);
+ QuiesceTrafficOutput mockOutput = mock(QuiesceTrafficOutput.class);
+ QuiesceTrafficOutputBuilder mockOutputBuilder = mock(QuiesceTrafficOutputBuilder.class);
+ QuiesceTrafficService mockService = mock(QuiesceTrafficService.class);
+
+ whenNew(QuiesceTrafficService.class).withNoArguments().thenReturn(mockService);
+ when(mockService.process(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<QuiesceTrafficOutput>> results = appcProviderLcm.quiesceTraffic(mockInput);
+ verify(mockService, times(1)).process(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testResumeTraffic() throws Exception {
+ ResumeTrafficInput mockInput = mock(ResumeTrafficInput.class);
+ ResumeTrafficOutput mockOutput = mock(ResumeTrafficOutput.class);
+ ResumeTrafficOutputBuilder mockOutputBuilder = mock(ResumeTrafficOutputBuilder.class);
+ ResumeTrafficService mockService = mock(ResumeTrafficService.class);
+
+ whenNew(ResumeTrafficService.class).withNoArguments().thenReturn(mockService);
+ when(mockService.process(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<ResumeTrafficOutput>> results = appcProviderLcm.resumeTraffic(mockInput);
+ verify(mockService, times(1)).process(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testUpgradePreCheck() throws Exception {
+ UpgradePreCheckInput mockInput = mock(UpgradePreCheckInput.class);
+ UpgradePreCheckOutput mockOutput = mock(UpgradePreCheckOutput.class);
+ UpgradePreCheckOutputBuilder mockOutputBuilder = mock(UpgradePreCheckOutputBuilder.class);
+ UpgradeService mockService = mock(UpgradeService.class);
+
+ whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService);
+ when(mockService.upgradePreCheck(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<UpgradePreCheckOutput>> results = appcProviderLcm.upgradePreCheck(mockInput);
+ verify(mockService, times(1)).upgradePreCheck(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+
+ @Test
+ public void testUpgradePostCheck() throws Exception {
+ UpgradePostCheckInput mockInput = mock(UpgradePostCheckInput.class);
+ UpgradePostCheckOutput mockOutput = mock(UpgradePostCheckOutput.class);
+ UpgradePostCheckOutputBuilder mockOutputBuilder = mock(UpgradePostCheckOutputBuilder.class);
+ UpgradeService mockService = mock(UpgradeService.class);
+
+ whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService);
+ when(mockService.upgradePostCheck(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<UpgradePostCheckOutput>> results = appcProviderLcm.upgradePostCheck(mockInput);
+ verify(mockService, times(1)).upgradePostCheck(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testUpgradeSoftware() throws Exception {
+ UpgradeSoftwareInput mockInput = mock(UpgradeSoftwareInput.class);
+ UpgradeSoftwareOutput mockOutput = mock(UpgradeSoftwareOutput.class);
+ UpgradeSoftwareOutputBuilder mockOutputBuilder = mock(UpgradeSoftwareOutputBuilder.class);
+ UpgradeService mockService = mock(UpgradeService.class);
+
+ whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService);
+ when(mockService.upgradeSoftware(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<UpgradeSoftwareOutput>> results = appcProviderLcm.upgradeSoftware(mockInput);
+ verify(mockService, times(1)).upgradeSoftware(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testUpgradeBackup() throws Exception {
+ UpgradeBackupInput mockInput = mock(UpgradeBackupInput.class);
+ UpgradeBackupOutput mockOutput = mock(UpgradeBackupOutput.class);
+ UpgradeBackupOutputBuilder mockOutputBuilder = mock(UpgradeBackupOutputBuilder.class);
+ UpgradeService mockService = mock(UpgradeService.class);
+
+ whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService);
+ when(mockService.upgradeBackup(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<UpgradeBackupOutput>> results = appcProviderLcm.upgradeBackup(mockInput);
+ verify(mockService, times(1)).upgradeBackup(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
+ @Test
+ public void testUpgradeBackout() throws Exception {
+ UpgradeBackoutInput mockInput = mock(UpgradeBackoutInput.class);
+ UpgradeBackoutOutput mockOutput = mock(UpgradeBackoutOutput.class);
+ UpgradeBackoutOutputBuilder mockOutputBuilder = mock(UpgradeBackoutOutputBuilder.class);
+ UpgradeService mockService = mock(UpgradeService.class);
+
+ whenNew(UpgradeService.class).withAnyArguments().thenReturn(mockService);
+ when(mockService.upgradeBackout(mockInput)).thenReturn(mockOutputBuilder);
+ when(mockOutputBuilder.build()).thenReturn(mockOutput);
+
+ Future<RpcResult<UpgradeBackoutOutput>> results = appcProviderLcm.upgradeBackout(mockInput);
+ verify(mockService, times(1)).upgradeBackout(mockInput);
+ Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
+ }
+
@After
public void tearDown() throws Exception {
if (appcProviderLcm != null) {
@@ -1098,6 +1312,7 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
}
}
+
private ActionIdentifiers newActionIdentifier(String vnfId, String vnfcId, String vserverId) {
ActionIdentifiersBuilder actionIdentifiersBuilder = new ActionIdentifiersBuilder();
actionIdentifiersBuilder.setVnfId(vnfId);
@@ -1115,4 +1330,4 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
"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/lcm/service/AbstractBaseServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseServiceTest.java
new file mode 100644
index 000000000..012b840bb
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseServiceTest.java
@@ -0,0 +1,212 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+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.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.executor.objects.Params;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.reflect.Whitebox;
+
+import java.util.EnumSet;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+
+public class AbstractBaseServiceTest {
+ private Action expectedAction = Action.Query;
+ private String rpcName = expectedAction.name().toLowerCase();
+
+ private CommonHeader commonHeader = mock(CommonHeader.class);
+ private ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+ private testAbc testAbstractBaseService;
+
+ class testAbc extends AbstractBaseService {
+ public testAbc() {
+ super(AbstractBaseServiceTest.this.expectedAction);
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ testAbstractBaseService = spy(new testAbc());
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) Whitebox.getInternalState(testAbstractBaseService, "expectedAction"));
+ Assert.assertEquals("Should have action-status RPC name", rpcName,
+ (Whitebox.getInternalState(testAbstractBaseService, "rpcName")).toString());
+ }
+
+ @Test
+ public void testValidateInput() throws Exception {
+ // test commonHeader error
+ Status status = testAbstractBaseService.validateInput(commonHeader, Action.Query, null);
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(commonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(commonHeader).getApiVer();
+ Mockito.doReturn("originator Id").when(commonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(commonHeader).getRequestId();
+
+ // test invalid action
+ status = testAbstractBaseService.validateInput(commonHeader, Action.AttachVolume, null);
+ Assert.assertEquals("Should return invalid parameter for action",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test null actionIdentifier
+ status = testAbstractBaseService.validateInput(commonHeader, Action.Query, null);
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test validation passed
+ status = testAbstractBaseService.validateInput(commonHeader, Action.Query, mockAI);
+ Assert.assertTrue("Should have null status", status == null);
+ }
+
+ @Test
+ public void testValidateVnfId() throws Exception {
+ // Skip test input validation, as it is all done in testValidateInput
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(commonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(commonHeader).getApiVer();
+ Mockito.doReturn("originator Id").when(commonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(commonHeader).getRequestId();
+
+ // test null VNF ID
+ Status status = testAbstractBaseService.validateVnfId(commonHeader, Action.Query, mockAI);
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty VNF_ID
+ Mockito.doReturn("").when(mockAI).getVnfId();
+ status = testAbstractBaseService.validateVnfId(commonHeader, Action.Query, mockAI);
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test calling validateExcludeActId
+ Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+ status = testAbstractBaseService.validateVnfId(commonHeader, Action.Query, mockAI);
+ Assert.assertTrue("Should have null status", status == null);
+ }
+
+ @Test
+ public void testValidateVserverId() throws Exception {
+ // Skip test input validation, as it is all done in testValidateInput
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(commonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(commonHeader).getApiVer();
+ Mockito.doReturn("originator Id").when(commonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(commonHeader).getRequestId();
+
+ // test null VNF ID
+ Status status = testAbstractBaseService.validateVserverId(commonHeader, Action.Query, mockAI);
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty VNF_ID
+ Mockito.doReturn("").when(mockAI).getVserverId();
+ status = testAbstractBaseService.validateVserverId(commonHeader, Action.Query, mockAI);
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test calling validateExcludeActId
+ Mockito.doReturn("vserverId").when(mockAI).getVserverId();
+ status = testAbstractBaseService.validateVserverId(commonHeader, Action.Query, mockAI);
+ Assert.assertTrue("Should have null status", status == null);
+ }
+
+ @Test
+ public void testValidateExcludedActIds() throws Exception {
+ EnumSet<AbstractBaseService.ACTID_KEYS> exclutionKeys = EnumSet.of(AbstractBaseService.ACTID_KEYS.VNF_ID);
+ Status status = testAbstractBaseService.validateExcludedActIds(mockAI, exclutionKeys);
+ Assert.assertTrue("Should have not error", status == null);
+
+ Integer expectedErrorCode = Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode());
+ Mockito.doReturn("vnfc name").when(mockAI).getVnfcName();
+ status = testAbstractBaseService.validateExcludedActIds(mockAI, exclutionKeys);
+ Assert.assertEquals("Should have error for vnfc name", expectedErrorCode, status.getCode());
+
+ Mockito.doReturn(null).when(mockAI).getVnfcName();
+ Mockito.doReturn("vserver Id").when(mockAI).getVserverId();
+ status = testAbstractBaseService.validateExcludedActIds(mockAI, exclutionKeys);
+ Assert.assertEquals("Should have error for vserver Id", expectedErrorCode, status.getCode());
+
+ Mockito.doReturn(null).when(mockAI).getVserverId();
+ Mockito.doReturn("vf module Id").when(mockAI).getVfModuleId();
+ status = testAbstractBaseService.validateExcludedActIds(mockAI, exclutionKeys);
+ Assert.assertEquals("Should have error for vf module Id", expectedErrorCode, status.getCode());
+
+ Mockito.doReturn(null).when(mockAI).getServiceInstanceId();
+ Mockito.doReturn("service instance Id").when(mockAI).getServiceInstanceId();
+ status = testAbstractBaseService.validateExcludedActIds(mockAI, exclutionKeys);
+ Assert.assertEquals("Should have error for service instance Id", expectedErrorCode, status.getCode());
+
+ Mockito.doReturn("vnfc name").when(mockAI).getVnfcName();
+ Mockito.doReturn("vserver Id").when(mockAI).getVserverId();
+ Mockito.doReturn("vf module Id").when(mockAI).getVfModuleId();
+ Mockito.doReturn("vnf Id").when(mockAI).getVnfId();
+ status = testAbstractBaseService.validateExcludedActIds(mockAI, exclutionKeys);
+ Assert.assertEquals("Should have error code", expectedErrorCode, status.getCode());
+ Assert.assertEquals("Should have error message",
+ LCMCommandStatus.INVALID_INPUT_PARAMETER.getFormattedMessage(getMsgParams(exclutionKeys)),
+ status.getMessage());
+ }
+
+ @Test
+ public void testExecuteAction() throws Exception {
+ RequestHandlerOutput output = testAbstractBaseService.executeAction(null);
+ Assert.assertTrue("Should return null RequestHandlerOutput", output == null);
+ Status status = Whitebox.getInternalState(testAbstractBaseService, "status");
+ Assert.assertEquals("Should have error code",
+ Integer.valueOf(LCMCommandStatus.UNEXPECTED_ERROR.getResponseCode()), status.getCode());
+ }
+
+ private Params getMsgParams(EnumSet<AbstractBaseService.ACTID_KEYS> exclutionKeys) {
+ StringBuilder msgBuilder = new StringBuilder();
+ for (QueryService.ACTID_KEYS aKey : AbstractBaseService.ACTID_KEYS.values()) {
+ if (exclutionKeys.contains(aKey)) {
+ continue;
+ }
+ msgBuilder.append(aKey.getKeyName()).append(testAbstractBaseService.DELIMITER_COMMA);
+ }
+ String msg = msgBuilder.toString();
+ return new Params().addParam("errorMsg", msg.substring(0, msg.length() -1));
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseUtilsTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseUtilsTest.java
new file mode 100644
index 000000000..c5322886c
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/AbstractBaseUtilsTest.java
@@ -0,0 +1,204 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.executor.objects.Params;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+
+import java.text.ParseException;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+public class AbstractBaseUtilsTest {
+
+ private AbstractBaseUtilsTest.testAbc testAbstractBaseUtils;
+
+ class testAbc extends AbstractBaseUtils {
+ // no content needed
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ testAbstractBaseUtils = spy(new AbstractBaseUtilsTest.testAbc());
+ }
+
+ private void validateStatusResult(Params params, LCMCommandStatus lcmCommandStatus, Status status) {
+ Assert.assertEquals(String.format("Should return proper code of %s", lcmCommandStatus.toString()),
+ Integer.valueOf(lcmCommandStatus.getResponseCode()), status.getCode());
+ Assert.assertEquals(String.format("Should return proper message of $s", lcmCommandStatus.toString()),
+ lcmCommandStatus.getFormattedMessage(params), status.getMessage());
+ }
+
+ @Test
+ public void testBuildStatusWithoutParams() throws Exception {
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.ACCEPTED;
+ Status status = testAbstractBaseUtils.buildStatusWithoutParams(lcmCommandStatus);
+ validateStatusResult(null, lcmCommandStatus, status);
+ }
+
+ @Test
+ public void testBuildStatusForErrorMsg() throws Exception {
+ String key = "errorMsg";
+ String msg = "testing";
+ Params params = new Params().addParam(key, msg);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.INVALID_INPUT_PARAMETER;
+ Status status = testAbstractBaseUtils.buildStatusForErrorMsg(lcmCommandStatus, msg);
+ verify(testAbstractBaseUtils, times(1)).buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+ }
+
+
+ @Test
+ public void testBuildStatusForVnfId() throws Exception {
+ String key = "vnfId";
+ String msg = "testing";
+ Params params = new Params().addParam(key, msg);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.VNF_NOT_FOUND;
+ Status status = testAbstractBaseUtils.buildStatusForVnfId(lcmCommandStatus, msg);
+ verify(testAbstractBaseUtils, times(1)).buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+ }
+
+ @Test
+ public void testBuildStatusForParamName() throws Exception {
+ String key = "paramName";
+ String msg = "testing";
+ Params params = new Params().addParam(key, msg);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.MISSING_MANDATORY_PARAMETER;
+ Status status = testAbstractBaseUtils.buildStatusForParamName(lcmCommandStatus, msg);
+ verify(testAbstractBaseUtils, times(1)).buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+ }
+
+ @Test
+ public void testBuildStatusForId() throws Exception {
+ String key = "id";
+ String msg = "testing";
+ Params params = new Params().addParam(key, msg);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.VSERVER_NOT_FOUND;
+ Status status = testAbstractBaseUtils.buildStatusForId(lcmCommandStatus, msg);
+ verify(testAbstractBaseUtils, times(1)).buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+ }
+
+ @Test
+ public void testBuildStatus() throws Exception {
+ String key = "errorMsg";
+ String msg = "testing";
+ Params params = new Params().addParam(key, msg);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.UNEXPECTED_ERROR;
+ Status status = testAbstractBaseUtils.buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+
+ key = "vnfId";
+ params = new Params().addParam(key, msg);
+ lcmCommandStatus = LCMCommandStatus.VNF_NOT_FOUND;
+ status = testAbstractBaseUtils.buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+
+ key = "paramName";
+ params = new Params().addParam(key, msg);
+ lcmCommandStatus = LCMCommandStatus.MISSING_MANDATORY_PARAMETER;
+ status = testAbstractBaseUtils.buildStatus(lcmCommandStatus, msg, key);
+ validateStatusResult(params, lcmCommandStatus, status);
+ }
+
+ @Test
+ public void testBuildStatusWithParseException() throws Exception {
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.REQUEST_PARSING_FAILED;
+ String key = "errorMsg";
+ String exceptionMsg = null;
+
+ ParseException parseException = new ParseException(exceptionMsg, 0);
+ Params params = new Params().addParam(key, parseException.toString());
+ Status status = testAbstractBaseUtils.buildStatusWithParseException(parseException);
+ validateStatusResult(params, lcmCommandStatus, status);
+
+ exceptionMsg = "testing message";
+ parseException = new ParseException(exceptionMsg, 0);
+ params = new Params().addParam(key, exceptionMsg);
+ status = testAbstractBaseUtils.buildStatusWithParseException(parseException);
+ validateStatusResult(params, lcmCommandStatus, status);
+ }
+
+ @Test
+ public void testBuildStatusWithDispatcherOutput() throws Exception {
+ RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+
+ ResponseContext mockContext = mock(ResponseContext.class);
+ Mockito.doReturn(mockContext).when(mockOutput).getResponseContext();
+
+ org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+ Mockito.doReturn(mockStatus).when(mockContext).getStatus();
+
+ Integer resultCode = new Integer(401);
+ String resultMsg = "testing result message";
+ Mockito.doReturn(resultCode).when(mockStatus).getCode();
+ Mockito.doReturn(resultMsg).when(mockStatus).getMessage();
+
+ Status status = testAbstractBaseUtils.buildStatusWithDispatcherOutput(mockOutput);
+ Assert.assertEquals("Should return result code", resultCode, status.getCode());
+ Assert.assertEquals("Should return result message", resultMsg, status.getMessage());
+ }
+
+ @Test
+ public void testGetRpcName() throws Exception {
+ Assert.assertEquals("Should return action-status",
+ "action-status", testAbstractBaseUtils.getRpcName(Action.ActionStatus));
+ Assert.assertEquals("Should return query",
+ "query", testAbstractBaseUtils.getRpcName(Action.Query));
+ Assert.assertEquals("Should return reboot",
+ "reboot", testAbstractBaseUtils.getRpcName(Action.Reboot));
+ Assert.assertEquals("Should return attach-volume",
+ "attach-volume", testAbstractBaseUtils.getRpcName(Action.AttachVolume));
+ Assert.assertEquals("Should return detach-volume",
+ "detach-volume", testAbstractBaseUtils.getRpcName(Action.DetachVolume));
+ Assert.assertEquals("Should return quiesce-traffic",
+ "quiesce-traffic", testAbstractBaseUtils.getRpcName(Action.QuiesceTraffic));
+ Assert.assertEquals("Should return resume-traffic",
+ "resume-traffic", testAbstractBaseUtils.getRpcName(Action.ResumeTraffic));
+ Assert.assertEquals("Should return upgrade-pre-check",
+ "upgrade-pre-check", testAbstractBaseUtils.getRpcName(Action.UpgradePreCheck));
+ Assert.assertEquals("Should return upgrade-post-check",
+ "upgrade-post-check", testAbstractBaseUtils.getRpcName(Action.UpgradePostCheck));
+ Assert.assertEquals("Should return upgrade-software",
+ "upgrade-software", testAbstractBaseUtils.getRpcName(Action.UpgradeSoftware));
+ Assert.assertEquals("Should return upgrade-backup",
+ "upgrade-backup", testAbstractBaseUtils.getRpcName(Action.UpgradeBackup));
+ Assert.assertEquals("Should return upgrade-backout",
+ "upgrade-backout", testAbstractBaseUtils.getRpcName(Action.UpgradeBackout));
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ActionStatusServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ActionStatusServiceTest.java
new file mode 100644
index 000000000..66fffeac7
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ActionStatusServiceTest.java
@@ -0,0 +1,197 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ActionStatusInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ActionStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+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.common.header.CommonHeader;
+import org.onap.appc.domainmodel.lcm.ActionLevel;
+import org.onap.appc.domainmodel.lcm.RequestContext;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.domainmodel.lcm.Status;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.provider.lcm.util.RequestInputBuilder;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+import java.text.ParseException;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ActionStatusService.class, RequestExecutor.class, RequestInputBuilder.class,})
+public class ActionStatusServiceTest {
+ private RequestHandlerInput mockRequestHandlerInput = mock(RequestHandlerInput.class);
+ private RequestContext mockRequestContext = mock(RequestContext.class);
+ private RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+ private ResponseContext mockResponseContext = mock(ResponseContext.class);
+
+ private ActionStatusService actionStatusService;
+
+ @Before
+ public void setUp() throws Exception {
+ Mockito.doReturn(mockRequestContext).when(mockRequestHandlerInput).getRequestContext();
+ actionStatusService = spy(new ActionStatusService());
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ Assert.assertEquals("Should have proper ACTION", Action.ActionStatus,
+ (Action) Whitebox.getInternalState(actionStatusService, "expectedAction"));
+ Assert.assertEquals("Should have action-status RPC name", "action-status",
+ (Whitebox.getInternalState(actionStatusService, "rpcName")).toString());
+ }
+
+ @Test
+ public void testQueryStatus() throws Exception {
+ // =========== test input validation ============
+ CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ ActionStatusInput mockInput = mock(ActionStatusInput.class);
+
+ Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader();
+ // test commonHeader error
+ ActionStatusOutputBuilder output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+ Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("originator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ // test invalid action
+ Mockito.doReturn(Action.Query).when(mockInput).getAction();
+ output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("Should return invalid parameter for action",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ // test null actionIdentifier
+ Mockito.doReturn(Action.ActionStatus).when(mockInput).getAction();
+ output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ // test missing VNF ID
+ ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+ Mockito.doReturn(mockAI).when(mockInput).getActionIdentifiers();
+ output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ // test invalid VNF ID
+ Mockito.doReturn("").when(mockAI).getVnfId();
+ output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("Should return invalid parameter for action",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ // test null payload
+ Mockito.doReturn("test VNF ID").when(mockAI).getVnfId();
+ output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ // test payload with empty string
+ Payload mockPayload = mock(Payload.class);
+ Mockito.doReturn(mockPayload).when(mockInput).getPayload();
+ output = actionStatusService.queryStatus(mockInput);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()),
+ output.getStatus().getCode());
+
+ // test validation passed
+ Mockito.doReturn("testing payload").when(mockPayload).getValue();
+
+ // =========== test success ============
+ RequestExecutor mockExecutor = mock(RequestExecutor.class);
+ whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+ Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+ Mockito.doReturn(mockPayload).when(mockExecutor).getPayload(mockOutput);
+
+ Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+
+ Integer statusCode = 400;
+ Status mockStatus = mock(Status.class);
+ Mockito.doReturn(statusCode).when(mockStatus).getCode();
+ Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+
+ output = actionStatusService.queryStatus(mockInput);
+ Mockito.verify(actionStatusService, times(1)).buildStatusWithDispatcherOutput(mockOutput);
+ Mockito.verify(mockExecutor, times(1)).getPayload(mockOutput);
+ Assert.assertTrue("Should have payload", output.getPayload() != null);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("Should return proper code", statusCode, output.getStatus().getCode());
+
+ // =========== test parserException ============
+ RequestInputBuilder mockInputBuilder = mock(RequestInputBuilder.class);
+ whenNew(RequestInputBuilder.class).withNoArguments().thenReturn(mockInputBuilder);
+ Mockito.doReturn(mockInputBuilder).when(mockInputBuilder).requestContext();
+ ParseException parserException = new ParseException("testing exception", 0);
+ Mockito.doThrow(parserException).when(mockInputBuilder).commonHeader(mockCommonHeader);
+
+ output = actionStatusService.queryStatus(mockInput);
+ Mockito.verify(actionStatusService, times(1)).buildStatusWithParseException(parserException);
+ Assert.assertEquals("Should have commonHeader", mockCommonHeader, output.getCommonHeader());
+ Assert.assertEquals("Should return request failed",
+ Integer.valueOf(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()),
+ output.getStatus().getCode());
+ }
+
+ @Test
+ public void testUpdateToMgmtActionLevel() throws Exception {
+ actionStatusService.updateToMgmtActionLevel(mockRequestHandlerInput);
+ Mockito.verify(mockRequestContext, times(1)).setActionLevel(ActionLevel.MGMT);
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QueryServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QueryServiceTest.java
new file mode 100644
index 000000000..be3370fd9
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QueryServiceTest.java
@@ -0,0 +1,175 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutputBuilder;
+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.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.query.output.QueryResults;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({QueryService.class, RequestExecutor.class})
+public class QueryServiceTest {
+ private final Action myAction = Action.Query;
+
+ private QueryInput mockInput = mock(QueryInput.class);
+ private CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ private ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+
+ private QueryService queryService;
+
+ @Before
+ public void setUp() throws Exception {
+ queryService = spy(new QueryService());
+
+ Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader();
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ Assert.assertEquals("Should have proper ACTION", myAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(queryService, "expectedAction"));
+ Assert.assertEquals("Should have query RPC name", myAction.name().toLowerCase(),
+ (org.powermock.reflect.Whitebox.getInternalState(queryService, "rpcName")).toString());
+ }
+
+ @Test
+ public void testProcess() throws Exception {
+ // test error occurs in validation
+ QueryOutputBuilder queryOutputBuilder = queryService.process(mockInput);
+ Mockito.verify(queryService, times(0)).proceedAction(mockInput);
+ Assert.assertTrue("Should have commonHeader",queryOutputBuilder.getCommonHeader() != null);
+ Assert.assertTrue("Should not have queryResults",queryOutputBuilder.getQueryResults() == null);
+ Assert.assertEquals("should return missing parameter status",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+ queryOutputBuilder.getStatus().getCode());
+
+ // to make validation pass
+ ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+ Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ Mockito.doReturn(myAction).when(mockInput).getAction();
+ Mockito.doReturn(mockAI).when(mockInput).getActionIdentifiers();
+ Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+
+ // test processAction return with error
+ queryOutputBuilder = queryService.process(mockInput);
+ Mockito.verify(queryService, times(1)).proceedAction(mockInput);
+ Assert.assertTrue("Should have commonHeader",queryOutputBuilder.getCommonHeader() != null);
+ Assert.assertTrue("Should not have queryResults",queryOutputBuilder.getQueryResults() == null);
+ Assert.assertEquals("should return rejected status",
+ Integer.valueOf(LCMCommandStatus.REJECTED.getResponseCode()),
+ queryOutputBuilder.getStatus().getCode());
+
+ // test processAction return without error
+ RequestExecutor mockExecutor = mock(RequestExecutor.class);
+ whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+
+ RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+ Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+
+ ResponseContext mockResponseContext = mock(ResponseContext.class);
+ Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+
+ List<QueryResults> results = new ArrayList<>();
+ QueryResults mockResult = mock(QueryResults.class);
+ results.add(mockResult);
+ Mockito.doReturn(results).when(mockResponseContext).getPayloadObject();
+
+ org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+ Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+ Mockito.doReturn(successCode).when(mockStatus).getCode();
+ Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+
+ queryOutputBuilder = queryService.process(mockInput);
+ Assert.assertTrue("Should have commonHeader",queryOutputBuilder.getCommonHeader() != null);
+ Assert.assertEquals("Should have queryResults", results, queryOutputBuilder.getQueryResults());
+ Assert.assertEquals("should return success status", successCode, queryOutputBuilder.getStatus().getCode());
+ }
+
+ @Test
+ public void testValidate() throws Exception {
+ // test commonHeader error
+ queryService.validate(mockInput);
+ Status status = (Status) Whitebox.getInternalState(queryService, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+ Mockito.verify(queryService, times(0)).buildStatusForParamName(any(), any());
+ Mockito.verify(queryService, times(0)).buildStatusForErrorMsg(any(), any());
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ // test empty ActionIdentifier
+ Mockito.doReturn(mockAI).when(mockInput).getActionIdentifiers();
+ Mockito.doReturn(myAction).when(mockInput).getAction();
+ queryService.validate(mockInput);
+ status = (Status) Whitebox.getInternalState(queryService, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty VNF_ID
+ Mockito.doReturn("").when(mockAI).getVnfId();
+ queryService.validate(mockInput);
+ status = (Status) Whitebox.getInternalState(queryService, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test calling validateExcludeActId
+ Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+ queryService.validate(mockInput);
+ Mockito.verify(queryService, times(1)).validateExcludedActIds(any(), any());
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QuiesceTrafficServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QuiesceTrafficServiceTest.java
new file mode 100644
index 000000000..b6dc15ce3
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/QuiesceTrafficServiceTest.java
@@ -0,0 +1,186 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.*;
+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.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({QuiesceTrafficService.class, RequestExecutor.class})
+public class QuiesceTrafficServiceTest {
+ private final Action myAction = Action.QuiesceTraffic;
+ private final String PAYLOAD_STRING = "{\"A\":\"A-value\",\"B\":{\"C\":\"B.C-value\",\"D\":\"B.D-value\"}}";
+ private QuiesceTrafficInput mockInput = mock(QuiesceTrafficInput.class);
+ private CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ private ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+ private Payload mockPayload = mock(Payload.class);
+
+ private QuiesceTrafficService quiesceServiceAction;
+ @Before
+ public void setUp() throws Exception {
+ quiesceServiceAction = spy(new QuiesceTrafficService());
+ }
+
+
+ @Test
+ public void testConstructor() throws Exception {
+ Action expectedAction = Action.QuiesceTraffic;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(quiesceServiceAction, "expectedAction"));
+ Assert.assertEquals("Should have quiesce-traffic RPC name", "quiesce-traffic",
+ (org.powermock.reflect.Whitebox.getInternalState(quiesceServiceAction, "rpcName")).toString());
+ }
+
+// @Test
+// public void testProcess() throws Exception {
+// // test error occurs in validation
+// QuiesceTrafficOutputBuilder outputBuilder = quiesceServiceAction.process(mockInput);
+// Mockito.verify(quiesceServiceAction, times(0)).proceedAction(any(),any(),any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+// // to make validation pass
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(myAction).when(mockInput).getAction();
+// Mockito.doReturn(mockAI).when(mockInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test processAction return with error
+// outputBuilder = quiesceServiceAction.process(mockInput);
+// Mockito.verify(quiesceServiceAction, times(1)).proceedAction(any(),any(),any());
+// Assert.assertTrue("Should have commonHeader",outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(LCMCommandStatus.REJECTED.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // test processAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = quiesceServiceAction.process(mockInput);
+// Assert.assertTrue("Should have commonHeader",outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status", successCode, outputBuilder.getStatus().getCode());
+// }
+
+ @Test
+ public void testValidate() throws Exception {
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI,mockPayload);
+ Status status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+ Mockito.verify(quiesceServiceAction, times(0)).buildStatusForParamName(any(), any());
+ Mockito.verify(quiesceServiceAction, times(0)).buildStatusForErrorMsg(any(), any());
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ // test empty action
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI,mockPayload);
+ status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("Should return missing parameter for action",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty ActionIdentifier
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI,mockPayload);
+ status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test Invalid VNF_ID
+ Mockito.doReturn("").when(mockAI).getVnfId();
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI,mockPayload);
+ status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test null payload
+ Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI, null);
+ Mockito.verify(quiesceServiceAction, times(1)).validateExcludedActIds(any(), any());
+ status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty payload
+
+ Mockito.doReturn("").when(mockPayload).getValue();
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test space payload
+ Mockito.doReturn(" ").when(mockPayload).getValue();
+ quiesceServiceAction.validate(mockCommonHeader, Action.QuiesceTraffic, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(quiesceServiceAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RebootServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RebootServiceTest.java
new file mode 100644
index 000000000..fffebf944
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RebootServiceTest.java
@@ -0,0 +1,153 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+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.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.RebootOutputBuilder;
+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.status.Status;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+import static org.mockito.Mockito.times;
+
+@RunWith(PowerMockRunner.class)
+public class RebootServiceTest {
+ private final String vserverId = "vserverId";
+
+ @Mock
+ private RebootService rebootService;
+ @Mock
+ private RebootInput rebootInput;
+ @Mock
+ private ActionIdentifiers actionIdentifiers;
+ @Mock
+ private org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader commonHeader;
+
+ private Payload payload;
+
+ @Before
+ public void setUp() throws Exception {
+ rebootService = new RebootService();
+ payload = new Payload("{\"reboot-type\":\"hard\"}");
+
+ PowerMockito.doReturn(actionIdentifiers).when(rebootInput).getActionIdentifiers();
+ PowerMockito.doReturn(payload).when(rebootInput).getPayload();
+ PowerMockito.doReturn(commonHeader).when(rebootInput).getCommonHeader();
+ PowerMockito.doReturn(new ZULU("2017-09-05T16:55:55.807Z")).when(commonHeader).getTimestamp();
+ PowerMockito.doReturn("2.00").when(commonHeader).getApiVer();
+ PowerMockito.doReturn("demo-lcm-stop-id#1").when(commonHeader).getRequestId();
+ PowerMockito.doReturn("demo-lcm-stop-id#2").when(commonHeader).getSubRequestId();
+ PowerMockito.doReturn("originator-id").when(commonHeader).getOriginatorId();
+ PowerMockito.doReturn(Action.Reboot).when(rebootInput).getAction();
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ Action expectedAction = Action.Reboot;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(rebootService, "expectedAction"));
+ Assert.assertEquals("Should have reboot RPC name", expectedAction.name().toLowerCase(),
+ (org.powermock.reflect.Whitebox.getInternalState(rebootService, "rpcName")).toString());
+ }
+
+ @Test
+ public void testProcessAccepted() throws Exception {
+ PowerMockito.doReturn(vserverId).when(actionIdentifiers).getVserverId();
+ RebootOutputBuilder process = rebootService.process(rebootInput);
+ PowerMockito.verifyPrivate(rebootService, times(1)).invoke("validate", rebootInput);
+ Assert.assertNotNull(process.getCommonHeader());
+ Assert.assertNotNull(process.getStatus());
+ }
+
+ @Test
+ public void testProcessError() throws Exception {
+ RebootOutputBuilder process = rebootService.process(rebootInput);
+ PowerMockito.verifyPrivate(rebootService, times(1))
+ .invoke("validate", rebootInput);
+ Assert.assertNotNull(process.getStatus());
+ }
+
+ @Test
+ public void testValidateSuccess() throws Exception {
+ PowerMockito.doReturn(vserverId).when(actionIdentifiers).getVserverId();
+ Status validate = Whitebox.invokeMethod(rebootService, "validate", rebootInput);
+ Assert.assertNull(validate);
+ }
+
+ @Test
+ public void testValidateMissingVserverId() throws Exception {
+ PowerMockito.doReturn("").when(actionIdentifiers).getVserverId();
+ Whitebox.invokeMethod(rebootService, "validate", rebootInput);
+ Status status = Whitebox.getInternalState(rebootService, "status");
+ Assert.assertNotNull(status);
+ }
+
+ @Test
+ public void testValidateWrongAction() throws Exception {
+ PowerMockito.doReturn(Action.Audit).when(rebootInput).getAction();
+ PowerMockito.doReturn("").when(actionIdentifiers).getVserverId();
+ Whitebox.invokeMethod(rebootService, "validate", rebootInput);
+ Status status = Whitebox.getInternalState(rebootService, "status");
+ Assert.assertNotNull(status);
+ }
+
+ @Test
+ public void testValidateMissingActionIdentifier() throws Exception {
+ PowerMockito.doReturn(actionIdentifiers).when(rebootInput).getActionIdentifiers();
+ Whitebox.invokeMethod(rebootService, "validate", rebootInput);
+ Status status = Whitebox.getInternalState(rebootService, "status");
+ Assert.assertNotNull(status);
+ }
+
+ @Test
+ public void testValidateMissingRebootType() throws Exception {
+ Payload payload = new Payload("{}");
+ PowerMockito.doReturn(payload).when(rebootInput).getPayload();
+ PowerMockito.doReturn(vserverId).when(actionIdentifiers).getVserverId();
+ Whitebox.invokeMethod(rebootService, "validate", rebootInput);
+ Status status = Whitebox.getInternalState(rebootService, "status");
+ Assert.assertNotNull(status);
+ }
+
+ @Test
+ public void testValidateWrongRebootType() throws Exception {
+ Payload payload = new Payload("{\"reboot-type\":\"1\"}");
+ PowerMockito.doReturn(payload).when(rebootInput).getPayload();
+ PowerMockito.doReturn(vserverId).when(actionIdentifiers).getVserverId();
+ Whitebox.invokeMethod(rebootService, "validate", rebootInput);
+ Status status = Whitebox.getInternalState(rebootService, "status");
+ Assert.assertNotNull(status);
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RequestExecutorTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RequestExecutorTest.java
new file mode 100644
index 000000000..a2001809e
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/RequestExecutorTest.java
@@ -0,0 +1,252 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.onap.appc.domainmodel.lcm.ActionLevel;
+import org.onap.appc.domainmodel.lcm.CommonHeader;
+import org.onap.appc.domainmodel.lcm.RequestContext;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.domainmodel.lcm.Status;
+import org.onap.appc.domainmodel.lcm.VNFOperation;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.executor.objects.Params;
+import org.onap.appc.i18n.Msg;
+import org.onap.appc.requesthandler.RequestHandler;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+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 java.util.Collection;
+import java.util.Iterator;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({FrameworkUtil.class})
+public class RequestExecutorTest {
+ private final VNFOperation vnfOperation = VNFOperation.ActionStatus;
+ private final ActionLevel actionLevel = ActionLevel.MGMT;
+
+ private Bundle mockBundle = mock(Bundle.class);
+ private BundleContext mockBundleContext = mock(BundleContext.class);
+
+ private RequestHandlerInput mockInput = mock(RequestHandlerInput.class);
+ private RequestContext mockRequestContext = mock(RequestContext.class);
+ private CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ private RequestHandler mockHandler = mock(RequestHandler.class);
+
+ private RequestExecutor requestExecutor;
+
+ @Before
+ public void setUp() throws Exception {
+ mockStatic(FrameworkUtil.class);
+ PowerMockito.when(FrameworkUtil.getBundle(any())).thenReturn(mockBundle);
+
+ Mockito.doReturn(mockRequestContext).when(mockInput).getRequestContext();
+ Mockito.doReturn(mockCommonHeader).when(mockRequestContext).getCommonHeader();
+
+ requestExecutor = spy(new RequestExecutor());
+ }
+
+ @Test
+ public void testExecuteRequest() throws Exception {
+ // test RequestHandler is null
+ Mockito.doReturn(null).when(mockBundle).getBundleContext();
+ Mockito.doReturn(actionLevel).when(mockRequestContext).getActionLevel();
+ Mockito.doReturn(vnfOperation).when(mockRequestContext).getAction();
+
+ Params params = new Params().addParam("errorMsg", requestExecutor.CANNOT_PROCESS);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.REJECTED;
+ Msg msg = Msg.REQUEST_HANDLER_UNAVAILABLE;
+
+ RequestHandlerOutput output = requestExecutor.executeRequest(mockInput);
+ ResponseContext responseContext = output.getResponseContext();
+ Status status = responseContext.getStatus();
+ Assert.assertEquals("Should have rejected status code",
+ lcmCommandStatus.getResponseCode(), status.getCode());
+ Assert.assertEquals("Should have rejected CANNOT_PROCESS status message",
+ lcmCommandStatus.getFormattedMessage(params), status.getMessage());
+ Assert.assertEquals("Should have the same commonHeader",
+ mockCommonHeader, responseContext.getCommonHeader());
+ Mockito.verify(requestExecutor, times(1)).getRequestHandler(any());
+ Mockito.verify(requestExecutor, times(1))
+ .createRequestHandlerOutput(any(), any(), any(), any());
+
+ // to get RequestHandler
+ ServiceReference<RequestHandler> mockSvcRefs = mock(ServiceReference.class);
+ Iterator mockIterator = mock(Iterator.class);
+ Mockito.doReturn(mockSvcRefs).when(mockIterator).next();
+
+ Collection<ServiceReference<RequestHandler>> mockSvcRefCollection = mock(Collection.class);
+ Mockito.doReturn(1).when(mockSvcRefCollection).size();
+ Mockito.doReturn(mockIterator).when(mockSvcRefCollection).iterator();
+
+ Mockito.doReturn(mockBundleContext).when(mockBundle).getBundleContext();
+ Mockito.doReturn(mockSvcRefCollection).when(mockBundleContext)
+ .getServiceReferences(eq(RequestHandler.class), anyString());
+
+ Mockito.doReturn(mockHandler).when(mockBundleContext).getService(mockSvcRefs);
+
+ // Skip test RequestHandler.quiesce throws exception as it does not throw exception
+
+ // test normal return
+ RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+ Mockito.doReturn(mockOutput).when(mockHandler).handleRequest(mockInput);
+ output = requestExecutor.executeRequest(mockInput);
+ Assert.assertEquals("Should return mockOuput", mockOutput, output);
+ }
+
+ @Test
+ public void testGetRequestHandler() throws Exception {
+ // test null BundleContext
+ Mockito.doReturn(null).when(mockBundle).getBundleContext();
+ RequestHandler requestHandler = requestExecutor.getRequestHandler(actionLevel);
+ Assert.assertTrue("Should return null", requestHandler == null);
+
+ // test successful returning RequestHandler
+ ServiceReference<RequestHandler> mockSvcRefs = mock(ServiceReference.class);
+ Iterator mockIterator = mock(Iterator.class);
+ Mockito.doReturn(mockSvcRefs).when(mockIterator).next();
+
+ Collection<ServiceReference<RequestHandler>> mockSvcRefCollection = mock(Collection.class);
+ Mockito.doReturn(1).when(mockSvcRefCollection).size();
+ Mockito.doReturn(mockIterator).when(mockSvcRefCollection).iterator();
+
+ Mockito.doReturn(mockBundleContext).when(mockBundle).getBundleContext();
+ Mockito.doReturn(mockSvcRefCollection).when(mockBundleContext)
+ .getServiceReferences(eq(RequestHandler.class), anyString());
+
+ Mockito.doReturn(mockHandler).when(mockBundleContext).getService(mockSvcRefs);
+
+ requestHandler = requestExecutor.getRequestHandler(actionLevel);
+ Assert.assertEquals("Should return RequestHandler", mockHandler, requestHandler);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testGetRequesetHandlerWithInvalidSyntaxException() throws Exception {
+ Mockito.doReturn(mockBundleContext).when(mockBundle).getBundleContext();
+ Mockito.doThrow(new InvalidSyntaxException("testing message", "testing filter"))
+ .when(mockBundleContext).getServiceReferences(eq(RequestHandler.class), anyString());
+
+ requestExecutor.getRequestHandler(actionLevel);
+ }
+
+
+ @Test(expected = RuntimeException.class)
+ public void testGetRequesetHandlerWithCannotFoundSvc() throws Exception {
+ Collection<ServiceReference<RequestHandler>> mockSvcRefCollection = mock(Collection.class);
+ Mockito.doReturn(2).when(mockSvcRefCollection).size();
+
+ Mockito.doReturn(mockBundleContext).when(mockBundle).getBundleContext();
+ Mockito.doReturn(mockSvcRefCollection).when(mockBundleContext)
+ .getServiceReferences(eq(RequestHandler.class), anyString());
+
+ requestExecutor.getRequestHandler(actionLevel);
+ }
+
+ @Test
+ public void testCreateRequestHandlerOutput() throws Exception {
+ // test exception without message
+ Exception testException = new Exception();
+ Params params = new Params().addParam("errorMsg", testException.toString());
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.REJECTED;
+ Msg msg = Msg.REQUEST_HANDLER_UNAVAILABLE;
+
+ RequestHandlerOutput output =
+ requestExecutor.createRequestHandlerOutput(mockInput, lcmCommandStatus, msg, testException);
+ ResponseContext responseContext = output.getResponseContext();
+ Status status = responseContext.getStatus();
+ Assert.assertEquals("Should have the same status code",
+ lcmCommandStatus.getResponseCode(), status.getCode());
+ Assert.assertEquals("Should have the proper exception to String status message",
+ lcmCommandStatus.getFormattedMessage(params), status.getMessage());
+ Assert.assertEquals("Should have the same commonHeader",
+ mockCommonHeader, responseContext.getCommonHeader());
+
+ // test exception with message
+ testException = new Exception("testing exception");
+ params = new Params().addParam("errorMsg", testException.getMessage());
+ lcmCommandStatus = LCMCommandStatus.UNEXPECTED_ERROR;
+ msg = Msg.EXCEPTION_CALLING_DG;
+
+ output =
+ requestExecutor.createRequestHandlerOutput(mockInput, lcmCommandStatus, msg, testException);
+ responseContext = output.getResponseContext();
+ status = responseContext.getStatus();
+ Assert.assertEquals("Should have the same status code",
+ lcmCommandStatus.getResponseCode(), status.getCode());
+ Assert.assertEquals("Should have the proper exception to String status message",
+ lcmCommandStatus.getFormattedMessage(params), status.getMessage());
+ Assert.assertEquals("Should have the same commonHeader",
+ mockCommonHeader, responseContext.getCommonHeader());
+ }
+
+ @Test
+ public void testGetPayload() throws Exception {
+ RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+ ResponseContext mockResponseContext = mock(ResponseContext.class);
+ // test null response context
+ Mockito.doReturn(null).when(mockOutput).getResponseContext();
+ Assert.assertTrue("Should return null with null requestContext",
+ requestExecutor.getPayload(mockOutput) == null);
+
+ // test null payload
+ Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+ Mockito.doReturn(null).when(mockResponseContext).getPayload();
+ Assert.assertTrue("Should return null with null payload",
+ requestExecutor.getPayload(mockOutput) == null);
+
+ // test empty payload
+ Mockito.doReturn("").when(mockResponseContext).getPayload();
+ Assert.assertTrue("Should return null with empty payload",
+ requestExecutor.getPayload(mockOutput) == null);
+
+ // test proper payload
+ String testingPayload = "testing payload";
+ Mockito.doReturn(testingPayload).when(mockResponseContext).getPayload();
+ Payload payload = requestExecutor.getPayload(mockOutput);
+ Assert.assertEquals("Should return null with empty payload", testingPayload, payload.getValue());
+ }
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ResumeTrafficServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ResumeTrafficServiceTest.java
new file mode 100644
index 000000000..2ea7ee0d2
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ResumeTrafficServiceTest.java
@@ -0,0 +1,162 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.*;
+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.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ResumeTrafficService.class, RequestExecutor.class})
+public class ResumeTrafficServiceTest {
+ private final Action myAction = Action.ResumeTraffic;
+
+ private ResumeTrafficInput mockInput = mock(ResumeTrafficInput.class);
+ private CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ private ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+
+ private ResumeTrafficService resumeServiceAction;
+ @Before
+ public void setUp() throws Exception {
+ resumeServiceAction = spy(new ResumeTrafficService());
+ }
+
+
+ @Test
+ public void testConstructor() throws Exception {
+ Action expectedAction = Action.ResumeTraffic;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(resumeServiceAction, "expectedAction"));
+ Assert.assertEquals("Should have resume-traffic RPC name", "resume-traffic",
+ (org.powermock.reflect.Whitebox.getInternalState(resumeServiceAction, "rpcName")).toString());
+ }
+
+// @Test
+// public void testProcess() throws Exception {
+// // test error occurs in validation
+// ResumeTrafficOutputBuilder outputBuilder = resumeServiceAction.process(mockInput);
+// Mockito.verify(resumeServiceAction, times(0)).proceedAction(any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader();
+//
+// // to make validation pass
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(myAction).when(mockInput).getAction();
+// Mockito.doReturn(mockAI).when(mockInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test processAction return with error
+// outputBuilder = resumeServiceAction.process(mockInput);
+// Mockito.verify(resumeServiceAction, times(1)).proceedAction(any());
+// Assert.assertTrue("Should have commonHeader",outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(LCMCommandStatus.REJECTED.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // test processAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = resumeServiceAction.process(mockInput);
+// Assert.assertTrue("Should have commonHeader",outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status", successCode, outputBuilder.getStatus().getCode());
+// }
+
+ @Test
+ public void testValidate() throws Exception {
+ resumeServiceAction.validate(mockCommonHeader, Action.ResumeTraffic, mockAI);
+ Status status = (Status) Whitebox.getInternalState(resumeServiceAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+ Mockito.verify(resumeServiceAction, times(0)).buildStatusForParamName(any(), any());
+ Mockito.verify(resumeServiceAction, times(0)).buildStatusForErrorMsg(any(), any());
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ // test empty action
+ resumeServiceAction.validate(mockCommonHeader, Action.ResumeTraffic, mockAI);
+ status = (Status) Whitebox.getInternalState(resumeServiceAction, "status");
+ Assert.assertEquals("Should return missing parameter for action",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty ActionIdentifier
+ resumeServiceAction.validate(mockCommonHeader, Action.ResumeTraffic, mockAI);
+ status = (Status) Whitebox.getInternalState(resumeServiceAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test Invalid VNF_ID
+ Mockito.doReturn("").when(mockAI).getVnfId();
+ resumeServiceAction.validate(mockCommonHeader, Action.ResumeTraffic, mockAI);
+ status = (Status) Whitebox.getInternalState(resumeServiceAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+ }
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/UpgradeServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/UpgradeServiceTest.java
new file mode 100644
index 000000000..3247a0e94
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/UpgradeServiceTest.java
@@ -0,0 +1,686 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.*;
+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.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({UpgradeService.class, RequestExecutor.class})
+public class UpgradeServiceTest {
+ private final String PAYLOAD_STRING = "{\"A\":\"A-value\",\"B\":{\"C\":\"B.C-value\",\"D\":\"B.D-value\"}}";
+ private UpgradePreCheckInput mockUpgradePreInput = mock(UpgradePreCheckInput.class);
+ private UpgradePostCheckInput mockUpgradePostInput = mock(UpgradePostCheckInput.class);
+ private UpgradeSoftwareInput mockUpgradeSoftInput = mock(UpgradeSoftwareInput.class);
+ private UpgradeBackupInput mockUpgradeBackupInput = mock(UpgradeBackupInput.class);
+ private UpgradeBackoutInput mockUpgradeBackoutInput = mock(UpgradeBackoutInput.class);
+ private CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ private ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+ private Payload mockPayload = mock(Payload.class);
+
+ private UpgradeService upgradePreAction;
+ private UpgradeService upgradePostAction;
+ private UpgradeService upgradeSoftAction;
+ private UpgradeService upgradeBackupAction;
+ private UpgradeService upgradeBackoutAction;
+
+ @Before
+ public void setUp() throws Exception {
+ upgradePreAction = spy(new UpgradeService("upgradePre"));
+ upgradePostAction = spy(new UpgradeService("upgradePost"));
+ upgradeSoftAction = spy(new UpgradeService("upgradeSoft"));
+ upgradeBackupAction = spy(new UpgradeService("upgradeBackup"));
+ upgradeBackoutAction = spy(new UpgradeService("upgradeBackout"));
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ Action expectedAction = Action.UpgradePreCheck;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(upgradePreAction, "expectedAction"));
+ Assert.assertEquals("Should have upgrade-precheck RPC name", "upgrade-pre-check",
+ (org.powermock.reflect.Whitebox.getInternalState(upgradePreAction, "rpcName")).toString());
+
+ expectedAction = Action.UpgradePostCheck;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(upgradePostAction, "expectedAction"));
+ Assert.assertEquals("Should have upgrade-postcheck RPC name","upgrade-post-check",
+ (org.powermock.reflect.Whitebox.getInternalState(upgradePostAction, "rpcName")).toString());
+
+ expectedAction = Action.UpgradeSoftware;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(upgradeSoftAction, "expectedAction"));
+ Assert.assertEquals("Should have upgrade-software RPC name", "upgrade-software",
+ (org.powermock.reflect.Whitebox.getInternalState(upgradeSoftAction, "rpcName")).toString());
+
+ expectedAction = Action.UpgradeBackup;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(upgradeBackupAction, "expectedAction"));
+ Assert.assertEquals("Should have upgrade-backup RPC name","upgrade-backup",
+ (org.powermock.reflect.Whitebox.getInternalState(upgradeBackupAction, "rpcName")).toString());
+
+ expectedAction = Action.UpgradeBackout;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(upgradeBackoutAction, "expectedAction"));
+ Assert.assertEquals("Should have upgrade-backout RPC name","upgrade-backout",
+ (org.powermock.reflect.Whitebox.getInternalState(upgradeBackoutAction, "rpcName")).toString());
+
+ }
+
+// @Test
+// public void testUpgradePreCheck() throws Exception {
+// // test error occurs in validation
+// UpgradePreCheckOutputBuilder outputBuilder = upgradePreAction.upgradePreCheck(mockUpgradePreInput);
+// //Mockito.verify(upgradePreAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockUpgradePreInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockUpgradePreInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.UpgradePreCheck).when(mockUpgradePreInput).getAction();
+// Mockito.doReturn(mockAI).when(mockUpgradePreInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test proceedAction return with error
+// outputBuilder = upgradePreAction.upgradePreCheck(mockUpgradePreInput);
+// //Mockito.verify(upgradePreAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = upgradePreAction.upgradePreCheck(mockUpgradePreInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// new Integer(302), outputBuilder.getStatus().getCode());
+// }
+//
+// @Test
+// public void testUpgradePostCheck() throws Exception {
+// // test error occurs in validation
+// UpgradePostCheckOutputBuilder outputBuilder = upgradePostAction.upgradePostCheck(mockUpgradePostInput);
+// // Mockito.verify(upgradePostAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockUpgradePostInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockUpgradePostInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.UpgradePostCheck).when(mockUpgradePostInput).getAction();
+// Mockito.doReturn(mockAI).when(mockUpgradePostInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test proceedAction return with error
+// outputBuilder = upgradePostAction.upgradePostCheck(mockUpgradePostInput);
+// // Mockito.verify(upgradePostAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(302),
+// outputBuilder.getStatus().getCode());
+//
+// // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();;
+//
+// outputBuilder = upgradePostAction.upgradePostCheck(mockUpgradePostInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// new Integer(302), outputBuilder.getStatus().getCode());
+// }
+// @Test
+// public void testUpgradeSoftware() throws Exception {
+// // test error occurs in validation
+// UpgradeSoftwareOutputBuilder outputBuilder = upgradeSoftAction.upgradeSoftware(mockUpgradeSoftInput);
+// //Mockito.verify(upgradeSoftAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockUpgradeSoftInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockUpgradeSoftInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.UpgradeSoftware).when(mockUpgradeSoftInput).getAction();
+// Mockito.doReturn(mockAI).when(mockUpgradeSoftInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test proceedAction return with error
+// outputBuilder = upgradeSoftAction.upgradeSoftware(mockUpgradeSoftInput);
+// //Mockito.verify(upgradeSoftAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(302),
+// outputBuilder.getStatus().getCode());
+//
+// // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = upgradeSoftAction.upgradeSoftware(mockUpgradeSoftInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// new Integer(302), outputBuilder.getStatus().getCode());
+// }
+// @Test
+// public void testUpgradeBackup() throws Exception {
+// // test error occurs in validation
+// UpgradeBackupOutputBuilder outputBuilder = upgradeBackupAction.upgradeBackup(mockUpgradeBackupInput);
+// //Mockito.verify(upgradeBackupAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockUpgradeBackupInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockUpgradeBackupInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.UpgradeBackup).when(mockUpgradeBackupInput).getAction();
+// Mockito.doReturn(mockAI).when(mockUpgradeBackupInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test proceedAction return with error
+// outputBuilder = upgradeBackupAction.upgradeBackup(mockUpgradeBackupInput);
+// //Mockito.verify(upgradeBackupAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(302),
+// outputBuilder.getStatus().getCode());
+//
+// // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = upgradeBackupAction.upgradeBackup(mockUpgradeBackupInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// new Integer(302), outputBuilder.getStatus().getCode());
+// }
+//
+// @Test
+// public void testUpgradeBackout() throws Exception {
+// // test error occurs in validation
+// UpgradeBackoutOutputBuilder outputBuilder = upgradeBackoutAction.upgradeBackout(mockUpgradeBackoutInput);
+// //Mockito.verify(upgradeBackoutAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockUpgradeBackoutInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockUpgradeBackoutInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.UpgradeBackup).when(mockUpgradeBackupInput).getAction();
+// Mockito.doReturn(mockAI).when(mockUpgradeBackupInput).getActionIdentifiers();
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test proceedAction return with error
+// outputBuilder = upgradeBackoutAction.upgradeBackout(mockUpgradeBackoutInput);
+// //Mockito.verify(upgradeBackoutAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(302),
+// outputBuilder.getStatus().getCode());
+//
+// // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = upgradeBackoutAction.upgradeBackout(mockUpgradeBackoutInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// new Integer(302), outputBuilder.getStatus().getCode());
+// }
+//}
+
+// @Test
+// public void testValidateForPreCheckAction() throws Exception {
+// // test commonHeader error
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, mockPayload);
+// Status status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+// //Mockito.verify(upgradePreAction, times(0)).buildStatusForParamName(any(), any());
+// // Mockito.verify(upgradePreAction, times(0)).buildStatusForErrorMsg(any(), any());
+//
+// ZULU mockTimeStamp = mock(ZULU.class);
+// Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// // test Invalid action
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("Should return invalid parameter for action",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty ActionIdentifier
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+//
+// // test empty VSERVER_ID
+// Mockito.doReturn("").when(mockAI).getVnfId();
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test null payload
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, null);
+// //Mockito.verify(upgradePreAction, times(1)).validateExcludedActIds(any(), any());
+// status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+//
+// // test empty payload
+// Mockito.doReturn("").when(mockPayload).getValue();
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test space payload
+// Mockito.doReturn(" ").when(mockPayload).getValue();
+// upgradePreAction.validate(mockCommonHeader, Action.UpgradePreCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePreAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+// }
+//
+// @Test
+// public void testValidateForUpgradePostAction() throws Exception {
+// // test commonHeader error
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, mockPayload);
+// Status status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+// // Mockito.verify(upgradePostAction, times(0)).buildStatusForParamName(any(), any());
+// //Mockito.verify(upgradePostAction, times(0)).buildStatusForErrorMsg(any(), any());
+//
+// ZULU mockTimeStamp = mock(ZULU.class);
+// Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// // test Invalid action
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("Should return invalid parameter for action",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty ActionIdentifier
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+//
+// // test empty VSERVER_ID
+// Mockito.doReturn("").when(mockAI).getVnfId();
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test null payload
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, null);
+// //Mockito.verify(upgradePostAction, times(1)).validateExcludedActIds(any(), any());
+// status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty payload
+// Mockito.doReturn("").when(mockPayload).getValue();
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test space payload
+// Mockito.doReturn(" ").when(mockPayload).getValue();
+// upgradePostAction.validate(mockCommonHeader, Action.UpgradePostCheck, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradePostAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+// }
+// @Test
+// public void testValidateForUpgradeBackoutAction() throws Exception {
+// // test commonHeader error
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, mockPayload);
+// Status status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+// //Mockito.verify(upgradeBackoutAction, times(0)).buildStatusForParamName(any(), any());
+// // Mockito.verify(upgradeBackoutAction, times(0)).buildStatusForErrorMsg(any(), any());
+//
+// ZULU mockTimeStamp = mock(ZULU.class);
+// Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// // test Invalid action
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("Should return invalid parameter for action",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty ActionIdentifier
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty VSERVER_ID
+// Mockito.doReturn("").when(mockAI).getVnfId();
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test null payload
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, null);
+// // Mockito.verify(upgradeBackoutAction, times(1)).validateExcludedActIds(any(), any());
+// status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty payload
+// Mockito.doReturn("").when(mockPayload).getValue();
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test space payload
+// Mockito.doReturn(" ").when(mockPayload).getValue();
+// upgradeBackoutAction.validate(mockCommonHeader, Action.UpgradeBackout, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackoutAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+// }
+//
+// @Test
+// public void testValidateForUpgradeSoftwareAction() throws Exception {
+// // test commonHeader error
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, mockPayload);
+// Status status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+// //Mockito.verify(upgradeSoftAction, times(0)).buildStatusForParamName(any(), any());
+// //Mockito.verify(upgradeSoftAction, times(0)).buildStatusForErrorMsg(any(), any());
+//
+// ZULU mockTimeStamp = mock(ZULU.class);
+// Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// // test Invalid action
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("Should return invalid parameter for action",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty ActionIdentifier
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty VSERVER_ID
+// Mockito.doReturn("").when(mockAI).getVnfId();
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test null payload
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, null);
+// //Mockito.verify(upgradeSoftAction, times(1)).validateExcludedActIds(any(), any());
+// status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty payload
+// Mockito.doReturn("").when(mockPayload).getValue();
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test space payload
+// Mockito.doReturn(" ").when(mockPayload).getValue();
+// upgradeSoftAction.validate(mockCommonHeader, Action.UpgradeSoftware, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeSoftAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+// }
+//
+// @Test
+// public void testValidateForUpgradeBackupAction() throws Exception {
+// // test commonHeader error
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, mockPayload);
+// Status status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+// //Mockito.verify(upgradeBackupAction, times(0)).buildStatusForParamName(any(), any());
+// //Mockito.verify(upgradeBackupAction, times(0)).buildStatusForErrorMsg(any(), any());
+//
+// ZULU mockTimeStamp = mock(ZULU.class);
+// Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// // test Invalid action
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("Should return invalid parameter for action",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty ActionIdentifier
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty VSERVER_ID
+// Mockito.doReturn("").when(mockAI).getVnfId();
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// Mockito.doReturn("vnfId").when(mockAI).getVnfId();
+//
+// // test null payload
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, null);
+// //Mockito.verify(upgradeBackupAction, times(1)).validateExcludedActIds(any(), any());
+// status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("should return missing parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test empty payload
+// Mockito.doReturn("").when(mockPayload).getValue();
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+//
+// // test space payload
+// Mockito.doReturn(" ").when(mockPayload).getValue();
+// upgradeBackupAction.validate(mockCommonHeader, Action.UpgradeBackup, mockAI, mockPayload);
+// status = (Status) Whitebox.getInternalState(upgradeBackupAction, "status");
+// Assert.assertEquals("should return invalid parameter",
+// Integer.valueOf(302), status.getCode());
+// }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/VolumeServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/VolumeServiceTest.java
new file mode 100644
index 000000000..0140dabd9
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/VolumeServiceTest.java
@@ -0,0 +1,320 @@
+/*-
+ * ============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.lcm.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AttachVolumeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+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.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
+import org.onap.appc.domainmodel.lcm.ResponseContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({VolumeService.class, RequestExecutor.class})
+public class VolumeServiceTest {
+ private final String PAYLOAD_STRING = "{\"A\":\"A-value\",\"B\":{\"C\":\"B.C-value\",\"D\":\"B.D-value\"}}";
+ private AttachVolumeInput mockAttachInput = mock(AttachVolumeInput.class);
+ private DetachVolumeInput mockDetachInput = mock(DetachVolumeInput.class);
+ private CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ private ActionIdentifiers mockAI = mock(ActionIdentifiers.class);
+ private Payload mockPayload = mock(Payload.class);
+
+ private VolumeService volumeServiceForAttachAction;
+ private VolumeService volumeServiceForDetachAction;
+
+ @Before
+ public void setUp() throws Exception {
+ volumeServiceForAttachAction = spy(new VolumeService(true));
+ volumeServiceForDetachAction = spy(new VolumeService(false));
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ Action expectedAction = Action.AttachVolume;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(volumeServiceForAttachAction, "expectedAction"));
+ Assert.assertEquals("Should have attach-volume RPC name", "attach-volume",
+ (org.powermock.reflect.Whitebox.getInternalState(volumeServiceForAttachAction, "rpcName")).toString());
+
+ expectedAction = Action.DetachVolume;
+ Assert.assertEquals("Should have proper ACTION", expectedAction,
+ (Action) org.powermock.reflect.Whitebox.getInternalState(volumeServiceForDetachAction, "expectedAction"));
+ Assert.assertEquals("Should have detach-volume RPC name","detach-volume",
+ (org.powermock.reflect.Whitebox.getInternalState(volumeServiceForDetachAction, "rpcName")).toString());
+ }
+
+// @Test
+// public void testAttachVolume() throws Exception {
+// // test error occurs in validation
+// AttachVolumeOutputBuilder outputBuilder = volumeServiceForAttachAction.attachVolume(mockAttachInput);
+// Mockito.verify(volumeServiceForAttachAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockAttachInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockAttachInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.AttachVolume).when(mockAttachInput).getAction();
+// Mockito.doReturn(mockAI).when(mockAttachInput).getActionIdentifiers();
+// Mockito.doReturn("vserverId").when(mockAI).getVserverId();
+
+ // test proceedAction return with error
+// outputBuilder = volumeServiceForAttachAction.attachVolume(mockAttachInput);
+// Mockito.verify(volumeServiceForAttachAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(LCMCommandStatus.REJECTED.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+
+ // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();
+//
+// outputBuilder = volumeServiceForAttachAction.attachVolume(mockAttachInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// successCode, outputBuilder.getStatus().getCode());
+// }
+
+// @Test
+// public void testDetachVolumn() throws Exception {
+// // test error occurs in validation
+// DetachVolumeOutputBuilder outputBuilder = volumeServiceForDetachAction.detachVolume(mockDetachInput);
+// Mockito.verify(volumeServiceForDetachAction, times(0)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should not have commonHeader as we did not mock it",
+// outputBuilder.getCommonHeader() == null);
+// Assert.assertEquals("should return missing parameter status",
+// Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+//
+// // make validation pass
+// Mockito.doReturn(mockCommonHeader).when(mockDetachInput).getCommonHeader();
+// Mockito.doReturn(mockPayload).when(mockDetachInput).getPayload();
+// Mockito.doReturn(PAYLOAD_STRING).when(mockPayload).getValue();
+//
+// ZULU zuluTimeStamp = new ZULU("2017-06-29T21:44:00.35Z");
+// Mockito.doReturn(zuluTimeStamp).when(mockCommonHeader).getTimestamp();
+// Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+// Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+// Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+//
+// Mockito.doReturn(Action.DetachVolume).when(mockDetachInput).getAction();
+// Mockito.doReturn(mockAI).when(mockDetachInput).getActionIdentifiers();
+// Mockito.doReturn("vserverId").when(mockAI).getVserverId();
+
+ // test proceedAction return with error
+// outputBuilder = volumeServiceForDetachAction.detachVolume(mockDetachInput);
+// Mockito.verify(volumeServiceForDetachAction, times(1)).proceedAction(any(), any(), any());
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return rejected status",
+// Integer.valueOf(LCMCommandStatus.REJECTED.getResponseCode()),
+// outputBuilder.getStatus().getCode());
+
+ // test proceedAction return without error
+// RequestExecutor mockExecutor = mock(RequestExecutor.class);
+// whenNew(RequestExecutor.class).withNoArguments().thenReturn(mockExecutor);
+//
+// RequestHandlerOutput mockOutput = mock(RequestHandlerOutput.class);
+// Mockito.doReturn(mockOutput).when(mockExecutor).executeRequest(any());
+//
+// ResponseContext mockResponseContext = mock(ResponseContext.class);
+// Mockito.doReturn(mockResponseContext).when(mockOutput).getResponseContext();
+//
+// org.onap.appc.domainmodel.lcm.Status mockStatus = mock(org.onap.appc.domainmodel.lcm.Status.class);
+// Integer successCode = Integer.valueOf(LCMCommandStatus.SUCCESS.getResponseCode());
+// Mockito.doReturn(successCode).when(mockStatus).getCode();
+// Mockito.doReturn(mockStatus).when(mockResponseContext).getStatus();;
+//
+// outputBuilder = volumeServiceForDetachAction.detachVolume(mockDetachInput);
+// Assert.assertTrue("Should have commonHeader",
+// outputBuilder.getCommonHeader() != null);
+// Assert.assertEquals("should return success status",
+// successCode, outputBuilder.getStatus().getCode());
+// }
+
+ @Test
+ public void testValidateForAttachAction() throws Exception {
+ // test commonHeader error
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, mockPayload);
+ Status status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+ Mockito.verify(volumeServiceForDetachAction, times(0)).buildStatusForParamName(any(), any());
+ Mockito.verify(volumeServiceForDetachAction, times(0)).buildStatusForErrorMsg(any(), any());
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ // test Invalid action
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("Should return invalid parameter for action",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty ActionIdentifier
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty VSERVER_ID
+ Mockito.doReturn("").when(mockAI).getVserverId();
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ Mockito.doReturn("vserverId").when(mockAI).getVserverId();
+
+ // test null payload
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, null);
+ Mockito.verify(volumeServiceForAttachAction, times(1)).validateExcludedActIds(any(), any());
+ status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty payload
+ Mockito.doReturn("").when(mockPayload).getValue();
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test space payload
+ Mockito.doReturn(" ").when(mockPayload).getValue();
+ volumeServiceForAttachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForAttachAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+ }
+
+ @Test
+ public void testValidateForDetachAction() throws Exception {
+ // test commonHeader error
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, mockPayload);
+ Status status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+ Mockito.verify(volumeServiceForDetachAction, times(0)).buildStatusForParamName(any(), any());
+ Mockito.verify(volumeServiceForDetachAction, times(0)).buildStatusForErrorMsg(any(), any());
+
+ ZULU mockTimeStamp = mock(ZULU.class);
+ Mockito.doReturn(mockTimeStamp).when(mockCommonHeader).getTimestamp();
+ Mockito.doReturn("api ver").when(mockCommonHeader).getApiVer();
+ Mockito.doReturn("orignator Id").when(mockCommonHeader).getOriginatorId();
+ Mockito.doReturn("request Id").when(mockCommonHeader).getRequestId();
+
+ // test Invalid action
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.AttachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("Should return invalid parameter for action",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty ActionIdentifier
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty VSERVER_ID
+ Mockito.doReturn("").when(mockAI).getVserverId();
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ Mockito.doReturn("vserverId").when(mockAI).getVserverId();
+
+ // test null payload
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, null);
+ Mockito.verify(volumeServiceForDetachAction, times(1)).validateExcludedActIds(any(), any());
+ status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
+
+ // test empty payload
+ Mockito.doReturn("").when(mockPayload).getValue();
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+
+ // test space payload
+ Mockito.doReturn(" ").when(mockPayload).getValue();
+ volumeServiceForDetachAction.validate(mockCommonHeader, Action.DetachVolume, mockAI, mockPayload);
+ status = (Status) Whitebox.getInternalState(volumeServiceForDetachAction, "status");
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/util/ValidationServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/util/ValidationServiceTest.java
new file mode 100644
index 000000000..ed2adf3de
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/util/ValidationServiceTest.java
@@ -0,0 +1,89 @@
+/*-
+ * ============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.lcm.util;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ZULU;
+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.status.Status;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+
+import static org.mockito.Mockito.mock;
+
+public class ValidationServiceTest {
+ private final Integer expectedErrorCode = Integer.valueOf(
+ LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode());
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void getInstance() throws Exception {
+ Assert.assertEquals("Should always return the same instance",
+ ValidationService.getInstance(), ValidationService.getInstance());
+ }
+
+ @Test
+ public void validateInput() throws Exception {
+ Status status = ValidationService.getInstance().validateInput(null, null, null);
+ Assert.assertEquals("Should return error status", expectedErrorCode, status.getCode());
+ Assert.assertTrue("Should include common-header in the message",
+ status.getMessage().contains("common-header"));
+ Assert.assertTrue("Should include action in the message",
+ status.getMessage().contains("action"));
+
+ CommonHeader mockCommonHeader = mock(CommonHeader.class);
+ status = ValidationService.getInstance().validateInput(mockCommonHeader, Action.Query, "query");
+ Assert.assertEquals("Should return error status", expectedErrorCode, status.getCode());
+ Assert.assertFalse("Should not include action in the message",
+ status.getMessage().contains("action"));
+
+ Mockito.when(mockCommonHeader.getApiVer()).thenReturn("testing API version");
+ status = ValidationService.getInstance().validateInput(mockCommonHeader, Action.Query, "query");
+ Assert.assertEquals("Should return error status", expectedErrorCode, status.getCode());
+ Assert.assertFalse("Should not include api-ver in the message",
+ status.getMessage().contains("api-ver"));
+
+ Mockito.when(mockCommonHeader.getOriginatorId()).thenReturn("testing originator id");
+ status = ValidationService.getInstance().validateInput(mockCommonHeader, Action.Query, "query");
+ Assert.assertEquals("Should return error status", expectedErrorCode, status.getCode());
+ Assert.assertFalse("Should not include originator-id in the message",
+ status.getMessage().contains("originator-id"));
+
+ Mockito.when(mockCommonHeader.getRequestId()).thenReturn("testing request id");
+ status = ValidationService.getInstance().validateInput(mockCommonHeader, Action.Query, "query");
+ Assert.assertEquals("Should return error status", expectedErrorCode, status.getCode());
+ Assert.assertFalse("Should not include request-id in the message",
+ status.getMessage().contains("request-id"));
+
+ Mockito.when(mockCommonHeader.getTimestamp()).thenReturn(mock(ZULU.class));
+ status = ValidationService.getInstance().validateInput(mockCommonHeader, Action.Query, "query");
+ Assert.assertTrue("Should return success", status == null);
+ }
+}