summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/groovy
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/MSOCommonBPMN/src/test/groovy
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/MSOCommonBPMN/src/test/groovy')
-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
3 files changed, 80 insertions, 9 deletions
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 {