summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-08-02 16:54:44 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-08-02 17:07:43 +0200
commitd41863f54c30a20a47e0c5c7d7436d4be72dfd7f (patch)
tree53dd736416859317a931c98476cf5b0ff2460969 /bpmn
parenta1e0b7b9b37c50eaf942a62d8b2487efcfd33c29 (diff)
Add junit for MSOCommonBPMN
Change-Id: I665f35bd6385ceec2d5aeff9a1d8af359bccd97a Issue-ID: SO-784 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AppCClientTest.groovy63
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy22
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy4
5 files changed, 81 insertions, 25 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy
index bb1de36eac..5cbbe0ab46 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy
@@ -20,21 +20,11 @@
package org.onap.so.bpmn.common.scripts
-import org.onap.so.bpmn.core.UrnPropertiesReader
-
-import java.util.HashMap;
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.hibernate.event.internal.AbstractLockUpgradeEventListener
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.appc.ApplicationControllerOrchestrator
-import org.onap.so.client.appc.ApplicationControllerOrchestratorException
import org.onap.appc.client.lcm.model.Action
-import org.onap.appc.client.lcm.model.Status
-import org.onap.so.bpmn.appc.payload.PayloadClient
import org.onap.so.client.appc.ApplicationControllerAction;
-import groovy.transform.TypeChecked;
-import java.util.UUID;
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -113,7 +103,7 @@ public class AppCClient extends AbstractServiceTaskProcessor{
payload = Optional.of(pay)
}
if(action.equals(Action.HealthCheck)){
- String healthCheckIndex = execution.getVariable('healthCheckIndex')
+ Integer healthCheckIndex = (Integer) execution.getVariable('healthCheckIndex')
execution.setVariable('workStep', action.toString() + healthCheckIndex)
execution.setVariable('healthCheckIndex', healthCheckIndex + 1)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy
index 9c4c73fb7d..ff5dabf99a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.common.scripts
-import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.logger.MessageEnum
@@ -170,8 +169,6 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
msoLogger.debug("Exception Occured During PreProcessRequest: " + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
-
-// msoLogger.trace("Completed CompleteMsoProcess preProcessRequest Method ");
}
public void setUpdateDBstatustoSuccessPayload (DelegateExecution execution){
@@ -303,8 +300,6 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
- // msoLogger.trace("Completed CompleteMsoProcess PostProcessRequest Method ");
-
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AppCClientTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AppCClientTest.groovy
new file mode 100644
index 0000000000..bb56787f03
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AppCClientTest.groovy
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.junit.Test
+import org.onap.appc.client.lcm.model.Action
+
+import static org.mockito.Mockito.*
+
+class AppCClientTest extends MsoGroovyTest {
+
+ @Test
+ void runAppcCommand_healtCheck_indexIncremented() {
+ DelegateExecution delegateExecutionMock = mock(DelegateExecution.class)
+ mockGettingExecutionVariables(delegateExecutionMock)
+
+ new AppCClient().runAppcCommand(delegateExecutionMock)
+
+ verifySettingExecutionVariables(delegateExecutionMock)
+ }
+
+ private mockGettingExecutionVariables(DelegateExecution delegateExecutionMock) {
+ when(delegateExecutionMock.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(delegateExecutionMock.getVariable("action")).thenReturn(Action.HealthCheck)
+ when(delegateExecutionMock.getVariable("vnfId")).thenReturn("vnfIdTest")
+ when(delegateExecutionMock.getVariable("msoRequestId")).thenReturn("msoRequestIdTest")
+ when(delegateExecutionMock.getVariable("vnfName")).thenReturn("vnfNameTest")
+ when(delegateExecutionMock.getVariable("aicIdentity")).thenReturn("aicIdentityTest")
+ when(delegateExecutionMock.getVariable("vnfHostIpAddress")).thenReturn("vnfHostIpAddressTest")
+ when(delegateExecutionMock.getVariable("vmIdList")).thenReturn("vmIdListTest")
+ when(delegateExecutionMock.getVariable("identityUrl")).thenReturn("identityUrlTest")
+ when(delegateExecutionMock.getVariable("vfModuleId")).thenReturn("vfModuleIdTest")
+ when(delegateExecutionMock.getVariable("healthCheckIndex")).thenReturn(1)
+ }
+
+ private verifySettingExecutionVariables(DelegateExecution delegateExecutionMock) {
+ verify(delegateExecutionMock).setVariable("rollbackVnfStop", false)
+ verify(delegateExecutionMock).setVariable("rollbackVnfLock", false)
+ verify(delegateExecutionMock).setVariable("rollbackQuiesceTraffic", false)
+ verify(delegateExecutionMock).setVariable("workStep", Action.HealthCheck.toString())
+ verify(delegateExecutionMock).setVariable("workStep", Action.HealthCheck.toString() + 1)
+ verify(delegateExecutionMock).setVariable("healthCheckIndex", 2)
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
index 9aa8425a50..8ac8f25eb1 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.scripts
import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.junit.Before
import org.junit.Test
@@ -140,11 +141,6 @@ class CompleteMsoProcessTest {
<sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out>
</sdncadapterworkflow:MsoCompletionResponse>"""
-/*
- private String msoCompletionResponse = """<sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
- <sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out>
-</sdncadapterworkflow:MsoCompletionResponse>"""
-*/
@Test
void testBuildDataError() {
// given
@@ -167,4 +163,20 @@ class CompleteMsoProcessTest {
assertThat capturedException.errorCode isEqualTo 500
assertThat capturedException.errorMessage isEqualTo message
}
+
+ @Test
+ void postProcessResponse_successful() {
+ DelegateExecution mockExecution = mock(DelegateExecution.class)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("mso-bpel-test")
+ new CompleteMsoProcess().postProcessResponse(mockExecution)
+
+ String expectedResponse = "<sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow=\"http://ecomp.com/mso/workflow/schema/v1\">\n" +
+ " <sdncadapterworkflow:out>BPEL mso-bpel-test completed</sdncadapterworkflow:out>\n" +
+ "</sdncadapterworkflow:MsoCompletionResponse>"
+
+ verify(mockExecution).setVariable("WorkflowResponse", expectedResponse)
+ verify(mockExecution).setVariable("CompleteMsoProcessResponse", expectedResponse)
+ verify(mockExecution).setVariable("CMSO_ResponseCode", "200")
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
index cd95a3a733..01e37f0cd7 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
@@ -22,13 +22,9 @@ package org.onap.so.bpmn.common.scripts
import static org.mockito.Mockito.*
-import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-import org.mockito.internal.debugging.MockitoDebuggerImpl
import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
import org.camunda.bpm.engine.repository.ProcessDefinition
abstract class MsoGroovyTest {