diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn')
6 files changed, 76 insertions, 76 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index 25913eabba..1ae0dd48f7 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -93,10 +93,19 @@ <artifactId>maven-jar-plugin</artifactId> <executions> <execution> - <id>tests</id> + <id>tests-jar</id> + <goals> + <goal>test-jar</goal> + </goals> + <configuration> + <skip>false</skip> + </configuration> </execution> <execution> <id>original</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index ace6e1937d..4fb63651eb 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -102,7 +102,11 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables)); processor.startProcess(processKey, variableMap); WorkflowResponse response = waitForResponse(inputVariables); - return Response.status(202).entity(response).build(); + if (response.getMessageCode() == 500) { + return Response.status(500).entity(response).build(); + } else { + return Response.status(202).entity(response).build(); + } } catch (WorkflowProcessorException e) { WorkflowResponse response = e.getWorkflowResponse(); return Response.status(500).entity(response).build(); @@ -112,7 +116,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { } } - private WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { + protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { String requestId = getRequestId(inputVariables); long currentWaitTime = 0; long waitTime = getWaitTime(inputVariables); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutor.java deleted file mode 100644 index 56526c7f89..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutor.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.onap.so.bpmn.core.plugins; - -import org.camunda.bpm.engine.delegate.ExecutionListener; -import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; -import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; -import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; -import org.camunda.bpm.engine.impl.util.xml.Element; -import org.springframework.stereotype.Component; - -@Component -public class AsyncTaskExecutor extends AbstractBpmnParseListener { - - private void injectTaskExecutorExecutionListener(ActivityImpl activity) { - activity.addListener(ExecutionListener.EVENTNAME_END, new AsyncTaskExecutorListener()); - } - - @Override - public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { - injectTaskExecutorExecutionListener(activity); - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/BPMNProcessCompletePlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/BPMNProcessCompletePlugin.java deleted file mode 100644 index 96c6af42ed..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/BPMNProcessCompletePlugin.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.core.plugins; - -import java.util.ArrayList; -import java.util.List; -import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; -import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; -import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - - - -@Component -public class BPMNProcessCompletePlugin extends AbstractProcessEnginePlugin { - - @Autowired - private AsyncTaskExecutor asyncTaskExecutor; - - @Override - public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { - List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); - if (preParseListeners == null) { - preParseListeners = new ArrayList<>(); - processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); - } - preParseListeners.add(asyncTaskExecutor); - } - -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java new file mode 100644 index 0000000000..df9a23019a --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java @@ -0,0 +1,59 @@ +package org.onap.so.bpmn.common.workflow.service; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import static org.mockito.ArgumentMatchers.anyMap; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.core.Response; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + +@RunWith(MockitoJUnitRunner.class) +public class WorkflowAsyncResourceTest { + + @InjectMocks + @Spy + private WorkflowAsyncResource workflowAsyncResource; + + @Mock + private WorkflowProcessor processor; + + private WorkflowResponse workflowResponse; + private VariableMapImpl varMap; + + @Before + public void before() { + workflowResponse = new WorkflowResponse(); + varMap = new VariableMapImpl(); + Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> requestIdMap = new HashMap<String, Object>(); + requestIdMap.put("value", "123"); + requestIdMap.put("type", "String"); + variables.put("mso-request-id", requestIdMap); + varMap.put("variables", variables); + } + + @Test + public void startProcessInstanceByKey200Test() throws Exception { + workflowResponse.setMessageCode(200); + doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap()); + Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap); + assertEquals(202, response.getStatus()); + } + + @Test + public void startProcessInstanceByKey500Test() throws Exception { + workflowResponse.setMessageCode(500); + doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap()); + Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap); + assertEquals(500, response.getStatus()); + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index 078317885c..43fbc59b3d 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -34,7 +34,7 @@ public class DmaapClientTestImpl implements DmaapClient { private Runnable informConsumer; @Override - public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo) { + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } |