diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn')
20 files changed, 157 insertions, 307 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index e617cfed61..5d0d05df92 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -3,7 +3,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>mso-infrastructure-bpmn</artifactId> @@ -20,6 +20,7 @@ <goal>unpack</goal> </goals> <configuration> + <skip>true</skip> <artifactItems> <artifactItem> <groupId>org.onap.so</groupId> @@ -55,6 +56,24 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <skip>true</skip> + <includes> + <include>**/IntegrationTestSuite.java</include> + </includes> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> @@ -132,12 +151,17 @@ <dependency> <groupId>org.camunda.bpm.springboot</groupId> <artifactId>camunda-bpm-spring-boot-starter</artifactId> - <version>2.3.0</version> + <version>${camunda.springboot.version}</version> + </dependency> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId> + <version>${camunda.springboot.version}</version> </dependency> <dependency> <groupId>org.camunda.bpm.springboot</groupId> <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId> - <version>2.3.0</version> + <version>${camunda.springboot.version}</version> </dependency> <dependency> <groupId>org.camunda.bpm.springboot</groupId> @@ -176,6 +200,16 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-bpmn-building-blocks</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-bpmn-infrastructure-flows</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> @@ -193,13 +227,11 @@ </dependency> <dependency> <groupId>io.micrometer</groupId> - <artifactId>micrometer-spring-legacy</artifactId> - <version>1.0.5</version> + <artifactId>micrometer-core</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> - <artifactId>micrometer-registry-prometheus</artifactId> - <version>1.0.5</version> + <artifactId>micrometer-registry-prometheus</artifactId> </dependency> <dependency> <groupId>org.onap.so</groupId> @@ -211,5 +243,23 @@ <artifactId>cxf-logging</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.camunda.bpm.extension.mockito</groupId> + <artifactId>camunda-bpm-mockito</artifactId> + <version>3.2.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.camunda.bpm.extension</groupId> + <artifactId>camunda-bpm-assert</artifactId> + <version>2.0-alpha2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>1.7.0</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java index f274850b8d..02164ccec1 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java @@ -35,7 +35,6 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; /** @@ -130,11 +129,9 @@ public class CallbackHandlerService { * @param variables variables to inject into the process * @param logMarker a marker for debug logging * @return true if a process could be found, false if not - * @throws Exception for correlation errors */ protected boolean correlate(String messageEventName, String correlationVariable, - String correlationValue, Map<String, Object> variables, String logMarker) - throws Exception { + String correlationValue, Map<String, Object> variables, String logMarker) { try{ LOGGER.debug(logMarker + " Attempting to find process waiting" + " for " + messageEventName + " with " + correlationVariable diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java index 0e9e1425a6..8ceb1c1277 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/ProcessEngineAwareService.java @@ -23,8 +23,6 @@ package org.onap.so.bpmn.common.workflow.service; import java.util.Optional; -import javax.ws.rs.ext.Provider; - import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.ProcessEngines; import org.springframework.stereotype.Service; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index ae9cec9476..96a11d21a7 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -49,8 +49,6 @@ import org.springframework.stereotype.Service; @Service public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService implements VnfAdapterNotify{ - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterNotifyServiceImpl.class); - private final String logMarker = "[VNF-NOTIFY]"; @Autowired 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 9ed36e5ba9..014b06deff 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 @@ -23,7 +23,6 @@ package org.onap.so.bpmn.common.workflow.service; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.UUID; import javax.ws.rs.Consumes; @@ -67,10 +66,7 @@ import io.swagger.annotations.ApiOperation; public class WorkflowAsyncResource extends ProcessEngineAwareService { private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); - - - protected Optional<ProcessEngineServices> pes4junit = Optional.empty(); - + long workflowPollInterval=1000; @Autowired @@ -79,12 +75,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { @Autowired private WorkflowContextHolder workflowContext; - public WorkflowProcessor getProcessor() { - return processor; - } - - - public void setProcessor(WorkflowProcessor processor) { this.processor = processor; } @@ -138,14 +128,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { throw new Exception("TimeOutOccured"); } - private WorkflowResponse buildTimeoutResponse(String requestId) { - WorkflowResponse response = new WorkflowResponse(); - response.setMessage("Fail"); - response.setResponse("Request timedout, request id:" + requestId); - response.setMessageCode(500); - return response; - } - private WorkflowResponse buildUnkownError(String requestId,String error) { WorkflowResponse response = new WorkflowResponse(); response.setMessage(error); @@ -166,46 +148,11 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { } return value; } - - // Note: the business key is used to identify the process in unit tests - protected static String getBusinessKey(Map<String, Object> inputVariables) { - return getOrCreate(inputVariables, "mso-business-key"); - } protected static String getRequestId(Map<String, Object> inputVariables) { return getOrCreate(inputVariables, "mso-request-id"); } - - - protected void recordEvents(String processKey, WorkflowResponse response, - long startTime) { - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - response.getMessage() + "for processKey: " + processKey + " with response: " + response.getResponse()); - - } - - protected static void setLogContext(String processKey, - Map<String, Object> inputVariables) { - MsoLogger.setServiceName("MSO." + processKey); - if (inputVariables != null) { - MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"serviceInstanceId")); - } - } - - protected static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { - if (inputVariables == null) { - return ""; - } - - return Objects.toString(inputVariables.get(key), "N/A"); - } - protected boolean isProcessEnded(String processInstanceId) { ProcessEngineServices pes = getProcessEngineServices(); return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null; @@ -224,25 +171,5 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { } return inputVariables; } - - - protected long getWaitTime(Map<String, Object> inputVariables) - { - - String timeout = Objects.toString(inputVariables.get("mso-service-request-timeout"), null); - - if (timeout != null) { - try { - return Long.parseLong(timeout)*1000; - } catch (NumberFormatException nex) { - msoLogger.debug("Invalid input for mso-service-request-timeout"); - } - } - - return DEFAULT_WAIT_TIME; - } - - - } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index 9ea97258ef..5afd7e00e8 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -38,12 +38,10 @@ import org.springframework.stereotype.Service; public class WorkflowProcessor extends ProcessEngineAwareService { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowProcessor.class); - protected static final String logMarker = "[WRKFLOW-RESOURCE]"; - protected static final long DEFAULT_WAIT_TIME = 30000; //default wait time @Async - public void startProcess( String processKey, VariableMapImpl variableMap) throws InterruptedException + public void startProcess( String processKey, VariableMapImpl variableMap) { long startTime = System.currentTimeMillis(); @@ -80,23 +78,12 @@ public class WorkflowProcessor extends ProcessEngineAwareService { throw new WorkflowProcessorException(workflowResponse); } } - - protected static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { - if (inputVariables == null) { - return ""; - } - return Objects.toString(inputVariables.get(key), "N/A"); - } - // Note: the business key is used to identify the process in unit tests protected static String getBusinessKey(Map<String, Object> inputVariables) { return getOrCreate(inputVariables, "mso-business-key"); } - protected static String getRequestId(Map<String, Object> inputVariables) { - return getOrCreate(inputVariables, "mso-request-id"); - } protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) { Map<String, Object> inputVariables = new HashMap<>(); @@ -120,20 +107,5 @@ public class WorkflowProcessor extends ProcessEngineAwareService { } return value; } - - protected long getWaitTime(Map<String, Object> inputVariables) - { - - String timeout = Objects.toString(inputVariables.get("mso-service-request-timeout"), null); - if (timeout != null) { - try { - return Long.parseLong(timeout)*1000; - } catch (NumberFormatException nex) { - msoLogger.debug("Invalid input for mso-service-request-timeout"); - } - } - - return DEFAULT_WAIT_TIME; - } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 9b65cca6c9..5435194f39 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -196,6 +196,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Override public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { + //injectLogExecutionListener(activity); } @Override @@ -213,7 +214,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { injectLogExecutionListener(timerActivity); } - @Override + @Override public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { } @@ -307,7 +308,8 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { String processName = repositoryService.createProcessDefinitionQuery() .processDefinitionId(execution.getProcessDefinitionId()) .singleResult() - .getName(); + .getName(); + MsoLogger.setServiceName(processName); String requestId = (String) execution.getVariable("mso-request-id"); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index efd73ba4f2..7956ecc363 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -27,11 +27,9 @@ import org.camunda.bpm.application.PostDeploy; import org.camunda.bpm.application.PreUndeploy; import org.camunda.bpm.application.ProcessApplicationInfo; import org.camunda.bpm.engine.ProcessEngine; -import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; import org.onap.so.logger.MsoLogger; import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -49,7 +47,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; */ @SpringBootApplication -@EnableProcessApplication("MSO Infrastructure Application") @EnableAsync @ComponentScan(basePackages = { "org.onap" }, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = { @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class) }) diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/META-INF/processes.xml b/bpmn/mso-infrastructure-bpmn/src/main/resources/META-INF/processes.xml deleted file mode 100644 index 35235b8539..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/META-INF/processes.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - ============LICENSE_START======================================================= - ONAP SO - ================================================================================ - 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========================================================= - --> - -<process-application - xmlns="http://www.camunda.org/schema/1.0/ProcessApplication" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <process-archive name="att-services-bpmn"> - <properties> - <property name="isDeleteUponUndeploy">false</property> - <property name="isScanForProcessDefinitions">true</property> - </properties> - </process-archive> - -</process-application> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application-local.yml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application-local.yml index 911aabdaec..ccea9483a8 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application-local.yml +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application-local.yml @@ -1,5 +1,5 @@ aai: - auth: asdf + auth: D6F77EC78213EF2AA1685F7F05E4DE7C0D1A70AA8798EC68B691CEF81E9991E4A0A3DA4F70EC61C5EB6525134E dme2: timeout: '30000' endpoint: http://localhost:8443 @@ -38,7 +38,7 @@ mso: completemsoprocess: endpoint: http://localhost:30253/CompleteMsoProcess db: - auth: 26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764 + auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 password: wLg4sjrAFUS8rfVfdvTXeQ== endpoint: http://localhost:30257/services/RequestsDbAdapter spring: @@ -51,7 +51,7 @@ mso: db: endpoint: http://localhost:30257/services/RequestsDbAdapter po: - auth: 757A94191D685FD2092AC1490730A4FC + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C password: 3141634BF7E070AA289CF2892C986C0B sdnc: endpoint: http://localhost:30254/adapters/SDNCAdapter diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml index c1f58e9db0..203988a1a3 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml @@ -6,22 +6,29 @@ server: spring: datasource: driver-class-name: org.mariadb.jdbc.Driver - url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/camundabpmn + jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/camundabpmn username: ${DB_USERNAME} password: ${DB_PASSWORD} - dbcp2: - initial-size: 5 - max-total: 20 - validation-query: select 1 - test-on-borrow: true http: multipart: enabled: false jersey: application-path: /sobpmnengine +camunda: + bpm: + application: + delete-upon-undeploy: false + scan-for-process-definitions: true + deploy-changed-only: true + job-execution: + deployment-aware: true #Actuator -management: - context-path: /manage +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" metrics: se-global-registry: false export: diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java index eee2810125..c28a86c49a 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java @@ -24,7 +24,7 @@ import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java index 041afe398b..d24e953196 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java @@ -56,6 +56,7 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.history.HistoricProcessInstance; import org.camunda.bpm.engine.history.HistoricVariableInstance; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; import org.camunda.bpm.engine.test.ProcessEngineRule; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.custommonkey.xmlunit.DetailedDiff; @@ -884,13 +885,23 @@ public abstract class WorkflowTest { return null; } + ProcessInstanceQuery processInstanceQuery = null; if (processInstance == null) { - processInstance = runtimeService + processInstanceQuery = runtimeService .createProcessInstanceQuery() - .processDefinitionKey(processKey) - .singleResult(); + .processDefinitionKey(processKey); + } + + if(processInstanceQuery.count() == 1 || processInstanceQuery.count() == 0){ + processInstance = processInstanceQuery.singleResult(); + }else{ + //TODO There shouldnt be more than one in the list but seems to be happening, need to figure out why happening and best way to get correct one from list + msoLogger.debug("Process Instance Query returned " + processInstanceQuery.count() + " instance. Getting the last instance in the list"); + List<ProcessInstance> processList = processInstanceQuery.list(); + processInstance = processList.get((processList.size() - 1)); } + if (processInstance != null) { value = runtimeService .getVariable(processInstance.getId(), variable); @@ -929,6 +940,11 @@ public abstract class WorkflowTest { "SDNCAResponse_CORRELATOR", timeout); if (sdncRequestId == null) { + sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV2", + "SDNCAResponse_CORRELATOR", timeout); + } + + if (sdncRequestId == null) { return false; } @@ -1688,7 +1704,7 @@ public abstract class WorkflowTest { /** * Checks to see if the specified process is ended. -<<<<<<< HEAD:bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java + * * @param processInstanceId the process Instance Id * @return true if the process is ended */ @@ -1700,8 +1716,7 @@ public abstract class WorkflowTest { /** * Checks to see if the specified process is ended. -======= ->>>>>>> origin/release/1806.51:bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java + * * @author cb645j */ //TODO combine into 1 diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java index 201e791a24..70d94052e1 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -20,15 +20,19 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import org.onap.aai.domain.yang.Pnf; -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; - import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +@Component +@Primary public class AaiConnectionTestImpl implements AaiConnection { public static final String ID_WITHOUT_ENTRY = "IdWithoutEntry"; diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 55910518e0..2d0d4b51a9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -22,37 +22,23 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import java.util.HashMap; import java.util.Map; + import java.util.UUID; import org.assertj.core.api.Assertions; -import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.test.Deployment; -import org.camunda.bpm.engine.test.ProcessEngineRule; -import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; -import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests; -import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; +import org.onap.so.BaseIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@ContextConfiguration(locations = "/applicationContext_forPnfTesting.xml") -public class CreateAndActivatePnfResourceTest { +public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { private static final String TIMEOUT_10_S = "PT10S"; - @Autowired - private RuntimeService runtimeService; - - @Autowired - @Rule - public ProcessEngineRule processEngineRule; private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); @Autowired @@ -62,11 +48,9 @@ public class CreateAndActivatePnfResourceTest { private DmaapClientTestImpl dmaapClientTestImpl; @Test - @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { // given - aaiConnection.reset(); - BpmnAwareTests.init(processEngineRule.getProcessEngine()); + aaiConnection.reset(); Map<String, Object> variables = new HashMap<>(); variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY); @@ -74,11 +58,11 @@ public class CreateAndActivatePnfResourceTest { // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); - BpmnAwareAssertions.assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); + assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); dmaapClientTestImpl.sendMessage(); // then - BpmnAwareAssertions.assertThat(instance).isEnded().hasPassedInOrder( + assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", "CheckInputs", "CheckAiiForCorrelationId", @@ -91,11 +75,10 @@ public class CreateAndActivatePnfResourceTest { } @Test - @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { // given aaiConnection.reset(); - BpmnAwareTests.init(processEngineRule.getProcessEngine()); + Map<String, Object> variables = new HashMap<>(); variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY); @@ -103,11 +86,11 @@ public class CreateAndActivatePnfResourceTest { // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); - BpmnAwareAssertions.assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); + assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); dmaapClientTestImpl.sendMessage(); // then - BpmnAwareAssertions.assertThat(instance).isEnded().hasPassedInOrder( + assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", "CheckInputs", "CheckAiiForCorrelationId", 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 09fb2d4cd7..146e07b820 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 @@ -20,10 +20,14 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; - import java.util.Objects; +import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +@Component +@Primary public class DmaapClientTestImpl implements DmaapClient { private String correlationId; diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java index 5b78b485a9..a19dec1f98 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java @@ -309,7 +309,7 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase { rollbackData.put(RbType, "rollbackSDNCassign", "true"); rollbackData.put(RbType, "rollbackSDNCactivate", "true"); rollbackData.put(RbType, "rollbackSDNCcreate", "true"); - rollbackData.put(RbType, "aaiARPath", "http://localhost:"+wiremockPort+"/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID); + rollbackData.put(RbType, "aaiARPath", "business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID); rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml")); rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml")); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java index 3720f1d840..8b47174b3b 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java @@ -309,7 +309,7 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase { rollbackData.put(RbType, "rollbackSDNCassign", "true"); rollbackData.put(RbType, "rollbackSDNCactivate", "true"); rollbackData.put(RbType, "rollbackSDNCcreate", "true"); - rollbackData.put(RbType, "aaiARPath", "http://localhost:"+wiremockPort+"/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID); + rollbackData.put(RbType, "aaiARPath", "/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID); rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml")); rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml")); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml b/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml index 167c2fa44b..09ffc0eb5c 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml @@ -1,6 +1,7 @@ aai: - auth: 26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764 + auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 endpoint: http://localhost:${wiremock.server.port} + pnfEntryNotificationTimeout: P14D appc: client: key: iaEMAfjsVsZnraBP @@ -22,7 +23,7 @@ mso: completemsoprocess: endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess db: - auth: 757A94191D685FD2092AC1490730A4FC + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter spring: endpoint: http://localhost:${wiremock.server.port} @@ -34,7 +35,7 @@ mso: db: endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter po: - auth: 757A94191D685FD2092AC1490730A4FC + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C password: 3141634BF7E070AA289CF2892C986C0B sdnc: endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter @@ -55,7 +56,9 @@ mso: workflow: message: endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message - + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 async: core-pool-size: 50 max-pool-size: 50 @@ -98,38 +101,14 @@ mso: default: aai: cloud-region: - version: '9' + version: '14' generic-vnf: - version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf + version: '14' global: default: aai: namespace: http://org.openecomp.aai.inventory/ - version: '8' + version: '14' message: endpoint: http://localhost:${wiremock.server.port}/mso/WorkflowMesssage notification: @@ -178,7 +157,7 @@ sniro: headers.latestVersion: 2 spring: datasource: - url: jdbc:mariadb://localhost:3307/camundabpmn + jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn username: root password: password driver-class-name: org.mariadb.jdbc.Driver @@ -205,4 +184,20 @@ camunda: bpm: metrics: enabled: false - db-reporter-activate: false
\ No newline at end of file + db-reporter-activate: false + application: + delete-upon-undeploy: false + scan-for-process-definitions: true + deploy-changed-only: true + job-execution: + deployment-aware: true +pnf: + dmaap: + host: hostTest + port: 1234 + protocol: http + uriPathPrefix: events + topicName: pnfReady + consumerGroup: consumerGroup + consumerId: consumerId + topicListenerDelayInSeconds: 5 diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/applicationContext_forPnfTesting.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/applicationContext_forPnfTesting.xml deleted file mode 100644 index 9e9e5a2177..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/resources/applicationContext_forPnfTesting.xml +++ /dev/null @@ -1,68 +0,0 @@ -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-2.5.xsd" > - - <bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> - <property name="targetDataSource"> - <bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> - <property name="driverClass" value="org.h2.Driver" /> - <property name="url" - value="jdbc:h2:mem:process-engine;DB_CLOSE_DELAY=1000" /> - <property name="username" value="sa" /> - <property name="password" value="" /> - </bean> - </property> - </bean> - - <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> - <property name="dataSource" ref="dataSource" /> - </bean> - - <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration"> - <property name="processEngineName" value="engine" /> - <property name="dataSource" ref="dataSource" /> - <property name="transactionManager" ref="transactionManager" /> - <property name="databaseSchemaUpdate" value="true" /> - <property name="jobExecutorActivate" value="false" /> - </bean> - - <bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean"> - <property name="processEngineConfiguration" ref="processEngineConfiguration" /> - </bean> - - <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /> - <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /> - <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> - <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> - <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /> - - <context:annotation-config /> - - <bean id="processEngineRule" class="org.camunda.bpm.engine.test.ProcessEngineRule"> - <property name="processEngine" ref="processEngine" /> - </bean> - - <bean id="aaiConnection" class="org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl"/> - - <bean id="CheckAaiForCorrelationIdDelegate" class="org.onap.so.bpmn.infrastructure.pnf.delegate.CheckAaiForCorrelationIdDelegate"> - <property name="aaiConnection" ref="aaiConnection"/> - </bean> - - <bean id="CreatePnfEntryInAaiDelegate" class="org.onap.so.bpmn.infrastructure.pnf.delegate.CreatePnfEntryInAaiDelegate"> - <property name="aaiConnection" ref="aaiConnection"/> - </bean> - - <bean id="InformDmaapClient" class="org.onap.so.bpmn.infrastructure.pnf.delegate.InformDmaapClient"> - <property name="dmaapClient" ref="DmaapClient"/> - </bean> - - <bean id="DmaapClient" class="org.onap.so.bpmn.infrastructure.pnf.delegate.DmaapClientTestImpl"/> - - <bean id="PnfCheckInputs" class="org.onap.so.bpmn.infrastructure.pnf.delegate.PnfCheckInputs"> - <constructor-arg value="PT1S"></constructor-arg> - </bean> -</beans> |