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
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)
}
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
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){
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 ");
-
}
--- /dev/null
+/*-
+ * ============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)
+ }
+}
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
<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
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
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 {