aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorzm330 <zhangminyj@chinamobile.com>2020-03-09 13:58:06 +0800
committerZhang Min <zhangminyj@chinamobile.com>2020-03-10 05:12:00 +0000
commita66c2e4aa0742e368393317bdbad48377d82113d (patch)
tree7e21c4f76c7b43e455be0342bab96e889ad09989 /bpmn/MSOCommonBPMN/src/test/groovy/org/onap
parentadca35fd311b5c20a101c1fd6659b6f16e708e63 (diff)
Add test for scritp util
Issue-ID: SO-2368 Signed-off-by: zm330 <zhangminyj@chinamobile.com> Change-Id: I1102a6ca9ba4d22b2ab58b45111e401ac67ac2e7
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/groovy/org/onap')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy78
1 files changed, 78 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy
new file mode 100644
index 0000000000..6b63bbe56c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.db.request.beans.OperationStatus
+
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class RequestDBUtilTest extends MsoGroovyTest {
+
+ @Before
+ void init() throws IOException {
+ super.init("DoDeleteSliceServiceTest")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void prepareUpdateOperationStatus(){
+ when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080")
+ OperationStatus operationStatus = new OperationStatus()
+ operationStatus.setServiceId("testServiceId")
+ operationStatus.setOperationId("testOperationId")
+ operationStatus.setUserId("testUserId")
+ operationStatus.setOperation("testOpertation")
+ operationStatus.setResult("testResult")
+ operationStatus.setProgress("testProgress")
+ operationStatus.setOperationContent("testOperationContent")
+ operationStatus.setReason("testReason")
+
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+ requestDBUtil.prepareUpdateOperationStatus(mockExecution, operationStatus)
+
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus = captor.getAllValues()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testGetOperationStatus(){
+ when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080")
+
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+ requestDBUtil.getOperationStatus(mockExecution, "testServiceId","testOperationId")
+
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("getOperationStatus"), captor.capture())
+ String getOperationStatus = captor.getAllValues()
+ assertNotNull(getOperationStatus)
+
+ }
+}