diff options
author | zm330 <zhangminyj@chinamobile.com> | 2020-03-09 13:58:06 +0800 |
---|---|---|
committer | Zhang Min <zhangminyj@chinamobile.com> | 2020-03-10 05:12:00 +0000 |
commit | a66c2e4aa0742e368393317bdbad48377d82113d (patch) | |
tree | 7e21c4f76c7b43e455be0342bab96e889ad09989 /bpmn | |
parent | adca35fd311b5c20a101c1fd6659b6f16e708e63 (diff) |
Add test for scritp util
Issue-ID: SO-2368
Signed-off-by: zm330 <zhangminyj@chinamobile.com>
Change-Id: I1102a6ca9ba4d22b2ab58b45111e401ac67ac2e7
Diffstat (limited to 'bpmn')
3 files changed, 99 insertions, 2 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index ce474fa713..b35042e3c0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -49,8 +49,8 @@ class RequestDBUtil { String operationType = operationStatus.getOperation() String result = operationStatus.getResult() String progress = operationStatus.getProgress() - String operationContent = operationStatus.getOperationContent() - String reason = operationStatus.getReason() + String operationContent = operationStatus.getOperationContent()?: "" + String reason = operationStatus.getReason()?: "" String payload = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 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) + + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy index 099fc6f8aa..8a18376819 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy @@ -1,3 +1,22 @@ +/*- + * ============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.infrastructure.scripts import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity |