diff --git a/.github/workflows/pr-downstream.yml b/.github/workflows/pr-downstream.yml index 8a477879ca1..ad13eb8f92e 100644 --- a/.github/workflows/pr-downstream.yml +++ b/.github/workflows/pr-downstream.yml @@ -23,7 +23,7 @@ jobs: job_name: [ kogito-apps, kogito-quarkus-examples, kogito-springboot-examples, serverless-workflow-examples ] os: [ubuntu-latest] java-version: [17] - maven-version: ['3.9.3'] + maven-version: ['3.9.6'] include: - job_name: kogito-apps repository: kogito-apps diff --git a/.github/workflows/pr-kogito-runtimes.yml b/.github/workflows/pr-kogito-runtimes.yml index fb794f5f40a..de79abcccaf 100644 --- a/.github/workflows/pr-kogito-runtimes.yml +++ b/.github/workflows/pr-kogito-runtimes.yml @@ -22,7 +22,7 @@ jobs: matrix: os: [ubuntu-latest] java-version: [17] - maven-version: ['3.9.3'] + maven-version: ['3.9.6'] fail-fast: false runs-on: ${{ matrix.os }} name: ${{ matrix.os }} / Java-${{ matrix.java-version }} / Maven-${{ matrix.maven-version }} diff --git a/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java b/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java index 92ddf1241e8..007c1aa4bde 100644 --- a/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java +++ b/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java @@ -18,8 +18,8 @@ */ package org.kie.kogito.monitoring.core.common.process; -import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -49,7 +49,7 @@ public class MetricsProcessEventListener extends DefaultKogitoProcessEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(MetricsProcessEventListener.class); - private static Map gaugeMap = new HashMap<>(); + private static Map gaugeMap = new ConcurrentHashMap<>(); private final String identifier; private final KogitoGAV gav; private final MeterRegistry meterRegistry; diff --git a/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationRepository.java b/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationRepository.java new file mode 100644 index 00000000000..0aa053a4ccc --- /dev/null +++ b/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationRepository.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.mongodb.correlation; + +import java.io.UncheckedIOException; +import java.util.Map; + +import org.bson.Document; +import org.bson.codecs.configuration.CodecRegistries; +import org.bson.codecs.configuration.CodecRegistry; +import org.bson.conversions.Bson; +import org.kie.kogito.correlation.CompositeCorrelation; +import org.kie.kogito.correlation.Correlation; +import org.kie.kogito.correlation.CorrelationInstance; +import org.kie.kogito.correlation.SimpleCorrelation; +import org.kie.kogito.jackson.utils.ObjectMapperFactory; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.model.Filters; +import com.mongodb.client.result.InsertOneResult; + +public class MongoDBCorrelationRepository { + + private final MongoCollection collection; + private final ObjectMapper objectMapper; + + private static final String ENCODED_CORRELATION_ID_FIELD = "encodedCorrelationId"; + private static final String CORRELATED_ID_FIELD = "correlatedId"; + private static final String CORRELATION_FIELD = "correlation"; + private static final String CORRELATION_COLLECTION_NAME = "correlations"; + + public MongoDBCorrelationRepository(MongoClient mongoClient, String dbName) { + CodecRegistry registry = CodecRegistries.fromRegistries(MongoClientSettings.getDefaultCodecRegistry()); + this.collection = mongoClient.getDatabase(dbName).getCollection(CORRELATION_COLLECTION_NAME).withCodecRegistry(registry); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addAbstractTypeMapping(Correlation.class, SimpleCorrelation.class); + this.objectMapper = ObjectMapperFactory.get().copy().registerModule(simpleModule); + } + + public CorrelationInstance insert(final String encodedCorrelationId, final String correlatedId, final Correlation correlation) { + + CorrelationInstance correlationInstance = new CorrelationInstance(encodedCorrelationId, correlatedId, correlation); + try { + Map object = Map.of( + ENCODED_CORRELATION_ID_FIELD, encodedCorrelationId, + CORRELATED_ID_FIELD, correlatedId, + CORRELATION_FIELD, correlation); + String json = this.objectMapper.writeValueAsString(object); + InsertOneResult insertOneResult = this.collection.insertOne(Document.parse(json)); + return insertOneResult.getInsertedId() != null ? correlationInstance : null; + } catch (JsonProcessingException e) { + throw new UncheckedIOException(e); + } + } + + public CorrelationInstance findByEncodedCorrelationId(String encoded) { + Bson eq = Filters.eq(ENCODED_CORRELATION_ID_FIELD, encoded); + return getCorrelationInstanceByFilter(eq); + } + + public CorrelationInstance findByCorrelatedId(String correlatedId) { + Bson eq = Filters.eq(CORRELATED_ID_FIELD, correlatedId); + return getCorrelationInstanceByFilter(eq); + } + + private CorrelationInstance getCorrelationInstanceByFilter(Bson eq) { + Document first = this.collection.find(eq).first(); + if (first == null) { + return null; + } else { + Document document = first.get(CORRELATION_FIELD, Document.class); + try { + CompositeCorrelation compositeCorrelation = this.objectMapper.readValue(document.toJson(), CompositeCorrelation.class); + return new CorrelationInstance( + first.getString(ENCODED_CORRELATION_ID_FIELD), + first.getString(CORRELATED_ID_FIELD), + compositeCorrelation); + } catch (JsonProcessingException e) { + throw new UncheckedIOException(e); + } + } + } + + public void delete(String encoded) { + Bson eq = Filters.eq(ENCODED_CORRELATION_ID_FIELD, encoded); + this.collection.deleteOne(eq); + } +} diff --git a/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationService.java b/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationService.java new file mode 100644 index 00000000000..f3fe19ae49c --- /dev/null +++ b/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationService.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.mongodb.correlation; + +import java.util.Optional; + +import org.kie.kogito.correlation.Correlation; +import org.kie.kogito.correlation.CorrelationEncoder; +import org.kie.kogito.correlation.CorrelationInstance; +import org.kie.kogito.correlation.CorrelationService; +import org.kie.kogito.event.correlation.MD5CorrelationEncoder; + +public class MongoDBCorrelationService implements CorrelationService { + + private final MongoDBCorrelationRepository correlationRepository; + private final CorrelationEncoder correlationEncoder; + + public MongoDBCorrelationService(MongoDBCorrelationRepository correlationRepository) { + this.correlationRepository = correlationRepository; + this.correlationEncoder = new MD5CorrelationEncoder(); + } + + @Override + public CorrelationInstance create(Correlation correlation, String correlatedId) { + String encodedCorrelationId = this.correlationEncoder.encode(correlation); + return this.correlationRepository.insert(encodedCorrelationId, correlatedId, correlation); + } + + @Override + public Optional find(Correlation correlation) { + String encodedCorrelationId = correlationEncoder.encode(correlation); + return Optional.ofNullable(this.correlationRepository.findByEncodedCorrelationId(encodedCorrelationId)); + } + + @Override + public Optional findByCorrelatedId(String correlatedId) { + return Optional.ofNullable(this.correlationRepository.findByCorrelatedId(correlatedId)); + } + + @Override + public void delete(Correlation correlation) { + String encodedCorrelationId = correlationEncoder.encode(correlation); + this.correlationRepository.delete(encodedCorrelationId); + } +} diff --git a/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationServiceIT.java b/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationServiceIT.java new file mode 100644 index 00000000000..f3abeaf61b2 --- /dev/null +++ b/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/correlation/MongoDBCorrelationServiceIT.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.mongodb.correlation; + +import java.util.Collections; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.kogito.correlation.CompositeCorrelation; +import org.kie.kogito.correlation.CorrelationInstance; +import org.kie.kogito.correlation.SimpleCorrelation; +import org.kie.kogito.testcontainers.KogitoMongoDBContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; + +import static org.assertj.core.api.Assertions.assertThat; + +@Testcontainers +class MongoDBCorrelationServiceIT { + + @Container + final static KogitoMongoDBContainer mongoDBContainer = new KogitoMongoDBContainer(); + private static MongoDBCorrelationService correlationService; + private static MongoClient mongoClient; + private static final String DB_NAME = "test"; + private static final String COLLECTION_NAME = "correlations"; + + @BeforeAll + static void setUp() { + mongoDBContainer.start(); + mongoClient = MongoClients.create(mongoDBContainer.getReplicaSetUrl()); + correlationService = new MongoDBCorrelationService(new MongoDBCorrelationRepository( + mongoClient, DB_NAME)); + } + + @BeforeEach + void beforeEach() { + mongoClient.getDatabase(DB_NAME).getCollection(COLLECTION_NAME).drop(); + } + + @Test + void shouldSaveCorrelation() { + // arrange + String correlatedId = "id"; + CompositeCorrelation correlation = new CompositeCorrelation(Collections.singleton(new SimpleCorrelation<>("city", "Rio de Janeiro"))); + + // act + correlationService.create(correlation, correlatedId); + + // assert + Optional byCorrelatedId = correlationService.findByCorrelatedId(correlatedId); + assertThat(byCorrelatedId).isNotEmpty(); + } + + @Test + void shouldDeleteCorrelation() { + // arrange + String correlatedId = "id"; + CompositeCorrelation correlation = new CompositeCorrelation(Collections.singleton(new SimpleCorrelation<>("city", "São Paulo"))); + correlationService.create(correlation, correlatedId); + + // act + correlationService.delete(correlation); + + // assert + assertThat(correlationService.findByCorrelatedId(correlatedId)).isEmpty(); + } + + @Test + void shouldFindByCorrelatedId() { + // arrange + String correlatedId = "id"; + CompositeCorrelation correlation = new CompositeCorrelation(Collections.singleton(new SimpleCorrelation<>("city", "Goiânia"))); + correlationService.create(correlation, correlatedId); + + // act + Optional byCorrelatedId = correlationService.findByCorrelatedId(correlatedId); + + // assert + assertThat(byCorrelatedId).isNotEmpty(); + } + + @Test + void shouldFindByCorrelation() { + // arrange + CompositeCorrelation correlation = new CompositeCorrelation(Collections.singleton(new SimpleCorrelation<>("city", "Osasco"))); + String correlatedId = "id"; + + correlationService.create(correlation, correlatedId); + + // act + Optional correlationInstance = correlationService.find(correlation); + + // assert + assertThat(correlationInstance).isNotEmpty(); + } + +} diff --git a/addons/common/pom.xml b/addons/common/pom.xml index 35d262844c8..6ac076d7960 100644 --- a/addons/common/pom.xml +++ b/addons/common/pom.xml @@ -41,6 +41,7 @@ rest-exception-handler process-svg process-management + process-dynamic knative kubernetes kubernetes-service-catalog diff --git a/addons/common/process-dynamic/pom.xml b/addons/common/process-dynamic/pom.xml new file mode 100644 index 00000000000..35e3a6ae36f --- /dev/null +++ b/addons/common/process-dynamic/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + org.kie + kogito-addons-common-parent + 999-SNAPSHOT + + kie-addons-process-dynamic + KIE Add-On Process Instance Dynamic Calls + Allow performing dynamic calls for existing process instances + + org.kie.process.dynamic + + + + + org.kie.kogito + kogito-rest-workitem + + + \ No newline at end of file diff --git a/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/DynamicPathParamResolver.java b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/DynamicPathParamResolver.java new file mode 100644 index 00000000000..b6a0580e86a --- /dev/null +++ b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/DynamicPathParamResolver.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.util.Map; + +import org.kogito.workitem.rest.pathresolvers.DefaultPathParamResolver; + +public class DynamicPathParamResolver extends DefaultPathParamResolver { + + private String processInstanceId; + + public DynamicPathParamResolver(String processInstanceId) { + this.processInstanceId = processInstanceId; + } + + @Override + protected Object getParam(Map parameters, String key) { + return key.equals("processInstanceId") ? this.processInstanceId : super.getParam(parameters, key); + } +} diff --git a/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/ProcessInstanceDynamicCallHelper.java b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/ProcessInstanceDynamicCallHelper.java new file mode 100644 index 00000000000..7c52c174aa2 --- /dev/null +++ b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/ProcessInstanceDynamicCallHelper.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.drools.core.common.InternalKnowledgeRuntime; +import org.jbpm.process.instance.InternalProcessRuntime; +import org.jbpm.process.instance.KogitoProcessContextImpl; +import org.jbpm.process.instance.ProcessInstance; +import org.jbpm.util.ContextFactory; +import org.jbpm.workflow.core.impl.WorkflowProcessImpl; +import org.jbpm.workflow.instance.WorkflowProcessInstance; +import org.jbpm.workflow.instance.node.DynamicUtils; +import org.kie.kogito.Model; +import org.kie.kogito.process.Process; +import org.kie.kogito.process.expr.ExpressionHandlerFactory; +import org.kie.kogito.process.impl.AbstractProcessInstance; +import org.kogito.workitem.rest.RestWorkItemHandler; + +public class ProcessInstanceDynamicCallHelper { + + private ProcessInstanceDynamicCallHelper() { + } + + public static void executeRestCall(RestWorkItemHandler handler, Collection> processes, String processId, String processInstanceId, RestCallInfo input) { + Process processDef = processes.stream().filter(p -> p.id().equals(processId)).findAny().orElseThrow(() -> new IllegalArgumentException("Cannot find process " + processId)); + WorkflowProcessInstance pi = (WorkflowProcessInstance) findProcessInstance(processDef, processInstanceId); + WorkflowProcessImpl process = (WorkflowProcessImpl) pi.getProcess(); + if (!process.isDynamic()) { + process.setDynamic(true); + } + InternalKnowledgeRuntime runtime = pi.getKnowledgeRuntime(); + InternalProcessRuntime.asKogitoProcessRuntime(runtime).getKogitoWorkItemManager().registerWorkItemHandler(RestWorkItemHandler.REST_TASK_TYPE, handler); + Map parameters = input.getArguments() == null ? new HashMap<>() : new HashMap<>(input.getArguments()); + if (input.getHost() != null) { + parameters.put(RestWorkItemHandler.HOST, input.getHost()); + } + if (input.getPort() != null) { + parameters.put(RestWorkItemHandler.PORT, input.getPort()); + } + if (input.getMethod() != null) { + parameters.put(RestWorkItemHandler.METHOD, input.getMethod()); + } + if (input.getEndpoint() != null) { + parameters.put(RestWorkItemHandler.URL, input.getEndpoint()); + } + parameters.put(RestWorkItemHandler.PATH_PARAM_RESOLVER, new DynamicPathParamResolver(processInstanceId)); + WorkItemHandlerResultHolder holder = new WorkItemHandlerResultHolder(); + parameters.put(RestWorkItemHandler.RESULT_HANDLER, holder); + KogitoProcessContextImpl context = ContextFactory.fromItem(DynamicUtils.addDynamicWorkItem(pi, runtime, RestWorkItemHandler.REST_TASK_TYPE, parameters)); + Model model = ((Model) processDef.createModel()); + model.update(input.getOutputExpression() != null + ? ExpressionHandlerFactory.get(input.getOutputExpressionLang(), input.getOutputExpression()).eval(holder.getResult(), Map.class, context) + : holder.getResult()); + ((AbstractProcessInstance) pi.unwrap()).updateVariablesPartially(model); + } + + private static ProcessInstance findProcessInstance(Process process, String processInstanceId) { + return process.instances() + .findById(processInstanceId).map(AbstractProcessInstance.class::cast) + .map(AbstractProcessInstance::internalGetProcessInstance) + .orElseThrow(() -> new IllegalArgumentException("Cannot find process instance " + processInstanceId + " for process " + process.id())); + } +} diff --git a/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/RestCallInfo.java b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/RestCallInfo.java new file mode 100644 index 00000000000..e6a0a144906 --- /dev/null +++ b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/RestCallInfo.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.util.Map; + +public class RestCallInfo { + + private String endpoint; + private String host; + private Integer port; + private String method; + private Map arguments; + private String outputExpression; + private String outputExpressionLang = "jq"; + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public Map getArguments() { + return arguments; + } + + public void setArguments(Map arguments) { + this.arguments = arguments; + } + + public String getOutputExpression() { + return outputExpression; + } + + public void setOutputExpression(String outputExpression) { + this.outputExpression = outputExpression; + } + + public String getOutputExpressionLang() { + return outputExpressionLang; + } + + public void setOutputExpressionLang(String outputExpressionLang) { + this.outputExpressionLang = outputExpressionLang; + } + + @Override + public String toString() { + return "RestCallInfo [endpoint=" + endpoint + ", host=" + host + ", port=" + port + ", method=" + method + + ", arguments=" + arguments + ", outputExpression=" + outputExpression + ", outputExpressionLang=" + + outputExpressionLang + "]"; + } +} diff --git a/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/WorkItemHandlerResultHolder.java b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/WorkItemHandlerResultHolder.java new file mode 100644 index 00000000000..620526f71dd --- /dev/null +++ b/addons/common/process-dynamic/src/main/java/org/kie/kogito/process/dynamic/WorkItemHandlerResultHolder.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.util.Map; + +import org.kogito.workitem.rest.resulthandlers.RestWorkItemHandlerResult; + +import io.vertx.mutiny.core.buffer.Buffer; +import io.vertx.mutiny.ext.web.client.HttpResponse; + +public class WorkItemHandlerResultHolder implements RestWorkItemHandlerResult { + + private Map result; + + @Override + public Object apply(HttpResponse buffer, Class clazz) { + result = buffer.bodyAsJson(Map.class); + return result; + } + + public Map getResult() { + return result; + } +} diff --git a/drools/kogito-pmml-dependencies/pom.xml b/drools/kogito-pmml-dependencies/pom.xml index 0d1f91a2891..d75f0a14849 100644 --- a/drools/kogito-pmml-dependencies/pom.xml +++ b/drools/kogito-pmml-dependencies/pom.xml @@ -59,33 +59,33 @@ org.kie kie-pmml-dependencies + org.kie - kie-pmml-models-tree-model + kie-pmml-models-drools-tree-model org.kie - kie-pmml-models-tree-compiler + kie-pmml-models-drools-tree-compiler org.kie - kie-pmml-models-tree-evaluator + kie-pmml-models-drools-tree-evaluator org.kie - kie-pmml-models-scorecard-model + kie-pmml-models-drools-scorecard-model org.kie - kie-pmml-models-scorecard-compiler + kie-pmml-models-drools-scorecard-compiler org.kie - kie-pmml-models-scorecard-evaluator + kie-pmml-models-drools-scorecard-evaluator - org.drools drools-mvel @@ -120,32 +120,31 @@ - org.kie - kie-pmml-models-drools-tree-model + kie-pmml-models-tree-model org.kie - kie-pmml-models-drools-tree-compiler + kie-pmml-models-tree-compiler org.kie - kie-pmml-models-drools-tree-evaluator + kie-pmml-models-tree-evaluator org.kie - kie-pmml-models-drools-scorecard-model + kie-pmml-models-scorecard-model org.kie - kie-pmml-models-drools-scorecard-compiler + kie-pmml-models-scorecard-compiler org.kie - kie-pmml-models-drools-scorecard-evaluator + kie-pmml-models-scorecard-evaluator diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java index a5e452a24a0..fb73d73c005 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java @@ -161,6 +161,9 @@ public void setNodeInstanceContainer(KogitoNodeInstanceContainer nodeInstanceCon @Override public org.kie.api.definition.process.Node getNode() { + if (nodeId == null) { + return null; + } try { return ((org.jbpm.workflow.core.NodeContainer) this.nodeInstanceContainer.getNodeContainer()).internalGetNode(this.nodeId); } catch (IllegalArgumentException e) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java index 5f67bf1957b..c604312a8cf 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java @@ -288,9 +288,12 @@ public List getNodeInstances(WorkflowElementIdentifier nodeId) { } public List getNodeInstances(WorkflowElementIdentifier nodeId, final List currentView) { + if (nodeId == null) { + return Collections.emptyList(); + } List result = new ArrayList<>(); for (final NodeInstance nodeInstance : currentView) { - if (nodeInstance.getNodeId().equals(nodeId)) { + if (nodeId.equals(nodeInstance.getNodeId())) { result.add(nodeInstance); } } @@ -712,7 +715,7 @@ public void signalEvent(String type, Object event) { } nodeInstance.trigger(null, Node.CONNECTION_DEFAULT_TYPE); } else if (node instanceof CompositeNode) { - Optional instance = this.nodeInstances.stream().filter(ni -> ni.getNodeId().equals(node.getId())).findFirst(); + Optional instance = this.nodeInstances.stream().filter(ni -> Objects.equals(ni.getNodeId(), node.getId())).findFirst(); instance.ifPresent(n -> ((CompositeNodeInstance) n).signalEvent(type, event)); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/DynamicUtils.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/DynamicUtils.java index f7b0f23ab24..5c11434bf91 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/DynamicUtils.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/DynamicUtils.java @@ -51,6 +51,7 @@ import org.kie.kogito.internal.process.event.KogitoProcessEventSupport; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; +import org.kie.kogito.internal.process.runtime.KogitoWorkItem; import org.kie.kogito.process.workitems.InternalKogitoWorkItemManager; import org.kie.kogito.process.workitems.impl.KogitoWorkItemImpl; import org.slf4j.Logger; @@ -75,19 +76,19 @@ public static void addDynamicWorkItem( parameters); } - public static void addDynamicWorkItem( + public static KogitoWorkItem addDynamicWorkItem( final org.kie.api.runtime.process.ProcessInstance dynamicProcessInstance, KieRuntime ksession, String workItemName, Map parameters) { - internalAddDynamicWorkItem((WorkflowProcessInstance) dynamicProcessInstance, + return internalAddDynamicWorkItem((WorkflowProcessInstance) dynamicProcessInstance, null, ksession, workItemName, parameters); } - private static void internalAddDynamicWorkItem( + private static KogitoWorkItem internalAddDynamicWorkItem( final WorkflowProcessInstance processInstance, final DynamicNodeInstance dynamicContext, KieRuntime ksession, @@ -134,14 +135,7 @@ private static void internalAddDynamicWorkItem( workItemNodeInstance.setMetaData("NodeType", workItemName); workItem.setNodeInstanceId(workItemNodeInstance.getStringId()); - if (ksession instanceof StatefulKnowledgeSession) { - workItemNodeInstance.setProcessInstance(processInstance); - workItemNodeInstance.setNodeInstanceContainer(dynamicContext == null ? processInstance : dynamicContext); - workItemNodeInstance.addEventListeners(); - executeWorkItem((StatefulKnowledgeSession) ksession, - workItem, - workItemNodeInstance); - } else if (ksession instanceof CommandBasedStatefulKnowledgeSession) { + if (ksession instanceof CommandBasedStatefulKnowledgeSession) { ExecutableRunner runner = ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); runner.execute(new ExecutableCommand() { private static final long serialVersionUID = 5L; @@ -164,11 +158,18 @@ public Void execute(Context context) { } }); } else { - throw new IllegalArgumentException("Unsupported ksession: " + (ksession == null ? "null" : ksession.getClass().getName())); + workItemNodeInstance.setProcessInstance(processInstance); + workItemNodeInstance.setNodeInstanceContainer(dynamicContext == null ? processInstance : dynamicContext); + workItemNodeInstance.addEventListeners(); + executeWorkItem(ksession, + workItem, + workItemNodeInstance); + } + return workItem; } - private static void executeWorkItem(StatefulKnowledgeSession ksession, + private static void executeWorkItem(KieRuntime ksession, KogitoWorkItemImpl workItem, WorkItemNodeInstance workItemNodeInstance) { KogitoProcessRuntime kruntime = asKogitoProcessRuntime(ksession); @@ -225,13 +226,7 @@ public static String internalAddDynamicSubProcess( subProcessNodeInstance.setProcessInstance(processInstance); subProcessNodeInstance.setMetaData("NodeType", "SubProcessNode"); - if (ksession instanceof StatefulKnowledgeSession) { - return executeSubProcess(asKogitoProcessRuntime(ksession), - processId, - parameters, - processInstance, - subProcessNodeInstance); - } else if (ksession instanceof CommandBasedStatefulKnowledgeSession) { + if (ksession instanceof CommandBasedStatefulKnowledgeSession) { ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); return commandService.execute(new ExecutableCommand() { private static final long serialVersionUID = 5L; @@ -256,7 +251,11 @@ public String execute(Context context) { } }); } else { - throw new IllegalArgumentException("Unsupported ksession: " + (ksession == null ? "null" : ksession.getClass().getName())); + return executeSubProcess(asKogitoProcessRuntime(ksession), + processId, + parameters, + processInstance, + subProcessNodeInstance); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/expr/ExpressionHandlerFactory.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/expr/ExpressionHandlerFactory.java index af66edf6e99..3becf03a8ad 100644 --- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/expr/ExpressionHandlerFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/expr/ExpressionHandlerFactory.java @@ -18,15 +18,18 @@ */ package org.kie.kogito.process.expr; +import java.util.Collection; import java.util.Optional; import java.util.ServiceLoader; +import java.util.stream.Collectors; public class ExpressionHandlerFactory { private ExpressionHandlerFactory() { } - private static final ServiceLoader serviceLoader = ServiceLoader.load(ExpressionHandler.class); + private static final Collection expressionHandlers = ServiceLoader.load(ExpressionHandler.class).stream() + .map(ServiceLoader.Provider::get).collect(Collectors.toUnmodifiableList()); public static Expression get(String lang, String expr) { return getExpressionHandler(lang).orElseThrow( @@ -34,10 +37,10 @@ public static Expression get(String lang, String expr) { } public static boolean isSupported(String lang) { - return serviceLoader.stream().anyMatch(p -> p.get().lang().equals(lang)); + return expressionHandlers.stream().map(ExpressionHandler::lang).anyMatch(lang::equals); } private static Optional getExpressionHandler(String lang) { - return serviceLoader.stream().filter(p -> p.get().lang().equals(lang)).findFirst().map(p -> p.get()); + return expressionHandlers.stream().filter(p -> p.lang().equals(lang)).findFirst(); } } diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompensationTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompensationTest.java index e379fd3166f..ad6d9095708 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompensationTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompensationTest.java @@ -23,19 +23,38 @@ import java.util.List; import java.util.Map; -import org.assertj.core.api.Assertions; +import org.jbpm.bpmn2.compensation.BookResourceProcess; +import org.jbpm.bpmn2.compensation.BookingModel; +import org.jbpm.bpmn2.compensation.BookingProcess; +import org.jbpm.bpmn2.compensation.CancelResourceProcess; +import org.jbpm.bpmn2.compensation.IntermediateThrowEventModel; +import org.jbpm.bpmn2.compensation.IntermediateThrowEventProcess; +import org.jbpm.bpmn2.compensation.ParallelOrderedCompensationIntermediateThrowEventModel; +import org.jbpm.bpmn2.compensation.ParallelOrderedCompensationIntermediateThrowEventProcess; +import org.jbpm.bpmn2.compensation.ThrowSpecificForSubProcessModel; +import org.jbpm.bpmn2.compensation.ThrowSpecificForSubProcessProcess; +import org.jbpm.bpmn2.compensation.UserTaskBeforeAssociatedActivityModel; +import org.jbpm.bpmn2.compensation.UserTaskBeforeAssociatedActivityProcess; +import org.jbpm.bpmn2.compensation.UserTaskCompensationModel; +import org.jbpm.bpmn2.compensation.UserTaskCompensationProcess; import org.jbpm.bpmn2.objects.TestWorkItemHandler; import org.jbpm.process.core.context.exception.CompensationScope; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; +import org.jbpm.test.utils.ProcessTestHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.kie.api.event.process.ProcessNodeLeftEvent; import org.kie.api.event.process.ProcessNodeTriggeredEvent; +import org.kie.kogito.Application; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; import org.kie.kogito.internal.process.event.KogitoProcessEventListener; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; +import org.kie.kogito.process.ProcessInstance; +import org.kie.kogito.process.impl.Sig; + +import static org.assertj.core.api.Assertions.assertThat; public class CompensationTest extends JbpmBpmn2TestCase { @@ -73,38 +92,39 @@ public void prepare() { */ @Test - public void compensationViaIntermediateThrowEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-IntermediateThrowEvent.bpmn2"); + public void compensationViaIntermediateThrowEventProcess() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - params.put("x", "0"); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateThrowEvent", params); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = IntermediateThrowEventProcess.newProcess(app); + IntermediateThrowEventModel model = process.createModel(); + model.setX("0"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); + processInstance.completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); // compensation activity (assoc. with script task) signaled *after* script task - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - assertProcessVarValue(processInstance, "x", "1"); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); + assertThat(processInstance.variables().getX()).isEqualTo("1"); } @Test - public void compensationTwiceViaSignal() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-IntermediateThrowEvent.bpmn2"); + public void compensationTwiceViaSignal() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - params.put("x", "0"); - String processId = "IntermediateThrowEvent"; - KogitoProcessInstance processInstance = kruntime.startProcess(processId, params); - - // twice - kruntime.signalEvent("Compensation", CompensationScope.IMPLICIT_COMPENSATION_PREFIX + processId, processInstance.getStringId()); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); - - // compensation activity (assoc. with script task) signaled *after* script task - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - assertProcessVarValue(processInstance, "x", "2"); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = IntermediateThrowEventProcess.newProcess(app); + IntermediateThrowEventModel model = process.createModel(); + model.setX("0"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + + processInstance.send(Sig.of("Compensation", CompensationScope.IMPLICIT_COMPENSATION_PREFIX + "IntermediateThrowEvent")); + processInstance.completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); + + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); + assertThat(processInstance.variables().getX()).isEqualTo("2"); } @Test @@ -122,60 +142,55 @@ public void compensationViaEventSubProcess() throws Exception { } @Test - public void compensationOnlyAfterAssociatedActivityHasCompleted() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-UserTaskBeforeAssociatedActivity.bpmn2"); - kruntime.getProcessEventManager().addEventListener(LOGGING_EVENT_LISTENER); + public void compensationOnlyAfterAssociatedActivityHasCompleted() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerProcessEventListener(app, LOGGING_EVENT_LISTENER); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - params.put("x", "0"); - KogitoProcessInstance processInstance = kruntime.startProcess("UserTaskBeforeAssociatedActivity", params); - - // should NOT cause compensation since compensated activity has not yet completed (or started)! - kruntime.signalEvent("Compensation", "_3", processInstance.getStringId()); - - // user task -> script task (associated with compensation) --> intermeidate throw compensation event - kruntime.getKogitoWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); - // compensation activity (assoc. with script task) signaled *after* to-compensate script task - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - assertProcessVarValue(processInstance, "x", "1"); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = UserTaskBeforeAssociatedActivityProcess.newProcess(app); + UserTaskBeforeAssociatedActivityModel model = process.createModel(); + model.setX("0"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + + processInstance.send(Sig.of("Compensation", "_3")); + + processInstance.completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); + assertThat(processInstance.variables().getX()).isEqualTo("1"); } @Test - public void orderedCompensation() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-ParallelOrderedCompensationIntermediateThrowEvent.bpmn2"); + public void orderedCompensation() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - params.put("x", ""); - KogitoProcessInstance processInstance = kruntime.startProcess("ParallelOrderedCompensationIntermediateThrowEvent", params); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = ParallelOrderedCompensationIntermediateThrowEventProcess.newProcess(app); + ParallelOrderedCompensationIntermediateThrowEventModel model = process.createModel(); + model.setX(""); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + List workItems = workItemHandler.getWorkItems(); - List workItemIds = new ArrayList<>(); - for (KogitoWorkItem workItem : workItems) { - if ("Thr".equals(workItem.getParameter("NodeName"))) { - workItemIds.add(workItem.getStringId()); - } - } - for (KogitoWorkItem workItem : workItems) { - if ("Two".equals(workItem.getParameter("NodeName"))) { - workItemIds.add(workItem.getStringId()); - } - } - for (KogitoWorkItem workItem : workItems) { - if ("One".equals(workItem.getParameter("NodeName"))) { - workItemIds.add(workItem.getStringId()); - } - } - for (String id : workItemIds) { - kruntime.getKogitoWorkItemManager().completeWorkItem(id, null); - } + final List workItemIds = new ArrayList<>(); + + workItems.stream().filter(workItem -> "Thr".equals(workItem.getParameter("NodeName"))) + .forEach(workItem -> workItemIds.add(workItem.getStringId())); + + workItems.stream().filter(workItem -> "Two".equals(workItem.getParameter("NodeName"))) + .forEach(workItem -> workItemIds.add(workItem.getStringId())); + + workItems.stream().filter(workItem -> "One".equals(workItem.getParameter("NodeName"))) + .forEach(workItem -> workItemIds.add(workItem.getStringId())); + + workItemIds.forEach(id -> processInstance.completeWorkItem(id, null)); // user task -> script task (associated with compensation) --> intermeidate throw compensation event - String xVal = getProcessVarValue(processInstance, "x"); + String xVal = processInstance.variables().getX(); // Compensation happens in the *REVERSE* order of completion // Ex: if the order is 3, 17, 282, then compensation should happen in the order of 282, 17, 3 // Compensation did not fire in the same order as the associated activities completed. - Assertions.assertThat(xVal).isEqualTo("_171:_131:_141:_151:"); + assertThat(xVal).isEqualTo("_171:_131:_141:_151:"); } @Test @@ -199,62 +214,71 @@ public void compensationInSubSubProcesses() throws Exception { } @Test - public void specificCompensationOfASubProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-ThrowSpecificForSubProcess.bpmn2"); + public void specificCompensationOfASubProcess() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - params.put("x", 1); - KogitoProcessInstance processInstance = kruntime.startProcess("ThrowSpecificForSubProcess", params); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = ThrowSpecificForSubProcessProcess.newProcess(app); + ThrowSpecificForSubProcessModel model = process.createModel(); + model.setX(1); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); // compensation activity (assoc. with script task) signaled *after* to-compensate script task - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); - assertProcessVarValue(processInstance, "x", null); + assertThat(processInstance.variables().getX()).isNull(); } @Test @Disabled - public void compensationViaCancellation() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-IntermediateThrowEvent.bpmn2"); + public void compensationViaCancellation() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - params.put("x", "0"); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateThrowEvent", params); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = IntermediateThrowEventProcess.newProcess(app); + IntermediateThrowEventModel model = process.createModel(); + model.setX("0"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); - kruntime.signalEvent("Cancel", null, processInstance.getStringId()); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); + processInstance.send(Sig.of("Cancel", null)); + processInstance.completeWorkItem(workItemHandler.getWorkItem().getStringId(), null); // compensation activity (assoc. with script task) signaled *after* script task - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - assertProcessVarValue(processInstance, "x", "1"); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); + assertThat(processInstance.variables().getX()).isEqualTo("1"); } @Test - public void compensationInvokingSubProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-UserTaskCompensation.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("compensation", "True"); - KogitoProcessInstance processInstance = kruntime.startProcess("UserTaskCompensation", params); - - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - assertProcessVarValue(processInstance, "compensation", "compensation"); + public void compensationInvokingSubProcess() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process process = UserTaskCompensationProcess.newProcess(app); + UserTaskCompensationModel model = process.createModel(); + model.setCompensation("True"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); + assertThat(processInstance.variables().getCompensation()).isEqualTo("compensation"); } /** * Test to demonstrate that Compensation Events work with Reusable * Subprocesses * - * @throws Exception */ @Test - public void compensationWithReusableSubprocess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/compensation/BPMN2-Booking.bpmn2", - "org/jbpm/bpmn2/compensation/BPMN2-BookResource.bpmn2", "org/jbpm/bpmn2/compensation/BPMN2-CancelResource.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("Booking"); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); + public void compensationWithReusableSubprocess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = BookingProcess.newProcess(app); + BookResourceProcess.newProcess(app); + CancelResourceProcess.newProcess(app); + ProcessInstance processInstance = process.createInstance(process.createModel()); + processInstance.start(); + + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); } } diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java index 7794b06b60e..44a3b38a017 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java @@ -32,6 +32,32 @@ import org.jbpm.bpmn2.core.Association; import org.jbpm.bpmn2.core.DataStore; import org.jbpm.bpmn2.core.Definitions; +import org.jbpm.bpmn2.data.DataInputAssociationsLazyCreatingModel; +import org.jbpm.bpmn2.data.DataInputAssociationsLazyCreatingProcess; +import org.jbpm.bpmn2.data.DataInputAssociationsModel; +import org.jbpm.bpmn2.data.DataInputAssociationsProcess; +import org.jbpm.bpmn2.data.DataInputAssociationsStringModel; +import org.jbpm.bpmn2.data.DataInputAssociationsStringNoQuotesModel; +import org.jbpm.bpmn2.data.DataInputAssociationsStringNoQuotesProcess; +import org.jbpm.bpmn2.data.DataInputAssociationsStringObjectModel; +import org.jbpm.bpmn2.data.DataInputAssociationsStringObjectProcess; +import org.jbpm.bpmn2.data.DataInputAssociationsStringProcess; +import org.jbpm.bpmn2.data.DataInputAssociationsXmlLiteralModel; +import org.jbpm.bpmn2.data.DataInputAssociationsXmlLiteralProcess; +import org.jbpm.bpmn2.data.DataObjectModel; +import org.jbpm.bpmn2.data.DataObjectProcess; +import org.jbpm.bpmn2.data.DataOutputAssociationsModel; +import org.jbpm.bpmn2.data.DataOutputAssociationsProcess; +import org.jbpm.bpmn2.data.DataOutputAssociationsXmlNodeModel; +import org.jbpm.bpmn2.data.DataOutputAssociationsXmlNodeProcess; +import org.jbpm.bpmn2.data.Evaluation2Model; +import org.jbpm.bpmn2.data.Evaluation2Process; +import org.jbpm.bpmn2.data.Evaluation3Model; +import org.jbpm.bpmn2.data.Evaluation3Process; +import org.jbpm.bpmn2.data.EvaluationModel; +import org.jbpm.bpmn2.data.EvaluationProcess; +import org.jbpm.bpmn2.data.ImportModel; +import org.jbpm.bpmn2.data.ImportProcess; import org.jbpm.bpmn2.flow.DataOutputAssociationsHumanTaskModel; import org.jbpm.bpmn2.flow.DataOutputAssociationsHumanTaskProcess; import org.jbpm.bpmn2.xml.ProcessHandler; @@ -55,21 +81,26 @@ public class DataTest extends JbpmBpmn2TestCase { @Test - public void testImport() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Import.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("Import"); - assertProcessInstanceCompleted(processInstance); + public void testImport() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = ImportProcess.newProcess(app); + ImportModel model = process.createModel(); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); } @Test - public void testDataObject() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataObject.bpmn2"); - Map params = new HashMap<>(); - params.put("employee", "UserId-12345"); - KogitoProcessInstance processInstance = kruntime.startProcess("DataObject", - params); - assertProcessInstanceCompleted(processInstance); + public void testDataObject() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = DataObjectProcess.newProcess(app); + DataObjectModel model = process.createModel(); + model.setEmployee("UserId-12345"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); } @@ -103,45 +134,47 @@ public void testAssociation() throws Exception { } @Test - public void testEvaluationProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Evaluation.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler( - "RegisterRequest", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("employee", "UserId-12345"); - KogitoProcessInstance processInstance = kruntime.startProcess("Evaluation", - params); - assertProcessInstanceCompleted(processInstance); + public void testEvaluationProcess() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "RegisterRequest", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = EvaluationProcess.newProcess(app); + EvaluationModel model = processDefinition.createModel(); + model.setEmployee("UserId-12345"); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testEvaluationProcess2() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Evaluation2.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("employee", "UserId-12345"); - KogitoProcessInstance processInstance = kruntime.startProcess("Evaluation2", params); - assertProcessInstanceCompleted(processInstance); + public void testEvaluationProcess2() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = Evaluation2Process.newProcess(app); + Evaluation2Model model = processDefinition.createModel(); + model.setEmployee("UserId-12345"); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testEvaluationProcess3() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Evaluation3.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler( - "RegisterRequest", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("employee", "john2"); - KogitoProcessInstance processInstance = kruntime.startProcess("Evaluation3", - params); - assertProcessInstanceCompleted(processInstance); + public void testEvaluationProcess3() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "RegisterRequest", new SystemOutWorkItemHandler()); + + org.kie.kogito.process.Process processDefinition = Evaluation3Process.newProcess(app); + Evaluation3Model model = processDefinition.createModel(); + model.setEmployee("john2"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -166,157 +199,151 @@ public void testXpathExpression() throws Exception { @Test public void testDataInputAssociations() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataInputAssociations.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - @Override - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } - } + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + assertThat(workItem.getParameter("coId")).isEqualTo("hello world"); + } + }); - @Override - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - assertThat(workItem.getParameter("coId")).isEqualTo("hello world"); - } - }); Document document = DocumentBuilderFactory .newInstance() .newDocumentBuilder() - .parse(new ByteArrayInputStream("" - .getBytes())); - Map params = new HashMap<>(); - params.put("instanceMetadata", document.getFirstChild()); - KogitoProcessInstance processInstance = kruntime.startProcess("DataInputAssociations", params); + .parse(new ByteArrayInputStream("".getBytes())); + + org.kie.kogito.process.Process processDefinition = DataInputAssociationsProcess.newProcess(app); + DataInputAssociationsModel model = processDefinition.createModel(); + model.setInstanceMetadata(document.getFirstChild()); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } @Test - public void testDataInputAssociationsWithStringObject() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataInputAssociationsStringObject.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - - @Override - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } - - @Override - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - assertThat(workItem.getParameter("coId")).isEqualTo("hello"); - } - - }); - Map params = new HashMap<>(); - params.put("instanceMetadata", "hello"); - KogitoProcessInstance processInstance = kruntime.startProcess("DataInputAssociationsStringObject", params); - + public void testDataInputAssociationsWithStringObject() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + assertThat(workItem.getParameter("coId")).isEqualTo("hello"); + } + }); + + org.kie.kogito.process.Process processDefinition = DataInputAssociationsStringObjectProcess.newProcess(app); + DataInputAssociationsStringObjectModel model = processDefinition.createModel(); + model.setInstanceMetadata("hello"); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } /** * TODO testDataInputAssociationsWithLazyLoading */ @Test - @Disabled - public void testDataInputAssociationsWithLazyLoading() - throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataInputAssociationsLazyCreating.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } - - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - Element coIdParamObj = (Element) workItem.getParameter("coId"); - assertThat(coIdParamObj.getNodeName()).isEqualTo("mydoc"); - assertThat(coIdParamObj.getFirstChild().getNodeName()).isEqualTo("mynode"); - assertThat(coIdParamObj.getFirstChild().getFirstChild().getNodeName()).isEqualTo("user"); - assertThat(coIdParamObj.getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue()).isEqualTo("hello world"); - } + public void testDataInputAssociationsWithLazyLoading() throws Exception { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + Element coIdParamObj = (Element) workItem.getParameter("coId"); + assertThat(coIdParamObj.getNodeName()).isEqualTo("mydoc"); + assertThat(coIdParamObj.getFirstChild().getNodeName()).isEqualTo("mynode"); + assertThat(coIdParamObj.getFirstChild().getFirstChild().getNodeName()).isEqualTo("user"); + assertThat(coIdParamObj.getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue()).isEqualTo("hello world"); + } + }); - }); Document document = DocumentBuilderFactory .newInstance() .newDocumentBuilder() - .parse(new ByteArrayInputStream("" - .getBytes())); + .parse(new ByteArrayInputStream("".getBytes())); Map params = new HashMap<>(); params.put("instanceMetadata", document.getFirstChild()); - KogitoProcessInstance processInstance = kruntime.startProcess("DataInputAssociationsLazyCreating", params); + org.kie.kogito.process.Process processDefinition = DataInputAssociationsLazyCreatingProcess.newProcess(app); + DataInputAssociationsLazyCreatingModel model = processDefinition.createModel(); + model.setInstanceMetadata(document.getFirstChild()); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } @Test - public void testDataInputAssociationsWithString() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataInputAssociationsString.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { + public void testDataInputAssociationsWithString() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + assertThat(workItem.getParameter("coId")).isEqualTo("hello"); + } + }); - } - - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - assertThat(workItem.getParameter("coId")).isEqualTo("hello"); - } - - }); - KogitoProcessInstance processInstance = kruntime.startProcess("DataInputAssociationsString"); + org.kie.kogito.process.Process processDefinition = DataInputAssociationsStringProcess.newProcess(app); + DataInputAssociationsStringModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } @Test - public void testDataInputAssociationsWithStringWithoutQuotes() - throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataInputAssociationsStringNoQuotes.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } + public void testDataInputAssociationsWithStringWithoutQuotes() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - assertThat(workItem.getParameter("coId")).isEqualTo("hello"); - } + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + assertThat(workItem.getParameter("coId")).isEqualTo("hello"); + } + }); - }); - KogitoProcessInstance processInstance = kruntime.startProcess("DataInputAssociationsStringNoQuotes"); + org.kie.kogito.process.Process processDefinition = DataInputAssociationsStringNoQuotesProcess.newProcess(app); + DataInputAssociationsStringNoQuotesModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } @Test - public void testDataInputAssociationsWithXMLLiteral() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataInputAssociationsXmlLiteral.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } - - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - assertThat(((org.w3c.dom.Node) workItem.getParameter("coId")).getNodeName()).isEqualTo("id"); - assertThat(((org.w3c.dom.Node) workItem.getParameter("coId")).getFirstChild().getTextContent()).isEqualTo("some text"); - } - - }); - KogitoProcessInstance processInstance = kruntime.startProcess("DataInputAssociationsXmlLiteral"); - + public void testDataInputAssociationsWithXMLLiteral() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + assertThat(((org.w3c.dom.Node) workItem.getParameter("coId")).getNodeName()).isEqualTo("id"); + assertThat(((org.w3c.dom.Node) workItem.getParameter("coId")).getFirstChild().getTextContent()).isEqualTo("some text"); + } + }); + + org.kie.kogito.process.Process processDefinition = DataInputAssociationsXmlLiteralProcess.newProcess(app); + DataInputAssociationsXmlLiteralModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } /** @@ -359,118 +386,100 @@ public void executeWorkItem(KogitoWorkItem workItem, } @Test - public void testDataOutputAssociationsforHumanTask() throws Exception { + public void testDataOutputAssociationsforHumanTask() { Application app = ProcessTestHelper.newApplication(); - ProcessTestHelper.registerHandler(app, "Human Task", - new KogitoWorkItemHandler() { - - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } - - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - DocumentBuilder builder; - try { - builder = factory.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } - final Map results = new HashMap<>(); - - // process metadata - org.w3c.dom.Document processMetadaDoc = builder - .newDocument(); - org.w3c.dom.Element processMetadata = processMetadaDoc - .createElement("previoustasksowner"); - processMetadaDoc.appendChild(processMetadata); - // org.w3c.dom.Element procElement = - // processMetadaDoc.createElement("previoustasksowner"); - processMetadata - .setAttribute("primaryname", "my_result"); - // processMetadata.appendChild(procElement); - results.put("output", processMetadata); - - mgr.completeWorkItem(workItem.getStringId(), results); - } - - }); - - org.kie.kogito.process.Process definition = DataOutputAssociationsHumanTaskProcess.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); - + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder; + try { + builder = factory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + final Map results = new HashMap<>(); + // process metadata + org.w3c.dom.Document processMetadaDoc = builder.newDocument(); + org.w3c.dom.Element processMetadata = processMetadaDoc.createElement("previoustasksowner"); + processMetadaDoc.appendChild(processMetadata); + processMetadata.setAttribute("primaryname", "my_result"); + results.put("output", processMetadata); + mgr.completeWorkItem(workItem.getStringId(), results); + } + }); + + org.kie.kogito.process.Process processDefinition = DataOutputAssociationsHumanTaskProcess.newProcess(app); + DataOutputAssociationsHumanTaskModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); instance.start(); } @Test - public void testDataOutputAssociations() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataOutputAssociations.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } - - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - try { - Document document = DocumentBuilderFactory - .newInstance() - .newDocumentBuilder() - .parse(new ByteArrayInputStream( - "" - .getBytes())); - Map params = new HashMap<>(); - params.put("output", document.getFirstChild()); - mgr.completeWorkItem(workItem.getStringId(), params); - } catch (Throwable e) { - throw new RuntimeException(e); - } - - } - - }); - KogitoProcessInstance processInstance = kruntime.startProcess("DataOutputAssociations"); - + public void testDataOutputAssociations() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + try { + Document document = DocumentBuilderFactory + .newInstance() + .newDocumentBuilder() + .parse(new ByteArrayInputStream("".getBytes())); + Map params = new HashMap<>(); + params.put("output", document.getFirstChild()); + mgr.completeWorkItem(workItem.getStringId(), params); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + }); + + org.kie.kogito.process.Process processDefinition = DataOutputAssociationsProcess.newProcess(app); + DataOutputAssociationsModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } @Test - public void testDataOutputAssociationsXmlNode() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataOutputAssociationsXmlNode.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new KogitoWorkItemHandler() { - - public void abortWorkItem(KogitoWorkItem manager, - KogitoWorkItemManager mgr) { - - } - - public void executeWorkItem(KogitoWorkItem workItem, - KogitoWorkItemManager mgr) { - try { - Document document = DocumentBuilderFactory - .newInstance() - .newDocumentBuilder() - .parse(new ByteArrayInputStream( - "" - .getBytes())); - Map params = new HashMap<>(); - params.put("output", document.getFirstChild()); - mgr.completeWorkItem(workItem.getStringId(), params); - } catch (Throwable e) { - throw new RuntimeException(e); - } - - } - - }); - KogitoProcessInstance processInstance = kruntime.startProcess("DataOutputAssociationsXmlNode"); - + public void testDataOutputAssociationsXmlNode() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new KogitoWorkItemHandler() { + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + } + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) { + try { + Document document = DocumentBuilderFactory + .newInstance() + .newDocumentBuilder() + .parse(new ByteArrayInputStream("".getBytes())); + Map params = new HashMap<>(); + params.put("output", document.getFirstChild()); + mgr.completeWorkItem(workItem.getStringId(), params); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + }); + + org.kie.kogito.process.Process processDefinition = DataOutputAssociationsXmlNodeProcess.newProcess(app); + DataOutputAssociationsXmlNodeModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); } @Test diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EndEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EndEventTest.java index ee949594ca3..bfed716fa30 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EndEventTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EndEventTest.java @@ -19,58 +19,83 @@ package org.jbpm.bpmn2; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import org.jbpm.bpmn2.escalation.EscalationEndEventModel; +import org.jbpm.bpmn2.escalation.EscalationEndEventProcess; +import org.jbpm.bpmn2.event.EndEventSignalWithDataModel; +import org.jbpm.bpmn2.event.EndEventSignalWithDataProcess; +import org.jbpm.bpmn2.event.ErrorEndEventModel; +import org.jbpm.bpmn2.event.ErrorEndEventProcess; import org.jbpm.bpmn2.event.MessageEndEventModel; import org.jbpm.bpmn2.event.MessageEndEventProcess; +import org.jbpm.bpmn2.event.OnEntryExitDesignerScriptProcessModel; +import org.jbpm.bpmn2.event.OnEntryExitDesignerScriptProcessProcess; +import org.jbpm.bpmn2.event.OnEntryExitMixedNamespacedScriptProcessModel; +import org.jbpm.bpmn2.event.OnEntryExitMixedNamespacedScriptProcessProcess; +import org.jbpm.bpmn2.event.OnEntryExitNamespacedScriptProcessModel; +import org.jbpm.bpmn2.event.OnEntryExitNamespacedScriptProcessProcess; +import org.jbpm.bpmn2.event.OnEntryExitScriptProcessModel; +import org.jbpm.bpmn2.event.OnEntryExitScriptProcessProcess; +import org.jbpm.bpmn2.event.ParallelSplitModel; +import org.jbpm.bpmn2.event.ParallelSplitProcess; +import org.jbpm.bpmn2.event.ParallelSplitTerminateModel; +import org.jbpm.bpmn2.event.ParallelSplitTerminateProcess; +import org.jbpm.bpmn2.event.SignalEndEventModel; +import org.jbpm.bpmn2.event.SignalEndEventProcess; +import org.jbpm.bpmn2.event.SubprocessWithParallelSplitTerminateModel; +import org.jbpm.bpmn2.event.SubprocessWithParallelSplitTerminateProcess; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.test.utils.ProcessTestHelper; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.kie.kogito.Application; import org.kie.kogito.event.impl.MessageProducer; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; +import org.kie.kogito.process.ProcessInstance; +import org.kie.kogito.process.impl.Sig; import static org.assertj.core.api.Assertions.assertThat; public class EndEventTest extends JbpmBpmn2TestCase { @Test - public void testImplicitEndParallel() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-ParallelSplit.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("ParallelSplit"); - assertProcessInstanceCompleted(processInstance); - + public void testImplicitEndParallel() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = ParallelSplitProcess.newProcess(app); + ProcessInstance processInstance = process.createInstance(process.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); } @Test - public void testErrorEndEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-ErrorEndEvent.bpmn2"); - KogitoProcessInstance processInstance = kruntime - .startProcess("ErrorEndEvent"); - assertProcessInstanceAborted(processInstance); - assertThat(((org.jbpm.process.instance.ProcessInstance) processInstance).getOutcome()).isEqualTo("error"); - + public void testErrorEndEventProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = ErrorEndEventProcess.newProcess(app); + ProcessInstance processInstance = process.createInstance(process.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED); + assertThat(((org.kie.kogito.process.impl.AbstractProcessInstance) processInstance) + .internalGetProcessInstance().getOutcome()).isEqualTo("error"); } @Test - public void testEscalationEndEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/escalation/BPMN2-EscalationEndEvent.bpmn2"); - KogitoProcessInstance processInstance = kruntime - .startProcess("EscalationEndEvent"); - assertProcessInstanceAborted(processInstance); + public void testEscalationEndEventProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = EscalationEndEventProcess.newProcess(app); + ProcessInstance processInstance = process.createInstance(process.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_ABORTED); } @Test - public void testSignalEnd() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-SignalEndEvent.bpmn2"); - Map params = new HashMap<>(); - params.put("x", "MyValue"); - kruntime.startProcess("SignalEndEvent", params); - + public void testSignalEnd() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = SignalEndEventProcess.newProcess(app); + SignalEndEventModel model = process.createModel(); + model.setX("MyValue"); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); } @Test @@ -94,94 +119,91 @@ public void produce(KogitoProcessInstance pi, String eventData) { } @Test - @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067") - public void testOnEntryExitScript() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-OnEntryExitScriptProcess.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new SystemOutWorkItemHandler()); + public void testOnEntryExitScript() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "MyTask", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process process = OnEntryExitScriptProcessProcess.newProcess(app); + OnEntryExitScriptProcessModel model = process.createModel(); List myList = new ArrayList<>(); - kruntime.getKieSession().setGlobal("list", myList); - KogitoProcessInstance processInstance = kruntime - .startProcess("OnEntryExitScriptProcess"); - assertProcessInstanceCompleted(processInstance); + model.setList(myList); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); assertThat(myList).hasSize(4); - } @Test - @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067") - public void testOnEntryExitNamespacedScript() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-OnEntryExitNamespacedScriptProcess.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new SystemOutWorkItemHandler()); + public void testOnEntryExitNamespacedScript() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "MyTask", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process process = OnEntryExitNamespacedScriptProcessProcess.newProcess(app); + OnEntryExitNamespacedScriptProcessModel model = process.createModel(); List myList = new ArrayList<>(); - kruntime.getKieSession().setGlobal("list", myList); - KogitoProcessInstance processInstance = kruntime - .startProcess("OnEntryExitScriptProcess"); - assertProcessInstanceCompleted(processInstance); + model.setList(myList); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); assertThat(myList).hasSize(4); - } @Test - @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067") - public void testOnEntryExitMixedNamespacedScript() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-OnEntryExitMixedNamespacedScriptProcess.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new SystemOutWorkItemHandler()); + public void testOnEntryExitMixedNamespacedScript() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "MyTask", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process process = OnEntryExitMixedNamespacedScriptProcessProcess.newProcess(app); + OnEntryExitMixedNamespacedScriptProcessModel model = process.createModel(); List myList = new ArrayList<>(); - kruntime.getKieSession().setGlobal("list", myList); - KogitoProcessInstance processInstance = kruntime - .startProcess("OnEntryExitScriptProcess"); - assertProcessInstanceCompleted(processInstance); + model.setList(myList); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); assertThat(myList).hasSize(4); - } @Test - @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067") - public void testOnEntryExitScriptDesigner() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-OnEntryExitDesignerScriptProcess.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new SystemOutWorkItemHandler()); + public void testOnEntryExitScriptDesigner() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "MyTask", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process process = OnEntryExitDesignerScriptProcessProcess.newProcess(app); + OnEntryExitDesignerScriptProcessModel model = process.createModel(); List myList = new ArrayList<>(); - kruntime.getKieSession().setGlobal("list", myList); - KogitoProcessInstance processInstance = kruntime - .startProcess("OnEntryExitScriptProcess"); - assertProcessInstanceCompleted(processInstance); + model.setList(myList); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(myList).hasSize(4); - } @Test - public void testTerminateWithinSubprocessEnd() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event//BPMN2-SubprocessWithParallelSplitTerminate.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("SubprocessWithParallelSplitTerminate"); - - kruntime.signalEvent("signal1", null, processInstance.getStringId()); - - assertProcessInstanceCompleted(processInstance); - + public void testTerminateWithinSubprocessEnd() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = SubprocessWithParallelSplitTerminateProcess.newProcess(app); + SubprocessWithParallelSplitTerminateModel model = process.createModel(); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + processInstance.send(Sig.of("signal1", null)); + assertThat(processInstance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testTerminateEnd() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-ParallelSplitTerminate.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("ParallelSplitTerminate"); - - kruntime.signalEvent("Signal 1", null, processInstance.getStringId()); - - assertProcessInstanceCompleted(processInstance); - + public void testTerminateEnd() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = ParallelSplitTerminateProcess.newProcess(app); + ParallelSplitTerminateModel model = process.createModel(); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + processInstance.send(Sig.of("Signal 1", null)); + assertThat(processInstance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testSignalEndWithData() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-EndEventSignalWithData.bpmn2"); - Map params = new HashMap<>(); - KogitoProcessInstance processInstance = kruntime.startProcess("EndEventSignalWithData", params); - - assertProcessInstanceCompleted(processInstance); + public void testSignalEndWithData() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = EndEventSignalWithDataProcess.newProcess(app); + EndEventSignalWithDataModel model = process.createModel(); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); } } diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java index d73e2b92bd3..213fbb95043 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java @@ -24,12 +24,28 @@ import java.util.List; import java.util.Map; +import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerByErrorCodeModel; +import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerByErrorCodeProcess; +import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRefModel; +import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRefProcess; +import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRefModel; +import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRefProcess; +import org.jbpm.bpmn2.error.BoundaryErrorEventStructureRefModel; +import org.jbpm.bpmn2.error.BoundaryErrorEventStructureRefProcess; import org.jbpm.bpmn2.error.EndErrorModel; import org.jbpm.bpmn2.error.EndErrorProcess; +import org.jbpm.bpmn2.error.EndErrorWithEventSubprocessModel; +import org.jbpm.bpmn2.error.EndErrorWithEventSubprocessProcess; import org.jbpm.bpmn2.error.ErrorBoundaryEventOnServiceTaskModel; import org.jbpm.bpmn2.error.ErrorBoundaryEventOnServiceTaskProcess; import org.jbpm.bpmn2.error.ErrorVariableModel; import org.jbpm.bpmn2.error.ErrorVariableProcess; +import org.jbpm.bpmn2.error.EventSubProcessErrorWithScriptModel; +import org.jbpm.bpmn2.error.EventSubProcessErrorWithScriptProcess; +import org.jbpm.bpmn2.error.EventSubprocessErrorHandlingWithErrorCodeModel; +import org.jbpm.bpmn2.error.EventSubprocessErrorHandlingWithErrorCodeProcess; +import org.jbpm.bpmn2.error.EventSubprocessErrorModel; +import org.jbpm.bpmn2.error.EventSubprocessErrorProcess; import org.jbpm.bpmn2.event.BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRefModel; import org.jbpm.bpmn2.event.BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRefProcess; import org.jbpm.bpmn2.event.BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithoutStructureRefModel; @@ -47,11 +63,9 @@ import org.jbpm.bpmn2.subprocess.ExceptionServiceProcessSignallingModel; import org.jbpm.bpmn2.subprocess.ExceptionServiceProcessSignallingProcess; import org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener; -import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.test.utils.EventTrackerProcessListener; import org.jbpm.test.utils.ProcessTestHelper; -import org.jbpm.workflow.instance.WorkflowProcessInstance; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.kie.api.event.process.ProcessNodeLeftEvent; @@ -69,43 +83,50 @@ import org.kie.kogito.internal.process.runtime.KogitoWorkItem; import org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler; import org.kie.kogito.internal.process.runtime.KogitoWorkItemManager; +import org.kie.kogito.process.ProcessInstance; import org.kie.kogito.process.workitem.WorkItemExecutionException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIterable; public class ErrorEventTest extends JbpmBpmn2TestCase { @Test - public void testEventSubprocessError() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-EventSubprocessError.bpmn2"); - final List executednodes = new ArrayList<>(); - KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { + public void testEventSubprocessError() { + Application app = ProcessTestHelper.newApplication(); + final List executedNodes = new ArrayList<>(); + KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (event.getNodeInstance().getNodeName() - .equals("Script Task 1")) { - executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId()); + if (event.getNodeInstance().getNodeName().equals("Script Task 1")) { + executedNodes.add(event.getNodeInstance().getId()); } } - }; - - kruntime.getProcessEventManager().addEventListener(listener); + EventTrackerProcessListener eventTrackerProcessListener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, listener); + ProcessTestHelper.registerProcessEventListener(app, eventTrackerProcessListener); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - KogitoProcessInstance processInstance = kruntime.startProcess("EventSubprocessError"); - assertProcessInstanceActive(processInstance); - kruntime.getProcessEventManager().addEventListener(listener); - + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = EventSubprocessErrorProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub"); - assertThat(executednodes).hasSize(1); - + processInstance.completeWorkItem(workItem.getStringId(), null); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(executedNodes).hasSize(1); + List trackedNodes = eventTrackerProcessListener.tracked().stream().map(event -> event.getNodeInstance().getNodeName()).toList(); + assertThatIterable(trackedNodes).contains( + "start", + "User Task 1", + "end", + "Sub Process 1", + "start-sub", + "Script Task 1", + "end-sub"); } @Test @@ -151,28 +172,34 @@ public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manager @Test public void testEventSubprocessErrorWithErrorCode() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-EventSubprocessErrorHandlingWithErrorCode.bpmn2"); - final List executednodes = new ArrayList<>(); + Application app = ProcessTestHelper.newApplication(); + final List executedNodes = new ArrayList<>(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { - @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (event.getNodeInstance().getNodeName() - .equals("Script2")) { - executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId()); + if (event.getNodeInstance().getNodeName().equals("Script2")) { + executedNodes.add(event.getNodeInstance().getId()); } } - }; - kruntime.getProcessEventManager().addEventListener(listener); - - KogitoProcessInstance processInstance = kruntime.startProcess("EventSubprocessErrorHandlingWithErrorCode"); - - assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "Script1", "starterror", "Script2", "end2", "eventsubprocess"); - assertProcessVarValue(processInstance, "CapturedException", "java.lang.RuntimeException: XXX"); - assertThat(executednodes).hasSize(1); - + EventTrackerProcessListener eventTrackerProcessListener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, listener); + ProcessTestHelper.registerProcessEventListener(app, eventTrackerProcessListener); + org.kie.kogito.process.Process processDefinition = EventSubprocessErrorHandlingWithErrorCodeProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED); + assertThat(eventTrackerProcessListener.tracked()) + .anyMatch(ProcessTestHelper.left("start")) + .anyMatch(ProcessTestHelper.left("Script1")) + .anyMatch(ProcessTestHelper.left("starterror")) + .anyMatch(ProcessTestHelper.left("Script2")) + .anyMatch(ProcessTestHelper.left("end2")) + .anyMatch(ProcessTestHelper.left("eventsubprocess")); + + assertThat(processInstance.variables().getCapturedException()).isInstanceOf(RuntimeException.class); + assertThat(((RuntimeException) processInstance.variables().getCapturedException()).getMessage()).isEqualTo("XXX"); + assertThat(executedNodes).hasSize(1); } @Test @@ -201,17 +228,6 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { } - @Test - public void testErrorBoundaryEvent() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-ErrorBoundaryEventInterrupting.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new DoNothingWorkItemHandler()); - KogitoProcessInstance processInstance = kruntime - .startProcess("ErrorBoundaryEventInterrupting"); - assertProcessInstanceFinished(processInstance, kruntime); - - } - @Test public void testErrorBoundaryEventOnTask() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-ErrorBoundaryEventOnTask.bpmn2"); @@ -390,14 +406,15 @@ public void testSignallingExceptionServiceTask() throws Exception { @Test public void testEventSubProcessErrorWithScript() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-EventSubProcessErrorWithScript.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Request Handler", new SignallingTaskHandlerDecorator(ExceptionOnPurposeHandler.class, "Error-90277")); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Error Handler", new SystemOutWorkItemHandler()); - KogitoProcessInstance processInstance = kruntime.startProcess("EventSubProcessErrorWithScript"); - - assertProcessInstanceAborted(processInstance); - assertThat(((WorkflowProcessInstance) processInstance).getOutcome()).isEqualTo("90277"); - + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Request Handler", new SignallingTaskHandlerDecorator(new ExceptionOnPurposeHandler(), "Error-90277")); + ProcessTestHelper.registerHandler(app, "Error Handler", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = EventSubProcessErrorWithScriptProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED); + assertThat(((org.kie.kogito.process.impl.AbstractProcessInstance) processInstance) + .internalGetProcessInstance().getOutcome()).isEqualTo("90277"); } @Test @@ -429,37 +446,42 @@ public void testErrorBoundaryEventOnExit() throws Exception { } @Test - public void testBoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRef() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRef.bpmn2"); + public void testBoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRef() { + Application app = ProcessTestHelper.newApplication(); ExceptionWorkItemHandler handler = new ExceptionWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); - - KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRef"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + org.kie.kogito.process.Process processDefinition = + BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRefProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testBoundaryErrorEventDefaultHandlerWithWorkItemExecutionError() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-BoundaryErrorEventDefaultHandlerByErrorCode.bpmn2"); + public void testBoundaryErrorEventDefaultHandlerWithWorkItemExecutionError() { + Application app = ProcessTestHelper.newApplication(); WorkItemExecutionErrorWorkItemHandler handler = new WorkItemExecutionErrorWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); - - KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventDefaultHandlerByErrorCode"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + org.kie.kogito.process.Process processDefinition = BoundaryErrorEventDefaultHandlerByErrorCodeProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testBoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRef() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-BoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRef.bpmn2"); + public void testBoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRef() { + Application app = ProcessTestHelper.newApplication(); ExceptionWorkItemHandler handler = new ExceptionWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); - - KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRef"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ERROR); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + org.kie.kogito.process.Process definition = + BoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRefProcess.newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ERROR); } @Test - public void testBoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRef() throws Exception { + public void testBoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRef() { Application app = ProcessTestHelper.newApplication(); EventTrackerProcessListener listener = new EventTrackerProcessListener(); ExceptionWorkItemHandler handler = new ExceptionWorkItemHandler(); @@ -513,25 +535,41 @@ public void testBoundaryErrorEventSubProcessExceptionMapping() throws Exception } @Test - public void testBoundaryErrorEventStructureRef() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-BoundaryErrorEventStructureRef.bpmn2"); + public void testBoundaryErrorEventStructureRef() { + Application app = ProcessTestHelper.newApplication(); ExceptionWorkItemHandler handler = new ExceptionWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); - - KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventStructureRef"); - - assertNodeTriggered(processInstance.getStringId(), "Start", "User Task", "MyBoundaryErrorEvent"); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + final List executedNodes = new ArrayList<>(); + KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { + @Override + public void afterNodeLeft(ProcessNodeLeftEvent event) { + executedNodes.add(event.getNodeInstance().getNodeName()); + } + }; + EventTrackerProcessListener eventTrackerProcessListener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, listener); + ProcessTestHelper.registerProcessEventListener(app, eventTrackerProcessListener); + org.kie.kogito.process.Process processDefinition = BoundaryErrorEventStructureRefProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(eventTrackerProcessListener.tracked()) + .anyMatch(ProcessTestHelper.left("Start")) + .anyMatch(ProcessTestHelper.left("User Task")) + .anyMatch(ProcessTestHelper.left("MyBoundaryErrorEvent")); } @Test - public void testEndErrorWithSubprocess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-EndErrorWithEventSubprocess.bpmn2"); - - KogitoProcessInstance processInstance = kruntime.startProcess("EndErrorWithEventSubprocess"); - - assertNodeTriggered(processInstance.getStringId(), "start", "task", "subprocess-task"); - - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testEndErrorWithSubprocess() { + Application app = ProcessTestHelper.newApplication(); + EventTrackerProcessListener tracker = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, tracker); + org.kie.kogito.process.Process processDefinition = EndErrorWithEventSubprocessProcess.newProcess(app); + ProcessInstance processInstance = processDefinition.createInstance(processDefinition.createModel()); + processInstance.start(); + assertThat(tracker.tracked()).anyMatch(ProcessTestHelper.triggered("start")); + assertThat(tracker.tracked()).anyMatch(ProcessTestHelper.triggered("task")); + assertThat(tracker.tracked()).anyMatch(ProcessTestHelper.triggered("subprocess-task")); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java index 5193317975b..f6568f8df9a 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java @@ -20,14 +20,22 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import org.jbpm.bpmn2.escalation.EscalationBoundaryEventModel; +import org.jbpm.bpmn2.escalation.EscalationBoundaryEventProcess; import org.jbpm.bpmn2.escalation.EscalationBoundaryEventWithTaskModel; import org.jbpm.bpmn2.escalation.EscalationBoundaryEventWithTaskProcess; +import org.jbpm.bpmn2.escalation.EscalationEndEventHandlingModel; +import org.jbpm.bpmn2.escalation.EscalationEndEventHandlingProcess; +import org.jbpm.bpmn2.escalation.EscalationEndEventModel; +import org.jbpm.bpmn2.escalation.EscalationEndEventProcess; +import org.jbpm.bpmn2.escalation.EscalationWithDataMappingModel; +import org.jbpm.bpmn2.escalation.EscalationWithDataMappingProcess; import org.jbpm.bpmn2.escalation.EventSubprocessEscalationModel; import org.jbpm.bpmn2.escalation.EventSubprocessEscalationProcess; +import org.jbpm.bpmn2.escalation.IntermediateThrowEventEscalationModel; +import org.jbpm.bpmn2.escalation.IntermediateThrowEventEscalationProcess; import org.jbpm.bpmn2.escalation.MultiEscalationModel; import org.jbpm.bpmn2.escalation.MultiEscalationProcess; import org.jbpm.bpmn2.escalation.TopLevelEscalationModel; @@ -162,10 +170,14 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { } @Test - public void testEscalationBoundaryEvent() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/escalation/BPMN2-EscalationBoundaryEvent.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("EscalationBoundaryEvent"); - assertProcessInstanceCompleted(processInstance); + public void testEscalationBoundaryEvent() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = EscalationBoundaryEventProcess.newProcess(app); + + EscalationBoundaryEventModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -192,10 +204,13 @@ public void testEscalationBoundaryEventInterruptsTask() throws Exception { } @Test - public void testEscalationIntermediateThrowEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/escalation/BPMN2-IntermediateThrowEventEscalation.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateThrowEventEscalation"); - assertProcessInstanceAborted(processInstance); + public void testEscalationIntermediateThrowEventProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = IntermediateThrowEventEscalationProcess.newProcess(app); + IntermediateThrowEventEscalationModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ABORTED); } @Test @@ -268,29 +283,37 @@ public void testNonInterruptingEscalationBoundaryEventOnTask() throws Exception } @Test - public void testEscalationEndEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/escalation/BPMN2-EscalationEndEvent.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("EscalationEndEvent"); - assertProcessInstanceAborted(processInstance.getStringId(), kruntime); + public void testEscalationEndEventProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = EscalationEndEventProcess.newProcess(app); + EscalationEndEventModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ABORTED); } @Test - public void testEscalationBoundaryEventAndIntermediate() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/escalation/BPMN2-EscalationWithDataMapping.bpmn2"); - Map sessionArgs = new HashMap<>(); - sessionArgs.put("Property_2", new java.lang.RuntimeException()); - KogitoProcessInstance processInstance = kruntime.startProcess("EscalationWithDataMapping", sessionArgs); - assertProcessInstanceCompleted(processInstance); - assertProcessVarValue(processInstance, "Property_3", "java.lang.RuntimeException"); + public void testEscalationBoundaryEventAndIntermediate() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = EscalationWithDataMappingProcess.newProcess(app); + EscalationWithDataMappingModel model = processDefinition.createModel(); + model.setProperty_2("java.lang.RuntimeException"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(instance.variables().getProperty_3()).isEqualTo("java.lang.RuntimeException"); } @Test - public void testHandledEscalationEndEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/escalation/BPMN2-EscalationEndEventHandling.bpmn2"); + public void testHandledEscalationEndEventProcess() { + Application app = ProcessTestHelper.newApplication(); - Map parameters = new HashMap<>(); - parameters.put("hello", 70); - KogitoProcessInstance processInstance = kruntime.startProcess("EscalationEndEventHandling", parameters); - assertProcessInstanceFinished(processInstance, kruntime); + org.kie.kogito.process.Process processDefinition = EscalationEndEventHandlingProcess.newProcess(app); + EscalationEndEventHandlingModel model = processDefinition.createModel(); + model.setHello(70); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } } diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java index 2e0093de5e6..d38604d1a24 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java @@ -31,6 +31,8 @@ import javax.xml.parsers.DocumentBuilderFactory; +import org.jbpm.bpmn2.activity.ScriptTaskModel; +import org.jbpm.bpmn2.activity.ScriptTaskProcess; import org.jbpm.bpmn2.adhoc.AdHocSubProcessAutoCompleteExpressionModel; import org.jbpm.bpmn2.adhoc.AdHocSubProcessAutoCompleteExpressionProcess; import org.jbpm.bpmn2.adhoc.AdHocSubProcessAutoCompleteModel; @@ -38,12 +40,49 @@ import org.jbpm.bpmn2.adhoc.AdHocSubProcessEmptyCompleteExpressionProcess; import org.jbpm.bpmn2.adhoc.AdHocTerminateEndEventModel; import org.jbpm.bpmn2.adhoc.AdHocTerminateEndEventProcess; +import org.jbpm.bpmn2.data.DataObjectModel; +import org.jbpm.bpmn2.data.DataObjectProcess; +import org.jbpm.bpmn2.data.Evaluation2Model; +import org.jbpm.bpmn2.data.Evaluation2Process; +import org.jbpm.bpmn2.data.Evaluation3Model; +import org.jbpm.bpmn2.data.Evaluation3Process; +import org.jbpm.bpmn2.data.EvaluationModel; +import org.jbpm.bpmn2.data.EvaluationProcess; +import org.jbpm.bpmn2.event.ErrorEndEventModel; +import org.jbpm.bpmn2.event.ErrorEndEventProcess; +import org.jbpm.bpmn2.event.SignalEndEventModel; +import org.jbpm.bpmn2.event.SignalEndEventProcess; +import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalModel; +import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalProcess; +import org.jbpm.bpmn2.flow.ExclusiveSplitModel; +import org.jbpm.bpmn2.flow.ExclusiveSplitProcess; +import org.jbpm.bpmn2.flow.InclusiveSplitModel; +import org.jbpm.bpmn2.flow.InclusiveSplitProcess; +import org.jbpm.bpmn2.flow.MinimalModel; +import org.jbpm.bpmn2.flow.MinimalProcess; +import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalModel; +import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalProcess; +import org.jbpm.bpmn2.flow.MinimalWithGraphicalModel; +import org.jbpm.bpmn2.flow.MinimalWithGraphicalProcess; +import org.jbpm.bpmn2.flow.SubProcessModel; +import org.jbpm.bpmn2.flow.SubProcessProcess; +import org.jbpm.bpmn2.flow.UserTaskModel; +import org.jbpm.bpmn2.flow.UserTaskProcess; import org.jbpm.bpmn2.handler.ReceiveTaskHandler; import org.jbpm.bpmn2.handler.SendTaskHandler; +import org.jbpm.bpmn2.intermediate.EventBasedSplit4Model; +import org.jbpm.bpmn2.intermediate.EventBasedSplit4Process; +import org.jbpm.bpmn2.intermediate.EventBasedSplitModel; +import org.jbpm.bpmn2.intermediate.EventBasedSplitProcess; import org.jbpm.bpmn2.intermediate.IntermediateThrowEventMessageModel; import org.jbpm.bpmn2.intermediate.IntermediateThrowEventMessageProcess; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; +import org.jbpm.bpmn2.subprocess.CallActivityModel; +import org.jbpm.bpmn2.subprocess.CallActivityProcess; +import org.jbpm.bpmn2.subprocess.CallActivitySubProcessProcess; +import org.jbpm.bpmn2.task.SendTaskModel; +import org.jbpm.bpmn2.task.SendTaskProcess; import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.process.instance.impl.humantask.InternalHumanTaskWorkItem; @@ -57,11 +96,14 @@ import org.kie.api.io.Resource; import org.kie.internal.io.ResourceFactory; import org.kie.kogito.Application; +import org.kie.kogito.auth.SecurityPolicy; import org.kie.kogito.event.impl.MessageProducer; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance; +import org.kie.kogito.process.ProcessInstance; +import org.kie.kogito.process.impl.Sig; import org.w3c.dom.Document; import static org.assertj.core.api.Assertions.assertThat; @@ -70,103 +112,120 @@ public class StandaloneBPMNProcessTest extends JbpmBpmn2TestCase { @Test - public void testMinimalProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcess.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("Minimal"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testMinimalProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process minimalProcess = MinimalProcess.newProcess(app); + MinimalModel model = minimalProcess.createModel(); + org.kie.kogito.process.ProcessInstance instance = minimalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testMinimalProcessWithGraphical() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessWithGraphical.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("MinimalWithGraphical"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testMinimalProcessWithGraphical() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process minimalWithGraphicalProcess = MinimalWithGraphicalProcess.newProcess(app); + MinimalWithGraphicalModel model = minimalWithGraphicalProcess.createModel(); + org.kie.kogito.process.ProcessInstance instance = minimalWithGraphicalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testMinimalProcessWithDIGraphical() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessWithDIGraphical.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("MinimalWithDIGraphical"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testMinimalProcessWithDIGraphical() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = MinimalWithDIGraphicalProcess.newProcess(app); + MinimalWithDIGraphicalModel model = process.createModel(); + org.kie.kogito.process.ProcessInstance instance = process.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test public void testCompositeProcessWithDIGraphical() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-CompositeProcessWithDIGraphical.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("CompositeWithDIGraphical"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process compositeWithDIGraphicalProcess = CompositeWithDIGraphicalProcess.newProcess(app); + CompositeWithDIGraphicalModel model = compositeWithDIGraphicalProcess.createModel(); + org.kie.kogito.process.ProcessInstance instance = compositeWithDIGraphicalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testScriptTask() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-ScriptTask.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("ScriptTask"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testScriptTask() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process scriptTaskProcess = ScriptTaskProcess.newProcess(app); + ScriptTaskModel model = scriptTaskProcess.createModel(); + org.kie.kogito.process.ProcessInstance instance = scriptTaskProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testDataObject() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataObject.bpmn2"); - - Map params = new HashMap<>(); - params.put("employee", "UserId-12345"); - KogitoProcessInstance processInstance = kruntime.startProcess("DataObject", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testDataObject() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process dataObjectProcess = DataObjectProcess.newProcess(app); + DataObjectModel model = dataObjectProcess.createModel(); + model.setEmployee("UserId-12345"); + org.kie.kogito.process.ProcessInstance instance = dataObjectProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testEvaluationProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Evaluation.bpmn2"); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("RegisterRequest", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("employee", "UserId-12345"); - KogitoProcessInstance processInstance = kruntime.startProcess("Evaluation", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testEvaluationProcess() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "RegisterRequest", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = EvaluationProcess.newProcess(app); + EvaluationModel model = processDefinition.createModel(); + model.setEmployee("UserId-12345"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testEvaluationProcess2() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Evaluation2.bpmn2"); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("employee", "UserId-12345"); - KogitoProcessInstance processInstance = kruntime.startProcess("Evaluation2", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testEvaluationProcess2() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = Evaluation2Process.newProcess(app); + Evaluation2Model model = processDefinition.createModel(); + model.setEmployee("UserId-12345"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testEvaluationProcess3() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Evaluation3.bpmn2"); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("RegisterRequest", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("employee", "john2"); - KogitoProcessInstance processInstance = kruntime.startProcess("Evaluation3", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testEvaluationProcess3() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "RegisterRequest", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = Evaluation3Process.newProcess(app); + Evaluation3Model model = processDefinition.createModel(); + model.setEmployee("john2"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testUserTask() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-UserTask.bpmn2"); - + public void testUserTask() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map params = new HashMap<>(); - String varId = "s"; - String varValue = "initialValue"; - params.put(varId, varValue); - KogitoProcessInstance processInstance = kruntime.startProcess("UserTask", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskProcess.newProcess(app); + UserTaskModel model = processDefinition.createModel(); + model.setS("initialValue"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); assertThat(workItem.getParameter("ActorId")).isEqualTo("john"); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); + instance.completeWorkItem(workItem.getStringId(), Collections.emptyMap(), SecurityPolicy.of("john", null)); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -193,25 +252,31 @@ public void testLane() throws Exception { } @Test - public void testExclusiveSplit() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplit.bpmn2"); + public void testExclusiveSplit() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("x", "First"); - params.put("y", "Second"); - KogitoProcessInstance processInstance = kruntime.startProcess("ExclusiveSplit", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + org.kie.kogito.process.Process processDefinition = ExclusiveSplitProcess.newProcess(app); + ExclusiveSplitModel model = processDefinition.createModel(); + model.setX("First"); + model.setY("Second"); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testInclusiveSplit() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-InclusiveSplit.bpmn2"); + public void testInclusiveSplit() { + Application app = ProcessTestHelper.newApplication(); - Map params = new HashMap<>(); - params.put("x", 15); - KogitoProcessInstance processInstance = kruntime.startProcess("InclusiveSplit", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + org.kie.kogito.process.Process processDefinition = InclusiveSplitProcess.newProcess(app); + InclusiveSplitModel model = processDefinition.createModel(); + model.setX(15); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -233,69 +298,65 @@ public void testExclusiveSplitXPath() throws Exception { } @Test - public void testEventBasedSplit() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit.bpmn2"); + public void testEventBasedSplit() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email1", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "Email2", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); - // Yes - KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); - kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - // No - processInstance = kruntime.startProcess("EventBasedSplit"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); - kruntime.signalEvent("No", "NoValue", processInstance.getStringId()); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); + org.kie.kogito.process.Process processDefinition = EventBasedSplitProcess.newProcess(app); + EventBasedSplitModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + instance.send(Sig.of("Yes", "YesValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + instance.send(Sig.of("No", "NoValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testEventBasedSplitBefore() throws Exception { - // signaling before the split is reached should have no effect - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit.bpmn2"); + public void testEventBasedSplitBefore() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email1", new DoNothingWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "Email2", new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); - // Yes - KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); - kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - // No - processInstance = kruntime.startProcess("EventBasedSplit"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); - kruntime.signalEvent("No", "NoValue", processInstance.getStringId()); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); + org.kie.kogito.process.Process processDefinition = EventBasedSplitProcess.newProcess(app); + EventBasedSplitModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + instance.send(Sig.of("Yes", "YesValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + + instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + instance.send(Sig.of("No", "NoValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); } @Test - public void testEventBasedSplitAfter() throws Exception { + public void testEventBasedSplitAfter() { // signaling the other alternative after one has been selected should // have no effect - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit.bpmn2"); + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email1", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "Email2", new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = EventBasedSplitProcess.newProcess(app); + EventBasedSplitModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); // Yes - KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); - kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + instance.send(Sig.of("Yes", "YesValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); // No - kruntime.signalEvent("No", "NoValue", processInstance.getStringId()); + instance.send(Sig.of("No", "NoValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); } @Test @@ -347,24 +408,23 @@ public void testEventBasedSplit3() throws Exception { } @Test - public void testEventBasedSplit4() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit4.bpmn2"); + public void testEventBasedSplit4() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email1", new SystemOutWorkItemHandler()); + ProcessTestHelper.registerHandler(app, "Email2", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); - // Yes - KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit4"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); - kruntime.signalEvent("Message-YesMessage", "YesValue", processInstance.getStringId()); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); - // No - processInstance = kruntime.startProcess("EventBasedSplit4"); - kruntime.signalEvent("Message-NoMessage", "NoValue", processInstance.getStringId()); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); + org.kie.kogito.process.Process processDefinition = EventBasedSplit4Process.newProcess(app); + EventBasedSplit4Model model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + instance.send(Sig.of("Message-YesMessage", "YesValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + + instance = processDefinition.createInstance(model); + instance.start(); + instance.send(Sig.of("Message-NoMessage", "NoValue")); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -397,23 +457,29 @@ public void testEventBasedSplit5() throws Exception { } @Test - public void testCallActivity() throws Exception { - kruntime = createKogitoProcessRuntime( - "org/jbpm/bpmn2/subprocess/BPMN2-CallActivity.bpmn2", - "org/jbpm/bpmn2/subprocess/BPMN2-CallActivitySubProcess.bpmn2"); + public void testCallActivity() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = CallActivityProcess.newProcess(app); + CallActivitySubProcessProcess.newProcess(app); + CallActivityModel model = processDefinition.createModel(); + model.setX("oldValue"); + ProcessInstance instance = processDefinition.createInstance(model); - Map params = new HashMap<>(); - params.put("x", "oldValue"); - KogitoProcessInstance processInstance = kruntime.startProcess("CallActivity", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); - assertThat(((KogitoWorkflowProcessInstance) processInstance).getVariable("y")).isEqualTo("new value"); + CallActivitySubProcessProcess.newProcess(app); + + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(instance.variables().getY()).isEqualTo("new value"); } @Test - public void testSubProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-SubProcess.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("SubProcess"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); + public void testSubProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = SubProcessProcess.newProcess(app); + SubProcessModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -618,22 +684,28 @@ public void testIntermediateCatchEventCondition() throws Exception { } @Test - public void testErrorEndEventProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-ErrorEndEvent.bpmn2"); + public void testErrorEndEventProcess() { + Application app = ProcessTestHelper.newApplication(); - KogitoProcessInstance processInstance = kruntime.startProcess("ErrorEndEvent"); - assertProcessInstanceAborted(processInstance.getStringId(), kruntime); + org.kie.kogito.process.Process processDefinition = ErrorEndEventProcess.newProcess(app); + ErrorEndEventModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ABORTED); } @Test - public void testSendTask() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/task/BPMN2-SendTask.bpmn2"); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler()); - Map params = new HashMap<>(); - params.put("s", "john"); - KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime.startProcess("SendTask", params); - assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); + public void testSendTask() { + Application app = ProcessTestHelper.newApplication(); + SendTaskHandler sendTaskHandler = new SendTaskHandler(); + ProcessTestHelper.registerHandler(app, "Send Task", sendTaskHandler); + org.kie.kogito.process.Process processDefinition = SendTaskProcess.newProcess(app); + SendTaskModel model = processDefinition.createModel(); + model.setS("john"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -698,11 +770,16 @@ public void afterProcessStarted(ProcessStartedEvent event) { } @Test - public void testSignalEnd() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/event/BPMN2-SignalEndEvent.bpmn2"); - Map params = new HashMap<>(); - params.put("x", "MyValue"); - kruntime.startProcess("SignalEndEvent", params); + public void testSignalEnd() { + Application app = ProcessTestHelper.newApplication(); + + org.kie.kogito.process.Process processDefinition = SignalEndEventProcess.newProcess(app); + SignalEndEventModel model = processDefinition.createModel(); + model.setX("MyValue"); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.jbpm.process.instance.ProcessInstance.STATE_COMPLETED); } @Test @@ -719,7 +796,7 @@ public void afterProcessStarted(ProcessStartedEvent event) { } @Test - public void testMessageIntermediateThrow() throws Exception { + public void testMessageIntermediateThrow() { Application app = ProcessTestHelper.newApplication(); ProcessTestHelper.registerHandler(app, "Send Task", new SendTaskHandler()); IntermediateThrowEventMessageProcess definition = (IntermediateThrowEventMessageProcess) IntermediateThrowEventMessageProcess.newProcess(app); diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java index 90d63909c93..db63be23c25 100644 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java @@ -26,6 +26,11 @@ import org.drools.io.ClassPathResource; import org.jbpm.bpmn2.objects.TestWorkItemHandler; +import org.jbpm.bpmn2.tags.ApprovalWithCustomVariableTagsModel; +import org.jbpm.bpmn2.tags.ApprovalWithCustomVariableTagsProcess; +import org.jbpm.bpmn2.tags.ApprovalWithReadonlyVariableTagsModel; +import org.jbpm.bpmn2.tags.ApprovalWithReadonlyVariableTagsProcess; +import org.jbpm.bpmn2.tags.ApprovalWithRequiredVariableTagsModel; import org.jbpm.bpmn2.tags.ApprovalWithRequiredVariableTagsProcess; import org.jbpm.process.core.context.variable.Variable; import org.jbpm.ruleflow.core.RuleFlowProcess; @@ -34,8 +39,8 @@ import org.kie.api.event.process.ProcessVariableChangedEvent; import org.kie.kogito.Application; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; -import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; +import org.kie.kogito.process.ProcessInstance; import org.kie.kogito.process.VariableViolationException; import org.kie.kogito.process.bpmn2.BpmnProcess; import org.kie.kogito.process.bpmn2.BpmnVariables; @@ -43,8 +48,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.entry; -import static org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ABORTED; -import static org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE; public class VariableTagsTest extends JbpmBpmn2TestCase { @@ -62,75 +65,80 @@ public void testVariableMultipleMetadata() throws Exception { } @Test - public void testProcessWithMissingRequiredVariable() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/tags/BPMN2-ApprovalWithRequiredVariableTags.bpmn2"); + public void testProcessWithMissingRequiredVariable() { + Application app = ProcessTestHelper.newApplication(); + ApprovalWithRequiredVariableTagsProcess processDefinition = (ApprovalWithRequiredVariableTagsProcess) ApprovalWithRequiredVariableTagsProcess.newProcess(app); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - assertThatExceptionOfType(VariableViolationException.class).isThrownBy(() -> kruntime.startProcess("ApprovalWithRequiredVariableTags")); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + ApprovalWithRequiredVariableTagsModel model = processDefinition.createModel(); + + assertThatExceptionOfType(VariableViolationException.class).isThrownBy(() -> { + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + }); } @Test - public void testProcessWithRequiredVariable() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/tags/BPMN2-ApprovalWithRequiredVariableTags.bpmn2"); - + public void testProcessWithRequiredVariable() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map parameters = new HashMap<>(); - parameters.put("approver", "john"); - - KogitoProcessInstance processInstance = kruntime.startProcess("ApprovalWithRequiredVariableTags", parameters); - assertThat(processInstance.getState()).isEqualTo(STATE_ACTIVE); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = ApprovalWithRequiredVariableTagsProcess.newProcess(app); + ApprovalWithRequiredVariableTagsModel model = processDefinition.createModel(); + model.setApprover("john"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); + instance.completeWorkItem(workItem.getStringId(), null); workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceFinished(processInstance, kruntime); + instance.completeWorkItem(workItem.getStringId(), null); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testProcessWithReadonlyVariable() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/tags/BPMN2-ApprovalWithReadonlyVariableTags.bpmn2"); - + public void testProcessWithReadonlyVariable() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map parameters = new HashMap<>(); - parameters.put("approver", "john"); - - KogitoProcessInstance processInstance = kruntime.startProcess("ApprovalWithReadonlyVariableTags", parameters); - assertThat(processInstance.getState()).isEqualTo(STATE_ACTIVE); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = ApprovalWithReadonlyVariableTagsProcess.newProcess(app); + ApprovalWithReadonlyVariableTagsModel model = processDefinition.createModel(); + model.setApprover("john"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - assertThatExceptionOfType(VariableViolationException.class) - .isThrownBy(() -> kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), Collections.singletonMap("ActorId", "john"))); - - kruntime.abortProcessInstance(processInstance.getStringId()); - - assertProcessInstanceFinished(processInstance, kruntime); + .isThrownBy(() -> instance.completeWorkItem(workItem.getStringId(), Collections.singletonMap("ActorId", "john"))); + instance.abort(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ABORTED); } @Test - public void testProcessWithCustomVariableTag() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/tags/BPMN2-ApprovalWithCustomVariableTags.bpmn2"); + public void testProcessWithCustomVariableTag() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() { - + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + DefaultKogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void beforeVariableChanged(ProcessVariableChangedEvent event) { if (event.hasTag("onlyAdmin")) { - throw new VariableViolationException(((KogitoProcessInstance) event.getProcessInstance()).getStringId(), event.getVariableId(), "Variable can only be set by admins"); + throw new VariableViolationException(event.getProcessInstance().getId(), event.getVariableId(), "Variable can only be set by admins"); } } - + }; + ProcessTestHelper.registerProcessEventListener(app, listener); + org.kie.kogito.process.Process processDefinition = ApprovalWithCustomVariableTagsProcess.newProcess(app); + ApprovalWithCustomVariableTagsModel model = processDefinition.createModel(); + model.setApprover("john"); + + assertThatExceptionOfType(VariableViolationException.class).isThrownBy(() -> { + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); }); - - Map parameters = new HashMap<>(); - parameters.put("approver", "john"); - - assertThatExceptionOfType(VariableViolationException.class).isThrownBy(() -> kruntime.startProcess("ApprovalWithCustomVariableTags", parameters)); } @Test @@ -139,20 +147,16 @@ public void testRequiredVariableFiltering() { BpmnProcess process = processes.get(0); Map params = new HashMap<>(); params.put("approver", "john"); - org.kie.kogito.process.ProcessInstance instance = process.createInstance(BpmnVariables.create(params)); instance.start(); - - assertThat(instance.status()).isEqualTo(STATE_ACTIVE); - + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE); assertThat(instance.variables().toMap()).hasSize(1); assertThat(instance.variables().toMap(BpmnVariables.OUTPUTS_ONLY)).isEmpty(); assertThat(instance.variables().toMap(BpmnVariables.INPUTS_ONLY)).isEmpty(); assertThat(instance.variables().toMap(BpmnVariables.INTERNAL_ONLY)).isEmpty(); assertThat(instance.variables().toMap(v -> v.hasTag("onlyAdmin"))).hasSize(1).containsEntry("approver", "john"); - instance.abort(); - - assertThat(instance.status()).isEqualTo(STATE_ABORTED); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ABORTED); } + } diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index b0bd0020724..a8ac56322d1 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -1214,6 +1214,40 @@ ${project.version} sources + + + org.kie + kie-addons-process-dynamic + ${project.version} + + + org.kie + kie-addons-process-dynamic + ${project.version} + sources + + + org.kie + kie-addons-quarkus-process-dynamic + ${project.version} + + + org.kie + kie-addons-quarkus-process-dynamic + ${project.version} + sources + + + org.kie + kie-addons-quarkus-process-dynamic-deployment + ${project.version} + + + org.kie + kie-addons-quarkus-process-dynamic-deployment + ${project.version} + sources + org.kie diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index e936a83d036..1a5d8ea4ed3 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -138,7 +138,7 @@ 0.10.2 2.0.6 - 3.9.3 + 3.9.6 2.2.1 3.7.1 3.2.0 @@ -366,6 +366,11 @@ jackson-jq ${version.net.thisptr.jackson-jq} + + net.thisptr + jackson-jq-extra + ${version.net.thisptr.jackson-jq} + org.postgresql postgresql diff --git a/kogito-serverless-workflow/kogito-jq-expression/pom.xml b/kogito-serverless-workflow/kogito-jq-expression/pom.xml index 7bebf4dc7c1..e054ecc4c2b 100644 --- a/kogito-serverless-workflow/kogito-jq-expression/pom.xml +++ b/kogito-serverless-workflow/kogito-jq-expression/pom.xml @@ -48,6 +48,10 @@ net.thisptr jackson-jq + + net.thisptr + jackson-jq-extra + org.junit.jupiter junit-jupiter-api diff --git a/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java b/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java index 279daa331d2..6ef7cfb899f 100644 --- a/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java +++ b/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java @@ -213,9 +213,12 @@ private static Duration getRequestTimeout(Map parameters) { } private Class getTargetInfo(KogitoWorkItem workItem) { - String varName = ((WorkItemNode) ((WorkItemNodeInstance) workItem.getNodeInstance()).getNode()).getIoSpecification().getOutputMappingBySources().get(RESULT); - if (varName != null) { - return getType(workItem, varName); + WorkItemNode node = (WorkItemNode) ((WorkItemNodeInstance) workItem.getNodeInstance()).getNode(); + if (node != null) { + String varName = node.getIoSpecification().getOutputMappingBySources().get(RESULT); + if (varName != null) { + return getType(workItem, varName); + } } logger.warn("no out mapping for {}", RESULT); return null; diff --git a/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/pathresolvers/DefaultPathParamResolver.java b/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/pathresolvers/DefaultPathParamResolver.java index 6f9f5e29a13..b9caf37ec5b 100644 --- a/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/pathresolvers/DefaultPathParamResolver.java +++ b/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/pathresolvers/DefaultPathParamResolver.java @@ -40,7 +40,7 @@ public String apply(String endPoint, Map parameters) { throw new IllegalArgumentException("malformed endpoint should contain enclosing '}' " + endPoint); } final String key = sb.substring(start + 1, end); - final Object value = parameters.get(key); + final Object value = getParam(parameters, key); if (value == null) { throw new IllegalArgumentException("missing parameter " + key); } @@ -51,4 +51,8 @@ public String apply(String endPoint, Map parameters) { parameters.keySet().removeAll(toRemove); return sb.toString(); } + + protected Object getParam(Map parameters, String key) { + return parameters.get(key); + } } diff --git a/quarkus/addons/dynamic/deployment/pom.xml b/quarkus/addons/dynamic/deployment/pom.xml new file mode 100644 index 00000000000..7c4332e4de3 --- /dev/null +++ b/quarkus/addons/dynamic/deployment/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.kie + kie-addons-quarkus-process-dynamic-parent + 999-SNAPSHOT + + kie-addons-quarkus-process-dynamic-deployment + KIE Add-On Process Instance Dynamic Calls - Deployment + + + org.kie.kogito.process.quarkus.dynamic.deployment + + + + + org.kie + kie-addons-quarkus-process-dynamic + + + org.kie + kogito-addons-quarkus-common-deployment + + + io.quarkus + quarkus-resteasy-deployment + provided + + + io.quarkus + quarkus-resteasy-jackson-deployment + provided + + + io.quarkus + quarkus-arc-deployment + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + diff --git a/quarkus/addons/dynamic/deployment/src/main/java/org/kie/kogito/process/dynamic/deployment/ProcessDynamicProcessor.java b/quarkus/addons/dynamic/deployment/src/main/java/org/kie/kogito/process/dynamic/deployment/ProcessDynamicProcessor.java new file mode 100644 index 00000000000..c5c3818bb26 --- /dev/null +++ b/quarkus/addons/dynamic/deployment/src/main/java/org/kie/kogito/process/dynamic/deployment/ProcessDynamicProcessor.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic.deployment; + +import org.kie.kogito.quarkus.addons.common.deployment.KogitoCapability; +import org.kie.kogito.quarkus.addons.common.deployment.OneOfCapabilityKogitoAddOnProcessor; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class ProcessDynamicProcessor extends OneOfCapabilityKogitoAddOnProcessor { + + private static final String FEATURE = "kie-addon-process-dynamic-extension"; + + ProcessDynamicProcessor() { + super(KogitoCapability.SERVERLESS_WORKFLOW); + } + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/quarkus/addons/dynamic/integration-tests/pom.xml b/quarkus/addons/dynamic/integration-tests/pom.xml new file mode 100644 index 00000000000..4fe89ac8159 --- /dev/null +++ b/quarkus/addons/dynamic/integration-tests/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + org.kie + kie-addons-quarkus-process-dynamic-parent + 999-SNAPSHOT + + + kie-addons-quarkus-process-dynamic-integration-tests + KIE Add-On Process Instance Dynamic Calls Integration test + + + org.kie.kogito.process.quarkus.dynamic.tests + + + + + org.apache.kie.sonataflow + sonataflow-quarkus + + + org.kie + kie-addons-quarkus-process-dynamic + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + + diff --git a/quarkus/addons/dynamic/integration-tests/src/main/java/org/kie/kogito/process/dynamic/ResumeProcessResource.java b/quarkus/addons/dynamic/integration-tests/src/main/java/org/kie/kogito/process/dynamic/ResumeProcessResource.java new file mode 100644 index 00000000000..9447ecd2200 --- /dev/null +++ b/quarkus/addons/dynamic/integration-tests/src/main/java/org/kie/kogito/process/dynamic/ResumeProcessResource.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.io.IOException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.util.Map; +import java.util.UUID; + +import org.eclipse.microprofile.reactive.messaging.Channel; +import org.eclipse.microprofile.reactive.messaging.Emitter; +import org.kie.kogito.event.CloudEventMarshaller; +import org.kie.kogito.event.cloudevents.CloudEventExtensionConstants; +import org.kie.kogito.event.impl.StringCloudEventMarshaller; +import org.kie.kogito.jackson.utils.ObjectMapperFactory; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; + +import jakarta.annotation.PostConstruct; +import jakarta.inject.Inject; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; + +@Path("/example") +public class ResumeProcessResource { + + private CloudEventMarshaller marshaller; + @Inject + @Channel("resume-out") + Emitter resumeEmitter; + + @PostConstruct + void init() { + marshaller = new StringCloudEventMarshaller(ObjectMapperFactory.get()); + } + + @POST + @Path("/{processInstanceId}") + public Map resumeProcess(@PathParam("processInstanceId") String processInstanceId, Map data) throws IOException { + resumeEmitter.send(marshaller.marshall(buildCloudEvent(processInstanceId, data))); + return Map.of("message", "this is a test call to resume the workflow", "tobefilterout", "This a parameter we would like to remove"); + } + + private CloudEvent buildCloudEvent(String processInstanceId, Map data) { + return CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSource(URI.create("")) + .withType("resume") + .withTime(OffsetDateTime.now()) + .withData(marshaller.cloudEventDataFactory().apply(data)).withExtension(CloudEventExtensionConstants.PROCESS_REFERENCE_ID, processInstanceId).build(); + } +} diff --git a/quarkus/addons/dynamic/integration-tests/src/main/resources/application.properties b/quarkus/addons/dynamic/integration-tests/src/main/resources/application.properties new file mode 100644 index 00000000000..a656b4c6420 --- /dev/null +++ b/quarkus/addons/dynamic/integration-tests/src/main/resources/application.properties @@ -0,0 +1,7 @@ +mp.messaging.incoming.resume.connector=quarkus-http +mp.messaging.incoming.resume.path=/resume + +mp.messaging.outgoing.resume-out.connector=quarkus-http +mp.messaging.outgoing.resume-out.url=http://localhost:8081/resume + +quarkus.devservices.enabled = false diff --git a/quarkus/addons/dynamic/integration-tests/src/main/resources/waitEvent.sw.json b/quarkus/addons/dynamic/integration-tests/src/main/resources/waitEvent.sw.json new file mode 100644 index 00000000000..fd57e325f26 --- /dev/null +++ b/quarkus/addons/dynamic/integration-tests/src/main/resources/waitEvent.sw.json @@ -0,0 +1,33 @@ +{ + "id": "dynamicWait", + "version": "1.0", + "name": "Test dynamic invocations", + "start": "doNothing", + "events": [ + { + "name": "resumeEvent", + "source": "", + "type": "resume" + } + ], + "states": [ + { + "name": "doNothing", + "type": "operation", + "actions": [], + "transition": "waitForEvent" + }, + { + "name": "waitForEvent", + "type": "event", + "onEvents": [ + { + "eventRefs": [ + "resumeEvent" + ] + } + ], + "end": true + } + ] +} \ No newline at end of file diff --git a/quarkus/addons/dynamic/integration-tests/src/test/java/org/kie/kogito/process/dynamic/DynamicCallResourceTest.java b/quarkus/addons/dynamic/integration-tests/src/test/java/org/kie/kogito/process/dynamic/DynamicCallResourceTest.java new file mode 100644 index 00000000000..76717637833 --- /dev/null +++ b/quarkus/addons/dynamic/integration-tests/src/test/java/org/kie/kogito/process/dynamic/DynamicCallResourceTest.java @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.*; +import static org.hamcrest.Matchers.containsString; + +@QuarkusTest +public class DynamicCallResourceTest { + + @Test + void testDynamicCall() { + + String id = createDynamicWaitProcessInstance(); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .when() + .get("/dynamicWait/" + id) + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "/example/{processInstanceId}", "port", 8081, "method", "post", "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + id + "/rest") + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .when() + .get("/dynamicWait/" + id) + .then() + .statusCode(404); + } + + @Test + void testDynamicCallWithInvalidProcessId() { + String invalidId = "invalid-process-id"; + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "/example/{processInstanceId}", "port", 8081, "method", "post", "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + invalidId + "/rest") + .then() + .statusCode(400) + .body("message", containsString("Cannot find process instance")); + } + + @Test + void testDynamicCallWithMissingUrlParameter() { + String id = createDynamicWaitProcessInstance(); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("port", 8081)) + .when() + .post("/_dynamic/dynamicWait/" + id + "/rest") + .then() + .statusCode(400) + .body("message", containsString("Missing required parameter Url")); + } + + @Test + void testDynamicCallWithMissingMethodParameter() { + String id = createDynamicWaitProcessInstance(); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "/example/{processInstanceId}", "port", 8081, "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + id + "/rest") + .then() + .statusCode(500) + .body("message", containsString("Method Not Allowed")); + } + + @Test + void testDynamicCallWithMissingPortParameter() { + String id = createDynamicWaitProcessInstance(); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "/example/{processInstanceId}", "method", "post", "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + id + "/rest") + .then() + .statusCode(500); + } + + @Test + void testDynamicCallWithInvalidEndpointFormat() { + String id = createDynamicWaitProcessInstance(); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "invalid-endpoint-format", "port", 8081, "method", "post", "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + id + "/rest") + .then() + .statusCode(404) + .body("message", containsString("endpoint invalid-endpoint-format failed")); + } + + @Test + void testConcurrentDynamicCalls() throws Exception { + String id1 = createDynamicWaitProcessInstance(); + + String id2 = createDynamicWaitProcessInstance(); + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Future future1 = executor.submit(() -> given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "/example/{processInstanceId}", "port", 8081, "method", "post", "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + id1 + "/rest") + .then() + .statusCode(200)); + + Future future2 = executor.submit(() -> given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(Map.of("endpoint", "/example/{processInstanceId}", "port", 8081, "method", "post", "outputExpression", "{message}")) + .when() + .post("/_dynamic/dynamicWait/" + id2 + "/rest") + .then() + .statusCode(200)); + + future1.get(); + future2.get(); + + executor.shutdown(); + } + + private String createDynamicWaitProcessInstance() { + return given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .when() + .post("/dynamicWait") + .then() + .statusCode(201) + .extract().path("id"); + } + +} diff --git a/quarkus/addons/dynamic/pom.xml b/quarkus/addons/dynamic/pom.xml new file mode 100644 index 00000000000..cbaa99408ca --- /dev/null +++ b/quarkus/addons/dynamic/pom.xml @@ -0,0 +1,42 @@ + + + + + kogito-addons-quarkus-parent + org.kie + 999-SNAPSHOT + + 4.0.0 + + kie-addons-quarkus-process-dynamic-parent + KIE Add-On Process Instance Dynamic Call - Parent + pom + + + deployment + runtime + integration-tests + + + \ No newline at end of file diff --git a/quarkus/addons/dynamic/runtime/pom.xml b/quarkus/addons/dynamic/runtime/pom.xml new file mode 100644 index 00000000000..98c099d0d60 --- /dev/null +++ b/quarkus/addons/dynamic/runtime/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + org.kie + kie-addons-quarkus-process-dynamic-parent + 999-SNAPSHOT + + kie-addons-quarkus-process-dynamic + KIE Add-On Process Instance Dynamic Calls + Allow performing dynamic calls for existiing process instances in Quarkus + + org.kie.kogito.process.quarkus.dynamic + + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-resteasy + provided + + + io.quarkus + quarkus-resteasy-jackson + provided + + + org.kie + kie-addons-process-dynamic + + + + + + io.quarkus + quarkus-extension-maven-plugin + ${version.io.quarkus} + + + compile + + extension-descriptor + + + ${project.groupId}:${project.artifactId}-deployment:${project.version} + + org.kie.addons.process.definitions + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + \ No newline at end of file diff --git a/quarkus/addons/dynamic/runtime/src/main/java/org/kie/kogito/process/dynamic/ProcessInstanceDynamicCallsResource.java b/quarkus/addons/dynamic/runtime/src/main/java/org/kie/kogito/process/dynamic/ProcessInstanceDynamicCallsResource.java new file mode 100644 index 00000000000..7ff60f52487 --- /dev/null +++ b/quarkus/addons/dynamic/runtime/src/main/java/org/kie/kogito/process/dynamic/ProcessInstanceDynamicCallsResource.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.process.dynamic; + +import java.util.Collection; +import java.util.stream.Collectors; + +import org.kie.kogito.process.Process; +import org.kogito.workitem.rest.RestWorkItemHandler; + +import io.vertx.ext.web.client.WebClientOptions; +import io.vertx.mutiny.core.Vertx; +import io.vertx.mutiny.ext.web.client.WebClient; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; + +@Path("/_dynamic") +public class ProcessInstanceDynamicCallsResource { + + @Inject + Vertx vertx; + @Inject + WebClientOptions sslOptions; + private RestWorkItemHandler handler; + private Collection> processes; + + @Inject + ProcessInstanceDynamicCallsResource(Instance> processes) { + this.processes = processes.stream().collect(Collectors.toUnmodifiableList()); + } + + @PostConstruct + void init() { + handler = new RestWorkItemHandler(WebClient.create(vertx), WebClient.create(vertx, sslOptions)); + } + + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @Path("/{processId}/{processInstanceId}/rest") + public Response executeRestCall(@PathParam("processId") String processId, @PathParam("processInstanceId") String processInstanceId, RestCallInfo input) { + ProcessInstanceDynamicCallHelper.executeRestCall(handler, processes, processId, processInstanceId, input); + return Response.status(200).build(); + } +} diff --git a/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/beans.xml b/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..a0eb9fbf8cd --- /dev/null +++ b/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/beans.xml @@ -0,0 +1,20 @@ + diff --git a/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/kogito.addon b/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/kogito.addon new file mode 100644 index 00000000000..079f19a7880 --- /dev/null +++ b/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/kogito.addon @@ -0,0 +1 @@ +process-dynamic \ No newline at end of file diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/invoker.properties b/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 71% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/invoker.properties rename to quarkus/addons/dynamic/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 35f50068472..3e108e13a76 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/invoker.properties +++ b/quarkus/addons/dynamic/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -17,5 +17,16 @@ # under the License. # -# disable verbose local download output -invoker.mavenOpts=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn +name: KIE Process Instance Dynamic Calls Add-On +description: Allow dynamic invocations over existing process instances +metadata: + keywords: + - KIE + - processes + - process dynamic + - workflows + guide: https://quarkus.io/guides/kie + categories: + - "business-automation" + - "cloud" + status: "stable" diff --git a/quarkus/addons/persistence/mongodb/runtime/src/main/java/org/kie/kogito/persistence/quarkus/MongoDBCorrelationServiceProducer.java b/quarkus/addons/persistence/mongodb/runtime/src/main/java/org/kie/kogito/persistence/quarkus/MongoDBCorrelationServiceProducer.java new file mode 100644 index 00000000000..4ec13086074 --- /dev/null +++ b/quarkus/addons/persistence/mongodb/runtime/src/main/java/org/kie/kogito/persistence/quarkus/MongoDBCorrelationServiceProducer.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.kie.kogito.persistence.quarkus; + +import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.kie.kogito.mongodb.correlation.MongoDBCorrelationRepository; +import org.kie.kogito.mongodb.correlation.MongoDBCorrelationService; + +import com.mongodb.client.MongoClient; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; + +@ApplicationScoped +public class MongoDBCorrelationServiceProducer { + + @Produces + public MongoDBCorrelationService getMongoDBCorrelationService(MongoClient mongoClient, @ConfigProperty(name = "quarkus.mongodb.database", defaultValue = "kogito") String dbName) { + return new MongoDBCorrelationService(new MongoDBCorrelationRepository(mongoClient, dbName)); + } +} diff --git a/quarkus/addons/pom.xml b/quarkus/addons/pom.xml index eb068baddb0..6b27efb5010 100644 --- a/quarkus/addons/pom.xml +++ b/quarkus/addons/pom.xml @@ -58,6 +58,7 @@ task-management marshallers process-definitions + dynamic diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml index 1d27fda2547..8da03ff0f7b 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml @@ -55,19 +55,6 @@ svm provided - - org.jboss.resteasy - resteasy-multipart-provider - - - org.jboss.resteasy - resteasy-jackson2-provider - - - org.jboss.resteasy - resteasy-client - - io.quarkus quarkus-rest-client diff --git a/springboot/integration-tests/integration-tests-springboot-decisions-it/pom.xml b/springboot/integration-tests/integration-tests-springboot-decisions-it/pom.xml new file mode 100644 index 00000000000..8dcda368af0 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/pom.xml @@ -0,0 +1,159 @@ + + + 4.0.0 + + + org.kie.kogito + kogito-spring-boot-integration-tests + 999-SNAPSHOT + + + integration-tests-springboot-decisions-it + + + integration.tests.springboot.decisions.it + + + + + + org.kie.kogito + kogito-spring-boot-bom + ${project.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter + + + + org.drools + drools-decisions-spring-boot-starter + + + + org.kie + kie-predictions-spring-boot-starter + + + + org.kie + kie-addons-springboot-monitoring-prometheus + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + org.junit.jupiter + junit-jupiter-engine + test + + + + io.rest-assured + rest-assured + test + + + + org.kie.kogito + kogito-spring-boot-test-utils + test + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + + + io.swagger.parser.v3 + swagger-parser + test + + + io.swagger.parser.v3 + swagger-parser-v2-converter + + + + + + + + ${project.artifactId} + + + maven-compiler-plugin + ${version.compiler.plugin} + + ${maven.compiler.release} + + + + org.kie.kogito + kogito-maven-plugin + ${project.version} + true + + + org.springframework.boot + spring-boot-maven-plugin + ${version.org.springframework.boot} + + + + repackage + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${version.surefire.plugin} + + + org/kie/kogito/integrationtests/springboot/* + + + + + + + diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/MyMathUtils.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/MyMathUtils.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/MyMathUtils.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/MyMathUtils.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectDecisionModels.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectDecisionModels.java similarity index 91% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectDecisionModels.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectDecisionModels.java index 3fb01da6ef4..c51ab800bcf 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectDecisionModels.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectDecisionModels.java @@ -18,19 +18,19 @@ */ package org.kie.kogito.integrationtests; -import org.springframework.beans.factory.annotation.Autowired; import org.kie.kogito.Application; import org.kie.kogito.decision.DecisionConfig; import org.kie.kogito.decision.DecisionModels; +import org.springframework.beans.factory.annotation.Autowired; public class SpringInjectDecisionModels { @Autowired public SpringInjectDecisionModels(DecisionModels decisionModels, Application application) { - if(decisionModels != application.get(DecisionModels.class)) { + if (decisionModels != application.get(DecisionModels.class)) { throw new IllegalStateException("DecisionModels should be injectable and same as instance application.get(DecisionModels.class)"); } - if(application.config().get(DecisionConfig.class) == null) { + if (application.config().get(DecisionConfig.class) == null) { throw new IllegalStateException("DecisionConfig not available"); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectPredictionModels.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectPredictionModels.java similarity index 90% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectPredictionModels.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectPredictionModels.java index 3e2403a4a10..6632e1d0de8 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectPredictionModels.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectPredictionModels.java @@ -18,19 +18,19 @@ */ package org.kie.kogito.integrationtests; -import org.springframework.beans.factory.annotation.Autowired; import org.kie.kogito.Application; import org.kie.kogito.prediction.PredictionConfig; import org.kie.kogito.prediction.PredictionModels; +import org.springframework.beans.factory.annotation.Autowired; public class SpringInjectPredictionModels { @Autowired public SpringInjectPredictionModels(PredictionModels predictionModels, Application application) { - if(predictionModels != application.get(PredictionModels.class)) { + if (predictionModels != application.get(PredictionModels.class)) { throw new IllegalStateException("PredictionModels should be injectable and same as instance application.get(PredictionModels.class)"); } - if(application.config().get(PredictionConfig.class) == null) { + if (application.config().get(PredictionConfig.class) == null) { throw new IllegalStateException("PredictionConfig not available"); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectRuleUnits.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectRuleUnits.java similarity index 95% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectRuleUnits.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectRuleUnits.java index 8740670a1b6..fa0f99dbc26 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectRuleUnits.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectRuleUnits.java @@ -18,10 +18,10 @@ */ package org.kie.kogito.integrationtests; -import org.springframework.beans.factory.annotation.Autowired; import org.kie.kogito.Application; -import org.kie.kogito.rules.RuleUnits; import org.kie.kogito.rules.RuleConfig; +import org.kie.kogito.rules.RuleUnits; +import org.springframework.beans.factory.annotation.Autowired; public class SpringInjectRuleUnits { @@ -30,8 +30,8 @@ public SpringInjectRuleUnits(RuleUnits ruleUnits, Application application) { if (ruleUnits != application.get(RuleUnits.class)) { throw new IllegalStateException("RuleUnits should be injectable and same as instance application.get(RuleUnits.class)"); } - if(application.config().get(RuleConfig.class) == null) { + if (application.config().get(RuleConfig.class) == null) { throw new IllegalStateException("RuleConfig not available"); } } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/FaceMaskTestData.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/FaceMaskTestData.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/FaceMaskTestData.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/FaceMaskTestData.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalStatusTestData.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalStatusTestData.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalStatusTestData.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalStatusTestData.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalsTestData.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalsTestData.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalsTestData.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/HospitalsTestData.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Human.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Human.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Human.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Human.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java similarity index 79% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java index 4d8e45e26c1..b23fb09af6f 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java @@ -21,10 +21,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages={"org.acme.travels.**", "org.kie.dmn.kogito.**", "org.kie.kogito.**", "com.example.**", "org.acme.examples.**"}) +@SpringBootApplication(scanBasePackages = { "org.kie.dmn.kogito.**", "org.kie.kogito.**", "com.example.**", "org.acme.examples.**", "http*.**" }) public class KogitoSpringbootApplication { - public static void main(String[] args) { - SpringApplication.run(KogitoSpringbootApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Patient.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Patient.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Patient.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/Patient.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/DScoercion.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/DScoercion.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/DScoercion.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/DScoercion.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/ElementAtIndex.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/ElementAtIndex.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/ElementAtIndex.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/ElementAtIndex.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/FaceMask.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/FaceMask.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/FaceMask.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/FaceMask.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/HospitalStatus.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/HospitalStatus.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/HospitalStatus.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/HospitalStatus.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/Hospitals.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/Hospitals.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/Hospitals.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/Hospitals.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/OneOfEachType.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/OneOfEachType.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/OneOfEachType.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/OneOfEachType.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/PMMLRegression.pmml b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/PMMLRegression.pmml similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/PMMLRegression.pmml rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/PMMLRegression.pmml diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/PMMLTree.pmml b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/PMMLTree.pmml similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/PMMLTree.pmml rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/PMMLTree.pmml diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/StatusService.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/StatusService.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/StatusService.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/StatusService.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/basicAdd.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/basicAdd.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/basicAdd.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/basicAdd.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/java_function_context.dmn b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/java_function_context.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/resources/java_function_context.dmn rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/main/resources/java_function_context.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java index 5f755f1888d..4c3c9a15de1 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java @@ -18,10 +18,11 @@ */ package org.kie.kogito.integrationtests.springboot; -import io.restassured.RestAssured; import org.junit.jupiter.api.BeforeEach; import org.springframework.boot.test.web.server.LocalServerPort; +import io.restassured.RestAssured; + public abstract class BaseRestTest { @LocalServerPort @@ -40,4 +41,4 @@ void setPort() { RestAssured.port = randomServerPort; } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicAddTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicAddTest.java similarity index 62% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicAddTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicAddTest.java index 77251b87ad8..96a2a1167bf 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicAddTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicAddTest.java @@ -18,21 +18,14 @@ */ package org.kie.kogito.integrationtests.springboot; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Period; - -import io.restassured.http.ContentType; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @ExtendWith(SpringExtension.class) @@ -42,45 +35,45 @@ class BasicAddTest extends BaseRestTest { @Test void testWholeModel() { given().body("{ \"a\": \"v1\", \"b\": \"v2\" }") - .contentType(ContentType.JSON) - .when() - .post("/basicAdd") - .then() - .statusCode(200) - .body("decision", is("v1v2")); + .contentType(ContentType.JSON) + .when() + .post("/basicAdd") + .then() + .statusCode(200) + .body("decision", is("v1v2")); } - + @Test void testWholeModel_dmnresult() { given().body("{ \"a\": \"v1\", \"b\": \"v2\" }") - .contentType(ContentType.JSON) - .when() - .post("/basicAdd/dmnresult") - .then() - .statusCode(200) - .body("dmnContext.decision", is("v1v2")); + .contentType(ContentType.JSON) + .when() + .post("/basicAdd/dmnresult") + .then() + .statusCode(200) + .body("dmnContext.decision", is("v1v2")); } - + @Test void testDs1() { given().body("{ \"a\": \"v1\", \"b\": \"v2\" }") - .contentType(ContentType.JSON) - .when() - .post("/basicAdd/ds1") - .then() - .statusCode(200) - .body(is("\"v1v2\"")); // a JSON string literal: "v1v2" + .contentType(ContentType.JSON) + .when() + .post("/basicAdd/ds1") + .then() + .statusCode(200) + .body(is("\"v1v2\"")); // a JSON string literal: "v1v2" } - + @Test void testDs1_dmnresult() { given().body("{ \"a\": \"v1\", \"b\": \"v2\" }") - .contentType(ContentType.JSON) - .when() - .post("/basicAdd/ds1/dmnresult") - .then() - .statusCode(200) - .body("dmnContext.decision", is("v1v2")); + .contentType(ContentType.JSON) + .when() + .post("/basicAdd/ds1/dmnresult") + .then() + .statusCode(200) + .body("dmnContext.decision", is("v1v2")); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/CommonPMMLTestUtils.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/CommonPMMLTestUtils.java similarity index 88% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/CommonPMMLTestUtils.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/CommonPMMLTestUtils.java index 9b03bee9f41..6d69155dd10 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/CommonPMMLTestUtils.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/CommonPMMLTestUtils.java @@ -20,9 +20,10 @@ import java.util.Map; +import org.hamcrest.core.IsNull; + import io.restassured.http.ContentType; import io.restassured.response.Response; -import org.hamcrest.core.IsNull; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.is; @@ -34,9 +35,9 @@ public class CommonPMMLTestUtils { public static void testResult(final String inputData, - final String path, - final String targetField, - final Object expectedResult) { + final String path, + final String targetField, + final Object expectedResult) { final Response response = given() .contentType(ContentType.JSON) .body(inputData) @@ -48,7 +49,7 @@ public static void testResult(final String inputData, } public static void testResultWrongData(final String inputData, - final String path) { + final String path) { final Response response = given() .contentType(ContentType.JSON) .body(inputData) @@ -61,9 +62,9 @@ public static void testResultWrongData(final String inputData, } public static void testDescriptive(final String inputData, - final String basePath, - final String targetField, - final Map expectedResultMap) { + final String basePath, + final String targetField, + final Map expectedResultMap) { String path = basePath + "/descriptive"; final Response response = given() .contentType(ContentType.JSON) @@ -93,7 +94,7 @@ public static void testDescriptive(final String inputData, } public static void testDescriptiveWrongData(final String inputData, - final String basePath) { + final String basePath) { String path = basePath + "descriptive"; final Response response = given() .contentType(ContentType.JSON) diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/DSCoercionTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/DSCoercionTest.java similarity index 62% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/DSCoercionTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/DSCoercionTest.java index 2bcb288a37c..05f928ed99c 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/DSCoercionTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/DSCoercionTest.java @@ -24,12 +24,13 @@ import java.time.LocalTime; import java.time.Period; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -41,90 +42,90 @@ class DSCoercionTest extends BaseRestTest { @Test void testWholeModel() { given() - .contentType(ContentType.JSON) - .when() - .post("/DScoercion") - .then() - .statusCode(200) - .body("n", is(47)) - .body("s", is("Hello, World")) - .body("b", is(true)) - .body("d", is("2020-05-18")) // as JSON is not schema aware, here we assert the RAW string - .body("t", is("12:34:56")) - .body("dt", is("2020-05-18T12:34:56")) - .body("ymd", is("P3Y")) - .body("dtd", is("PT1H")); + .contentType(ContentType.JSON) + .when() + .post("/DScoercion") + .then() + .statusCode(200) + .body("n", is(47)) + .body("s", is("Hello, World")) + .body("b", is(true)) + .body("d", is("2020-05-18")) // as JSON is not schema aware, here we assert the RAW string + .body("t", is("12:34:56")) + .body("dt", is("2020-05-18T12:34:56")) + .body("ymd", is("P3Y")) + .body("dtd", is("PT1H")); } @Test void testDSn() { Number DSn = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSn") - .getBody().as(Number.class); + .when() + .post("/DScoercion/DSn") + .getBody().as(Number.class); assertThat(DSn, is(47)); } @Test void testDSs() { String DSs = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSs") - .getBody().asString(); + .when() + .post("/DScoercion/DSs") + .getBody().asString(); assertThat(DSs, is("\"Hello, World\"")); // we want to be sure the RAW response is a JSONValue string literal, ref http://ecma-international.org/ecma-262/5.1/#sec-15.12 } @Test void testDSb() { Boolean DSb = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSb") - .getBody().as(Boolean.class); + .when() + .post("/DScoercion/DSb") + .getBody().as(Boolean.class); assertThat(DSb, is(true)); } @Test void testDSd() { LocalDate DSd = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSd") - .getBody().as(LocalDate.class); + .when() + .post("/DScoercion/DSd") + .getBody().as(LocalDate.class); assertThat(DSd, is(LocalDate.of(2020, 5, 18))); } @Test void testDSt() { LocalTime DSt = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSt") - .getBody().as(LocalTime.class); + .when() + .post("/DScoercion/DSt") + .getBody().as(LocalTime.class); assertThat(DSt, is(LocalTime.of(12, 34, 56))); } @Test void testDSdt() { LocalDateTime DSdt = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSdt") - .getBody().as(LocalDateTime.class); + .when() + .post("/DScoercion/DSdt") + .getBody().as(LocalDateTime.class); assertThat(DSdt, is(LocalDateTime.of(2020, 5, 18, 12, 34, 56))); } @Test void testDSdtd() { Duration DSdtd = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSdtd") - .getBody().as(Duration.class); + .when() + .post("/DScoercion/DSdtd") + .getBody().as(Duration.class); assertThat(DSdtd, is(Duration.parse("PT1H"))); } @Test void testDSymd() { Period DSymd = given().contentType(ContentType.JSON) - .when() - .post("/DScoercion/DSymd") - .getBody().as(Period.class); + .when() + .post("/DScoercion/DSymd") + .getBody().as(Period.class); assertThat(DSymd, is(Period.parse("P3Y"))); } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/ElementAtIndexTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/ElementAtIndexTest.java similarity index 65% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/ElementAtIndexTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/ElementAtIndexTest.java index 2fb7a8b6a3d..72d994d52a5 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/ElementAtIndexTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/ElementAtIndexTest.java @@ -18,14 +18,13 @@ */ package org.kie.kogito.integrationtests.springboot; -import io.restassured.RestAssured; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @@ -38,36 +37,36 @@ class ElementAtIndexTest extends BaseRestTest { @Test void testHeaderEmpty() { given().body(" { \"a list\" : [\"a\", \"b\", \"c\"], \"an index\" : 1 }") - .contentType(ContentType.JSON) - .when() - .post("/ElementAtIndex") - .then() - .statusCode(200) - .header("X-Kogito-decision-messages", nullValue()) - .body("'element at index'", is("a")); + .contentType(ContentType.JSON) + .when() + .post("/ElementAtIndex") + .then() + .statusCode(200) + .header("X-Kogito-decision-messages", nullValue()) + .body("'element at index'", is("a")); } @Test void testHeaderPopulated() { given().body(" { \"a list\" : [\"a\", \"b\", \"c\"], \"an index\" : 47 }") - .contentType(ContentType.JSON) - .when() - .post("/ElementAtIndex") - .then() - .statusCode(200) - .header("X-Kogito-decision-messages", notNullValue()) // a warning - .body("'element at index'", nullValue()); + .contentType(ContentType.JSON) + .when() + .post("/ElementAtIndex") + .then() + .statusCode(200) + .header("X-Kogito-decision-messages", notNullValue()) // a warning + .body("'element at index'", nullValue()); } @Test void testGET() { given().accept(ContentType.XML) - .when() - .get("/ElementAtIndex") - .then() - .statusCode(200) - .body("definitions.decision[0].children().size()", is(4)) - .body("definitions.children().findAll { node -> node.name() == 'literalExpression' }.size()", is(0)); + .when() + .get("/ElementAtIndex") + .then() + .statusCode(200) + .body("definitions.decision[0].children().size()", is(4)) + .body("definitions.children().findAll { node -> node.name() == 'literalExpression' }.size()", is(0)); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/FaceMaskTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/FaceMaskTest.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/FaceMaskTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/FaceMaskTest.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsStatusTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsStatusTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsStatusTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsStatusTest.java index d121f7f2f6b..f7db5f8edfb 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsStatusTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsStatusTest.java @@ -23,11 +23,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; -import io.restassured.http.ContentType; - /** * Part of build certification process. Please do not remove. * Smoke test of kogito end-to-end scenarios. @@ -51,4 +51,4 @@ public void testHospitalStatus() { .statusCode(200) .body("'Current Status'", equalTo("red")); } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsTest.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/HospitalsTest.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/JavaFNctxTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/JavaFNctxTest.java similarity index 79% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/JavaFNctxTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/JavaFNctxTest.java index 8902cba0137..e0840ab6e41 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/JavaFNctxTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/JavaFNctxTest.java @@ -20,14 +20,15 @@ import java.math.BigDecimal; -import io.restassured.RestAssured; -import io.restassured.http.ContentType; -import io.restassured.path.json.config.JsonPathConfig; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import io.restassured.path.json.config.JsonPathConfig; + import static io.restassured.RestAssured.given; import static io.restassured.config.JsonConfig.jsonConfig; import static org.hamcrest.Matchers.closeTo; @@ -39,14 +40,14 @@ public class JavaFNctxTest extends BaseRestTest { @Test void testJavaFNctx() { given().config(RestAssured.config().jsonConfig(jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL))) - .body(" { \"Input\" : 3.14 }") - .contentType(ContentType.JSON) - .when() - .post("/javaFNctx") - .then() - .statusCode(200) - .body("D1", closeTo(new BigDecimal(-1), new BigDecimal(0.1))) // the scope of this test is verify Math.cos() was invoked correctly on the JDK - .body("D2", closeTo(new BigDecimal(-1), new BigDecimal(0.1))); + .body(" { \"Input\" : 3.14 }") + .contentType(ContentType.JSON) + .when() + .post("/javaFNctx") + .then() + .statusCode(200) + .body("D1", closeTo(new BigDecimal(-1), new BigDecimal(0.1))) // the scope of this test is verify Math.cos() was invoked correctly on the JDK + .body("D2", closeTo(new BigDecimal(-1), new BigDecimal(0.1))); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OASTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OASTest.java similarity index 98% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OASTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OASTest.java index 6b1227ba188..0c93b5ac5a0 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OASTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OASTest.java @@ -20,12 +20,6 @@ import java.util.List; -import io.restassured.RestAssured; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.PathItem; -import io.swagger.v3.parser.OpenAPIV3Parser; -import io.swagger.v3.parser.core.models.ParseOptions; -import io.swagger.v3.parser.core.models.SwaggerParseResult; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; @@ -33,6 +27,13 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.RestAssured; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.PathItem; +import io.swagger.v3.parser.OpenAPIV3Parser; +import io.swagger.v3.parser.core.models.ParseOptions; +import io.swagger.v3.parser.core.models.SwaggerParseResult; + import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.aMapWithSize; import static org.hamcrest.Matchers.greaterThan; @@ -64,7 +65,7 @@ public void testOASisValid() { assertThat(p2).isNotNull(); assertThat(p2.getPost()).isNotNull(); // only POST for ../dmnresult expected. } - + @Test public void testOASisSwaggerUICompatible() { String url = RestAssured.baseURI + ":" + RestAssured.port + "/v3/api-docs"; // default location from org.springdoc:springdoc-openapi-ui as used in archetype @@ -85,7 +86,7 @@ public void testOASisSwaggerUICompatible() { } @ParameterizedTest - @ValueSource(strings = {"basicAdd", + @ValueSource(strings = { "basicAdd", "DScoercion", "ElementAtIndex", "FaceMask", @@ -93,7 +94,7 @@ public void testOASisSwaggerUICompatible() { "HospitalStatus", "java_function_context", "OneOfEachType", - "StatusService"}) + "StatusService" }) public void testOASdmnDefinitions(String name) { RestAssured.given() .get("/" + name + ".json") diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OneOfEachTypeTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OneOfEachTypeTest.java similarity index 51% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OneOfEachTypeTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OneOfEachTypeTest.java index deae0ecafcd..f9f350f1cb0 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OneOfEachTypeTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/OneOfEachTypeTest.java @@ -18,21 +18,15 @@ */ package org.kie.kogito.integrationtests.springboot; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Period; - -import io.restassured.http.ContentType; -import io.restassured.RestAssured; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @ExtendWith(SpringExtension.class) @@ -46,31 +40,30 @@ class OneOfEachTypeTest extends BaseRestTest { @Test public void allTypes() { final String JSON = "{\n" + - " \"InputBoolean\": true,\n" + - " \"InputDate\": \"2020-04-02\",\n" + - " \"InputDTDuration\": \"P1D\",\n" + - " \"InputDateAndTime\": \"2020-04-02T09:00:00\",\n" + - " \"InputNumber\": 1,\n" + - " \"InputString\": \"John Doe\",\n" + - " \"InputTime\": \"09:00\",\n" + - " \"InputYMDuration\": \"P1M\"\n" + - "}"; + " \"InputBoolean\": true,\n" + + " \"InputDate\": \"2020-04-02\",\n" + + " \"InputDTDuration\": \"P1D\",\n" + + " \"InputDateAndTime\": \"2020-04-02T09:00:00\",\n" + + " \"InputNumber\": 1,\n" + + " \"InputString\": \"John Doe\",\n" + + " \"InputTime\": \"09:00\",\n" + + " \"InputYMDuration\": \"P1M\"\n" + + "}"; RestAssured.given() - .contentType(ContentType.JSON) - .accept(ContentType.JSON) - .body(JSON) - .post("/OneOfEachType") - .then() - .statusCode(200) - .body("DecisionBoolean", is(Boolean.FALSE)) - .body("DecisionDate", is("2020-04-03")) // as JSON is not schema aware, here we assert the RAW string - .body("DecisionDTDuration", is("PT48H")) - .body("DecisionDateAndTime", is("2020-04-02T10:00:00")) - .body("DecisionNumber", is(2)) - .body("DecisionString", is("Hello, John Doe")) - .body("DecisionTime", is("10:00:00")) - .body("DecisionYMDuration", is("P2M")) - ; + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(JSON) + .post("/OneOfEachType") + .then() + .statusCode(200) + .body("DecisionBoolean", is(Boolean.FALSE)) + .body("DecisionDate", is("2020-04-03")) // as JSON is not schema aware, here we assert the RAW string + .body("DecisionDTDuration", is("PT48H")) + .body("DecisionDateAndTime", is("2020-04-02T10:00:00")) + .body("DecisionNumber", is(2)) + .body("DecisionString", is("Hello, John Doe")) + .body("DecisionTime", is("10:00:00")) + .body("DecisionYMDuration", is("P2M")); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLRegressionTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLRegressionTest.java similarity index 83% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLRegressionTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLRegressionTest.java index a70f8ec22a8..527db75f929 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLRegressionTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLRegressionTest.java @@ -21,27 +21,16 @@ import java.util.Collections; import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; import io.restassured.RestAssured; -import io.restassured.http.ContentType; -import org.hamcrest.core.IsNull; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.kie.kogito.integrationtests.springboot.CommonPMMLTestUtils.testDescriptive; import static org.kie.kogito.integrationtests.springboot.CommonPMMLTestUtils.testResult; - @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) class PMMLRegressionTest extends BaseRestTest { diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLTreeTest.java b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLTreeTest.java similarity index 86% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLTreeTest.java rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLTreeTest.java index ec9e61b8123..cfb607a7ac6 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLTreeTest.java +++ b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/PMMLTreeTest.java @@ -21,20 +21,12 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; import io.restassured.RestAssured; -import io.restassured.http.ContentType; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.kie.kogito.integrationtests.springboot.CommonPMMLTestUtils.testDescriptive; import static org.kie.kogito.integrationtests.springboot.CommonPMMLTestUtils.testResult; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-decisions-it/src/test/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/pom.xml b/springboot/integration-tests/integration-tests-springboot-kafka-it/pom.xml similarity index 82% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/pom.xml rename to springboot/integration-tests/integration-tests-springboot-kafka-it/pom.xml index 767e7e39a29..96a8a6ef2e1 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-kafka-it/pom.xml @@ -22,14 +22,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.kie.kogito - integration-tests-springboot-kakfa-it - @project.version@ + + org.kie.kogito + kogito-spring-boot-integration-tests + 999-SNAPSHOT + + + integration-tests-springboot-kafka-it - @maven.compiler.release@ + integration.tests.springboot.kakfa.it - + @@ -110,9 +114,9 @@ maven-compiler-plugin - @version.compiler.plugin@ + ${version.compiler.plugin} - @maven.compiler.release@ + ${maven.compiler.release} @@ -124,7 +128,7 @@ org.springframework.boot spring-boot-maven-plugin - @version.org.springframework.boot@ + ${version.org.springframework.boot} @@ -133,13 +137,20 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + + ${project.build.outputDirectory} + + org.apache.maven.plugins maven-surefire-plugin - @version.surefire.plugin@ + ${version.surefire.plugin} - @container.image.kafka@ + ${container.image.kafka} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Address.java b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Address.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Address.java rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Address.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Traveller.java b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Traveller.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Traveller.java rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/acme/travels/Traveller.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java similarity index 78% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java index e7b7536c448..9c3f6dc9fdb 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java +++ b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java @@ -21,10 +21,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages={"org.kie.dmn.kogito.**", "org.kie.kogito.**", "com.example.**", "org.acme.examples.**", "http*.**"}) +@SpringBootApplication(scanBasePackages = { "org.acme.travels.**", "org.kie.dmn.kogito.**", "org.kie.kogito.**", "com.example.**", "org.acme.examples.**" }) public class KogitoSpringbootApplication { - public static void main(String[] args) { - SpringApplication.run(KogitoSpringbootApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/handle-approvals.bpmn b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/handle-approvals.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/handle-approvals.bpmn rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/handle-approvals.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/ping_message.bpmn b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/ping_message.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/ping_message.bpmn rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/ping_message.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/pong_message.bpmn b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/pong_message.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/main/resources/pong_message.bpmn rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/main/resources/pong_message.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java index 5f755f1888d..4c3c9a15de1 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java +++ b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java @@ -18,10 +18,11 @@ */ package org.kie.kogito.integrationtests.springboot; -import io.restassured.RestAssured; import org.junit.jupiter.api.BeforeEach; import org.springframework.boot.test.web.server.LocalServerPort; +import io.restassured.RestAssured; + public abstract class BaseRestTest { @LocalServerPort @@ -40,4 +41,4 @@ void setPort() { RestAssured.port = randomServerPort; } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java similarity index 92% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java index 5f0842b5f18..83c74e812ba 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java +++ b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java @@ -18,28 +18,26 @@ */ package org.kie.kogito.integrationtests.springboot; +import java.time.Duration; import java.util.Arrays; import java.util.List; -import java.util.Map; -import java.time.Duration; -import io.restassured.http.ContentType; + import org.junit.jupiter.api.Test; import org.kie.kogito.event.ChannelType; import org.kie.kogito.event.Topic; import org.kie.kogito.testcontainers.springboot.KafkaSpringBootTestResource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; + +import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; +import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.equalTo; -import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) -@ContextConfiguration(initializers = { KafkaSpringBootTestResource.class }) +@ContextConfiguration(initializers = { KafkaSpringBootTestResource.class }) public class PingPongMessageTest extends BaseRestTest { @Test @@ -78,8 +76,7 @@ void testPingPongBetweenProcessInstances() throws InterruptedException { .statusCode(404); } - - private void validateSubProcess(){ + private void validateSubProcess() { await().atMost(Duration.ofSeconds(10)) .untilAsserted(() -> given() .contentType(ContentType.JSON) @@ -112,7 +109,7 @@ private void validateSubProcess(){ .then() .statusCode(404); } - + @Test void verifyTopicsInformation() { final List topics = Arrays.asList(given().get("/messaging/topics").as(Topic[].class)); diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessEventIT.java b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessEventIT.java similarity index 96% rename from springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessEventIT.java rename to springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessEventIT.java index d52ddf29f70..b8add1d2412 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessEventIT.java +++ b/springboot/integration-tests/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessEventIT.java @@ -28,7 +28,6 @@ import org.acme.travels.Traveller; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.kogito.event.process.ProcessInstanceDataEvent; @@ -45,7 +44,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.cloudevents.jackson.JsonFormat; -import io.restassured.RestAssured; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; @@ -88,7 +86,7 @@ void testSaveTask() throws Exception { if ("handleApprovals".equals(data.get("processId"))) { switch (event.getType()) { case "ProcessInstanceStateDataEvent": - assertEquals("ProcessInstanceEvent", event.getType()); + assertEquals("ProcessInstanceStateDataEvent", event.getType()); assertEquals("/handleApprovals", event.getSource().toString()); assertEquals("handleApprovals", data.get("processId")); assertEquals("1.0", event.getKogitoProcessInstanceVersion()); @@ -102,7 +100,7 @@ void testSaveTask() throws Exception { assertEquals("1.0", event.getKogitoProcessInstanceVersion()); break; case "ProcessInstanceVariableDataEvent": - assertEquals("VariableInstanceEvent", event.getType()); + assertEquals("ProcessInstanceVariableDataEvent", event.getType()); assertEquals("/handleApprovals", event.getSource().toString()); assertEquals("handleApprovals", data.get("processId")); assertEquals("1.0", event.getKogitoProcessInstanceVersion()); diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/pom.xml b/springboot/integration-tests/integration-tests-springboot-norest-it/pom.xml similarity index 89% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/pom.xml rename to springboot/integration-tests/integration-tests-springboot-norest-it/pom.xml index 0b15be98596..c3136d58f3f 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/pom.xml @@ -22,9 +22,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.kie.kogito + + org.kie.kogito + kogito-spring-boot-integration-tests + 999-SNAPSHOT + + integration-tests-springboot-norest-it - @project.version@ + + + integration.tests.springboot.norest.it + @@ -102,9 +110,9 @@ maven-compiler-plugin - @version.compiler.plugin@ + ${version.compiler.plugin} - @maven.compiler.release@ + ${maven.compiler.release} @@ -116,7 +124,7 @@ org.springframework.boot spring-boot-maven-plugin - @version.org.springframework.boot@ + ${version.org.springframework.boot} @@ -128,7 +136,7 @@ org.apache.maven.plugins maven-surefire-plugin - @version.surefire.plugin@ + ${version.surefire.plugin} org/kie/kogito/integrationtests/springboot/* diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/Hello.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/Hello.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/Hello.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/Hello.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/KogitoSpringbootApplication.java similarity index 81% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/KogitoSpringbootApplication.java index e1cdda886df..8baed787dd2 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/KogitoSpringbootApplication.java +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/java/org/kie/kogito/examples/KogitoSpringbootApplication.java @@ -21,10 +21,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages={"org.kie.dmn.kogito.**", "org.kie.kogito.**", "http*.**"}) +@SpringBootApplication(scanBasePackages = { "org.kie.dmn.kogito.**", "org.kie.kogito.**", "http*.**" }) public class KogitoSpringbootApplication { - public static void main(String[] args) { - SpringApplication.run(KogitoSpringbootApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/PMMLRegression.pmml b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/PMMLRegression.pmml similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/PMMLRegression.pmml rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/PMMLRegression.pmml diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/Traffic Violation.dmn b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/Traffic Violation.dmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/Traffic Violation.dmn rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/Traffic Violation.dmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/org/kie/kogito/examples/Hello.drl b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/org/kie/kogito/examples/Hello.drl similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/org/kie/kogito/examples/Hello.drl rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/org/kie/kogito/examples/Hello.drl diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/test-process.bpmn b/springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/test-process.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/main/resources/test-process.bpmn rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/main/resources/test-process.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/NoEndpointTest.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/NoEndpointTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/NoEndpointTest.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/NoEndpointTest.java index d24024c1b9a..8b8806955e1 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/NoEndpointTest.java +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/NoEndpointTest.java @@ -20,6 +20,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.examples.KogitoSpringbootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; import io.restassured.RestAssured; import io.swagger.v3.oas.models.OpenAPI; @@ -27,11 +30,6 @@ import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; -import org.kie.kogito.examples.KogitoSpringbootApplication; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; - import static org.assertj.core.api.Assertions.assertThat; @ExtendWith(SpringExtension.class) diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/dmn/TrafficViolationTest.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/dmn/TrafficViolationTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/dmn/TrafficViolationTest.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/dmn/TrafficViolationTest.java index b78f57ff587..5686a8a7d2a 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/dmn/TrafficViolationTest.java +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/dmn/TrafficViolationTest.java @@ -21,15 +21,13 @@ import java.util.HashMap; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.dmn.api.core.DMNResult; import org.kie.kogito.decision.DecisionModel; import org.kie.kogito.decision.DecisionModels; import org.kie.kogito.examples.KogitoSpringbootApplication; - +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/drools/HelloTest.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/drools/HelloTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/drools/HelloTest.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/drools/HelloTest.java index d9502024589..534e566ba04 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/drools/HelloTest.java +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/drools/HelloTest.java @@ -22,15 +22,13 @@ import java.util.Map; import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Autowired; - +import org.drools.ruleunits.api.RuleUnit; +import org.drools.ruleunits.api.RuleUnitInstance; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.kogito.examples.Hello; import org.kie.kogito.examples.KogitoSpringbootApplication; -import org.drools.ruleunits.api.RuleUnit; -import org.drools.ruleunits.api.RuleUnitInstance; - +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/jbpm/ProcessTest.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/jbpm/ProcessTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/jbpm/ProcessTest.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/jbpm/ProcessTest.java index e65df71557d..eeb310a1de5 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/jbpm/ProcessTest.java +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/jbpm/ProcessTest.java @@ -21,9 +21,6 @@ import java.util.HashMap; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.kogito.Model; @@ -31,7 +28,8 @@ import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.process.Process; import org.kie.kogito.process.ProcessInstance; - +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/pmml/PMMLRegressionTest.java b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/pmml/PMMLRegressionTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/pmml/PMMLRegressionTest.java rename to springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/pmml/PMMLRegressionTest.java index 837d7513887..32beca3cf5c 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/pmml/PMMLRegressionTest.java +++ b/springboot/integration-tests/integration-tests-springboot-norest-it/src/test/java/org/kie/kogito/spring/pmml/PMMLRegressionTest.java @@ -21,8 +21,6 @@ import java.util.HashMap; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; - import org.assertj.core.data.Offset; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -30,7 +28,7 @@ import org.kie.kogito.examples.KogitoSpringbootApplication; import org.kie.kogito.prediction.PredictionModel; import org.kie.kogito.prediction.PredictionModels; - +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-it/pom.xml similarity index 91% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-it/pom.xml index ade9547f382..1371c640bc7 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/pom.xml @@ -22,12 +22,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.kie.kogito + + org.kie.kogito + kogito-spring-boot-integration-tests + 999-SNAPSHOT + + integration-tests-springboot-processes-it - @project.version@ - @maven.compiler.release@ + integration.tests.springboot.processes.it @@ -136,9 +140,9 @@ maven-compiler-plugin - @version.compiler.plugin@ + ${version.compiler.plugin} - @maven.compiler.release@ + ${maven.compiler.release} @@ -150,7 +154,7 @@ org.springframework.boot spring-boot-maven-plugin - @version.org.springframework.boot@ + ${version.org.springframework.boot} @@ -162,7 +166,7 @@ org.apache.maven.plugins maven-surefire-plugin - @version.surefire.plugin@ + ${version.surefire.plugin} org/kie/kogito/integrationtests/springboot/* diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Movie.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Movie.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Movie.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Movie.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/MovieGenre.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/MovieGenre.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/MovieGenre.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/MovieGenre.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Rating.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Rating.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Rating.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Rating.java diff --git a/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Address.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Address.java new file mode 100644 index 00000000000..662dfa9b9f7 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Address.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.acme.travels; + +public class Address { + + private String street; + private String city; + private String zipCode; + private String country; + + public Address() { + + } + + public Address(String street, String city, String zipCode, String country) { + super(); + this.street = street; + this.city = city; + this.zipCode = zipCode; + this.country = country; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getZipCode() { + return zipCode; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + @Override + public String toString() { + return "Address [street=" + street + ", city=" + city + ", zipCode=" + zipCode + ", country=" + country + "]"; + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Traveller.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Traveller.java new file mode 100644 index 00000000000..a4df50325a6 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Traveller.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.acme.travels; + +public class Traveller { + + private String firstName; + private String lastName; + private String email; + private String nationality; + private Address address; + + public Traveller() { + + } + + public Traveller(String firstName, String lastName, String email, String nationality) { + this(firstName, lastName, email, nationality, null); + } + + public Traveller(String firstName, String lastName, String email, String nationality, Address address) { + super(); + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.nationality = nationality; + this.address = address; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getNationality() { + return nationality; + } + + public void setNationality(String nationality) { + this.nationality = nationality; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + @Override + public String toString() { + return "Traveller [firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + ", nationality=" + + nationality + ", address=" + address + "]"; + } + +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/ApprovalResource.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/ApprovalResource.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/ApprovalResource.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/ApprovalResource.java index 78c5061baf7..31c2e5c5808 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/ApprovalResource.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/ApprovalResource.java @@ -20,15 +20,14 @@ import java.util.Map; +import org.kie.kogito.Model; +import org.kie.kogito.process.Process; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.http.ResponseEntity; - -import org.kie.kogito.Model; -import org.kie.kogito.process.Process; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/HelloService.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/HelloService.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/HelloService.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/HelloService.java index 05c9d93ad38..d49f2392ec9 100755 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/HelloService.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/HelloService.java @@ -18,11 +18,12 @@ */ package org.kie.kogito.integrationtests; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; @Component public class HelloService { diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectProcesses.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectProcesses.java similarity index 91% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectProcesses.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectProcesses.java index 57ea14583c0..df9415533f0 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectProcesses.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/SpringInjectProcesses.java @@ -18,19 +18,19 @@ */ package org.kie.kogito.integrationtests; -import org.springframework.beans.factory.annotation.Autowired; import org.kie.kogito.Application; -import org.kie.kogito.process.Processes; import org.kie.kogito.process.ProcessConfig; +import org.kie.kogito.process.Processes; +import org.springframework.beans.factory.annotation.Autowired; public class SpringInjectProcesses { @Autowired public SpringInjectProcesses(Processes processes, Application application) { - if(processes != application.get(Processes.class)) { + if (processes != application.get(Processes.class)) { throw new IllegalStateException("Processes should be injectable and same as instance application.get(Processes.class)"); } - if(application.config().get(ProcessConfig.class) == null) { + if (application.config().get(ProcessConfig.class) == null) { throw new IllegalStateException("ProcessConfig not available"); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/UnitOfWorkTestEventListener.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/UnitOfWorkTestEventListener.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/UnitOfWorkTestEventListener.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/UnitOfWorkTestEventListener.java index d3b2176dcd4..c9b8aafb693 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/UnitOfWorkTestEventListener.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/UnitOfWorkTestEventListener.java @@ -25,7 +25,6 @@ import org.kie.kogito.uow.events.UnitOfWorkEndEvent; import org.kie.kogito.uow.events.UnitOfWorkEventListener; import org.kie.kogito.uow.events.UnitOfWorkStartEvent; - import org.springframework.stereotype.Component; @Component @@ -67,4 +66,4 @@ public List getEndEvents() { public List getAbortEvents() { return abortEvents; } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java similarity index 97% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java index 7bc079282c8..c02befdcbf0 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java @@ -24,7 +24,6 @@ import org.kie.kogito.process.Process; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java similarity index 77% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java index 7d5727b54e8..0ede7da0f68 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/springboot/KogitoSpringbootApplication.java @@ -21,11 +21,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages={"org.acme.travels.**", "org.kie.dmn.kogito.**", "org.kie.kogito.**", "com" + - ".example.**", "org.acme.examples.**", "http*.**"}) +@SpringBootApplication(scanBasePackages = { "org.acme.travels.**", "org.kie.dmn.kogito.**", "org.kie.kogito.**", "com" + + ".example.**", "org.acme.examples.**", "http*.**" }) public class KogitoSpringbootApplication { - public static void main(String[] args) { - SpringApplication.run(KogitoSpringbootApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/AdHocProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/AdHocProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/BPMN2GatewayFEEL.bpmn2 b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/BPMN2GatewayFEEL.bpmn2 similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/BPMN2GatewayFEEL.bpmn2 rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/BPMN2GatewayFEEL.bpmn2 diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals-expected.svg b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals-expected.svg similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals-expected.svg rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals-expected.svg diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals.svg b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals.svg similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals.svg rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/META-INF/processSVG/approvals.svg diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/SimpleLinkTest.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/SimpleLinkTest.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/SimpleLinkTest.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/SimpleLinkTest.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/StartSignalEventStringPayload.bpmn2 b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/StartSignalEventStringPayload.bpmn2 similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/StartSignalEventStringPayload.bpmn2 rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/StartSignalEventStringPayload.bpmn2 diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/approval.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/approval.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/approval.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/approval.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/process-parent.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/process-parent.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/process-parent.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/process-parent.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/process-subprocess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/process-subprocess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/process-subprocess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/process-subprocess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/singaltest.bpmn2 b/springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/singaltest.bpmn2 similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/singaltest.bpmn2 rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/main/resources/singaltest.bpmn2 diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java similarity index 90% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java index 85ec3edcf7d..cec3f11a37e 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java @@ -21,17 +21,16 @@ import java.util.HashMap; import java.util.Map; -import io.restassured.http.ContentType; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.Matchers.emptyOrNullString; @ExtendWith(SpringExtension.class) @@ -45,13 +44,13 @@ void testUserTaskProcess() { String id = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) .header("Location", not(emptyOrNullString())) - .extract() + .extract() .path("id"); String taskId = extractID(given() @@ -60,10 +59,10 @@ void testUserTaskProcess() { .queryParam("group", "manager") .when() .post("/AdHocFragments/{pid}/AdHocTask1", id) - .then() + .then() .statusCode(201) .header("Location", not(emptyOrNullString())) - .extract() + .extract() .header("Location")); params = new HashMap<>(); @@ -86,19 +85,19 @@ void testServiceTaskProcess() { String pid = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) - .extract() + .extract() .path("id"); given() .contentType(ContentType.JSON) - .when() + .when() .post("/AdHocFragments/{pid}/Service_Task", pid) - .then() + .then() .statusCode(200) .body("var1", equalTo("Hello Kermit 5!")); } @@ -110,20 +109,20 @@ void testNonAdHocUserTaskProcess() { String pid = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) - .extract() + .extract() .path("id"); given() .contentType(ContentType.JSON) .queryParam("user", "john") - .when() + .when() .post("/AdHocFragments/{pid}/Task", pid) - .then() + .then() .statusCode(404); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java index 5f755f1888d..4c3c9a15de1 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BaseRestTest.java @@ -18,10 +18,11 @@ */ package org.kie.kogito.integrationtests.springboot; -import io.restassured.RestAssured; import org.junit.jupiter.api.BeforeEach; import org.springframework.boot.test.web.server.LocalServerPort; +import io.restassured.RestAssured; + public abstract class BaseRestTest { @LocalServerPort @@ -40,4 +41,4 @@ void setPort() { RestAssured.port = randomServerPort; } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java similarity index 90% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java index 945a4b321df..c8001ee2bb4 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java @@ -25,8 +25,8 @@ import org.acme.travels.Traveller; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess; import org.kie.kogito.integrationtests.UnitOfWorkTestEventListener; +import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -35,10 +35,9 @@ import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.emptyOrNullString; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) @@ -57,7 +56,7 @@ void assertExpectedUnitOfWorkEvents(Integer events) { assertThat(uowEventListener.getEndEvents()).hasSize(events); assertThat(uowEventListener.getAbortEvents()).isEmpty(); } - + @Test void testGeneratedId() { Map params = new HashMap<>(); @@ -65,33 +64,33 @@ void testGeneratedId() { String id = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) .body("id", not(emptyOrNullString())) .body("var1", equalTo("Kermit")) .header("Location", not(emptyOrNullString())) - .extract() + .extract() .path("id"); given() .contentType(ContentType.JSON) - .when() + .when() .get("/AdHocFragments/{id}", id) - .then() + .then() .statusCode(200) .body("id", equalTo(id)) .body("var1", equalTo("Kermit")); assertExpectedUnitOfWorkEvents(1); } - + @Test - void testWithInaccurateModel () { - - Traveller traveller = new Traveller ("Javierito","Dimequienes","pepe@pepe.com","Spanish", null); + void testWithInaccurateModel() { + + Traveller traveller = new Traveller("Javierito", "Dimequienes", "pepe@pepe.com", "Spanish", null); String processId = given() .contentType(ContentType.JSON) .body(traveller) @@ -101,7 +100,7 @@ void testWithInaccurateModel () { .statusCode(201) .extract() .path("id"); - + given() .contentType(ContentType.JSON) .queryParam("user", "admin") @@ -124,15 +123,15 @@ void testWithBusinessKey() { String id = given() .contentType(ContentType.JSON) .queryParam("businessKey", businessKey) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) .header("Location", not(emptyOrNullString())) .body("id", not(emptyOrNullString())) .body("var1", equalTo("Kermit")) - .extract() + .extract() .path("id"); // UUID is no longer the BusinessKey or generated from it @@ -142,9 +141,9 @@ void testWithBusinessKey() { given() .contentType(ContentType.JSON) - .when() + .when() .get("/AdHocFragments/{id}", id) - .then() + .then() .statusCode(200) .body("id", equalTo(id)) .body("var1", equalTo("Kermit")); @@ -159,10 +158,10 @@ void testIdNotFound() { given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .get("/AdHocFragments/FOO") - .then() + .then() .statusCode(404); assertExpectedUnitOfWorkEvents(0); @@ -175,25 +174,25 @@ void testUpdate() { String id = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) - .header("Location",not(emptyOrNullString())) + .header("Location", not(emptyOrNullString())) .body("id", not(emptyOrNullString())) .body("var1", equalTo("Kermit")) - .extract() + .extract() .path("id"); // Update the previously model params.put("var1", "Gonzo"); given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .put("/AdHocFragments/{customId}", id) - .then() + .then() .statusCode(200) .body("id", equalTo(id)) .body("var1", equalTo("Gonzo")); @@ -208,23 +207,23 @@ void testDelete() { String id = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) .header("Location", not(emptyOrNullString())) .body("id", not(emptyOrNullString())) .body("var1", equalTo("Kermit")) - .extract() + .extract() .path("id"); given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .delete("/AdHocFragments/{id}", id) - .then() + .then() .statusCode(200) .body("id", equalTo(id)) .body("var1", equalTo("Kermit")); @@ -232,10 +231,10 @@ void testDelete() { //Resource already deleted given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .delete("/AdHocFragments/{id}", id) - .then() + .then() .statusCode(404); assertExpectedUnitOfWorkEvents(3); @@ -249,21 +248,21 @@ void testGetTasks() { String id = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocFragments") - .then() + .then() .statusCode(201) .header("Location", not(emptyOrNullString())) - .extract() + .extract() .path("id"); given() .queryParam("user", "john") .queryParam("group", "manager") - .when() + .when() .get("/AdHocFragments/{id}/tasks", id) - .then() + .then() .statusCode(200) .body("$.size()", is(1)) .body("[0].name", is("Task")); diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java similarity index 94% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java index dea61421451..8d058580774 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java @@ -53,27 +53,27 @@ void testSubmitMovie() { String pid = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/cinema") - .then() + .then() .statusCode(201) .body("id", not(emptyOrNullString())) .body("movie.name", equalTo(movie.getName())) .body("movie.genre", equalTo(movie.getGenre().name())) .body("movie.rating", equalTo(movie.getRating().name())) .body("movie.releaseYear", equalTo(movie.getReleaseYear())) - .extract() + .extract() .path("id"); TaskModel task = given() .queryParam("group", "customer") - .when() + .when() .get("/cinema/{pid}/tasks", pid) - .then() + .then() .statusCode(200) .body("$.size()", is(1)) - .extract() + .extract() .as(TestWorkItem[].class)[0]; assertEquals("ReviewRatingTask", task.getName()); @@ -81,10 +81,10 @@ void testSubmitMovie() { given() .contentType(ContentType.JSON) .queryParam("group", "customer") - .when() + .when() .body(Collections.singletonMap("reviewedRating", Rating.PG_13)) .post("/cinema/{pid}/ReviewRatingTask/{taskId}", pid, task.getId()) - .then() + .then() .statusCode(200) .body("movie.rating", equalTo(Rating.PG_13.name())); } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/FlexibleProcessTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/FlexibleProcessTest.java similarity index 94% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/FlexibleProcessTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/FlexibleProcessTest.java index a9a7fdeeb4d..5daaf866689 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/FlexibleProcessTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/FlexibleProcessTest.java @@ -21,12 +21,13 @@ import java.util.HashMap; import java.util.Map; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; @@ -44,23 +45,23 @@ void testInstantiateProcess() { String pid = given() .contentType(ContentType.JSON) - .when() + .when() .body(params) .post("/AdHocProcess") - .then() + .then() .statusCode(201) .header("Location", not(emptyOrNullString())) .body("id", not(emptyOrNullString())) .body("var1", equalTo("Hello first! Script")) .body("var2", equalTo("second Script 2")) - .extract() + .extract() .path("id"); given() .contentType(ContentType.JSON) - .when() + .when() .get("/AdHocProcess/{pid}", pid) - .then() + .then() .statusCode(200); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/GatewayFEELTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/GatewayFEELTest.java similarity index 93% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/GatewayFEELTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/GatewayFEELTest.java index 7c032596bb2..78b9ff74cb8 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/GatewayFEELTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/GatewayFEELTest.java @@ -18,19 +18,13 @@ */ package org.kie.kogito.integrationtests.springboot; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Period; - -import io.restassured.RestAssured; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/LinkTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/LinkTest.java similarity index 95% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/LinkTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/LinkTest.java index bc87198ab60..d86c5c0e317 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/LinkTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/LinkTest.java @@ -20,14 +20,13 @@ import java.util.HashMap; -import io.restassured.RestAssured; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; - import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; @ExtendWith(SpringExtension.class) @@ -38,10 +37,10 @@ class LinkTest extends BaseRestTest { public void testLink() { given() .contentType(ContentType.JSON) - .when() + .when() .body(new HashMap<>()) .post("/SimpleLinkTest") - .then() + .then() .statusCode(201); } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java similarity index 87% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java index 3c45dbf9f72..25bb26eda06 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java @@ -21,13 +21,14 @@ import java.util.HashMap; import java.util.List; -import io.restassured.RestAssured; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; @@ -43,17 +44,17 @@ class ManagementAddOnTest extends BaseRestTest { private static final String HELLO1_NODE = "_3CDC6E61-DCC5-4831-8BBB-417CFF517CB0"; private static final String GREETINGS = "greetings"; - + static { RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); } - + @Test void testGetProcessNodesWithInvalidProcessId() { given().contentType(ContentType.JSON) - .when() + .when() .get("/management/processes/{processId}/nodes", "aprocess") - .then() + .then() .statusCode(404) .body(equalTo("Process with id aprocess not found")); } @@ -63,9 +64,9 @@ void testAbortProcessInstance() { String pid = givenGreetingsProcess(); given().contentType(ContentType.JSON) - .when() + .when() .delete("/management/processes/{processId}/instances/{processInstanceId}", GREETINGS, pid) - .then() + .then() .statusCode(200); } @@ -74,12 +75,12 @@ void testGetNodeInstances() { String pid = givenGreetingsProcess(); given().contentType(ContentType.JSON) - .when() + .when() .get("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances", GREETINGS, pid) - .then() + .then() .statusCode(200) .body("$.size()", is(2)) - .body("$", hasItems(hasEntry("name", "Hello1"),hasEntry("name", "Hello2"))) + .body("$", hasItems(hasEntry("name", "Hello1"), hasEntry("name", "Hello2"))) .body("[0].state", is(0)) .body("[1].state", is(0)); } @@ -87,9 +88,9 @@ void testGetNodeInstances() { @Test void testGetProcessNodes() { given().contentType(ContentType.JSON) - .when() + .when() .get("/management/processes/{processId}/nodes", GREETINGS) - .then() + .then() .statusCode(200) .body("$.size()", is(10)) .body("[0].id", is("_F8881669-9AE6-46D0-9633-02A42D3D06BB")) @@ -116,9 +117,9 @@ void testReTriggerNode() { // then trigger new node instance via management interface given().contentType(ContentType.JSON) - .when() + .when() .post("/management/processes/{processId}/instances/{processInstanceId}/nodes/{node}", GREETINGS, pid, HELLO1_NODE) - .then() + .then() .statusCode(200); // since node instance was retriggered it must have different ids @@ -130,30 +131,30 @@ void testReTriggerNode() { private String givenGreetingsProcess() { return given().contentType(ContentType.JSON) .when() - .body(new HashMap<>()) - .post("/greetings") + .body(new HashMap<>()) + .post("/greetings") .then() - .statusCode(201) - .body("id", not(emptyOrNullString())) - .body("test", emptyOrNullString()) - .header("Location", not(emptyOrNullString())) + .statusCode(201) + .body("id", not(emptyOrNullString())) + .body("test", emptyOrNullString()) + .header("Location", not(emptyOrNullString())) .extract().path("id"); } private void whenCancelNodeInstance(String pid, String nodeInstanceId) { given().contentType(ContentType.JSON) - .when() + .when() .delete("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances/{nodeInstanceId}", GREETINGS, pid, nodeInstanceId) - .then() + .then() .statusCode(200); } private List whenGetNodeInstances(String pid) { return given().contentType(ContentType.JSON) .when() - .get("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances", GREETINGS, pid) + .get("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances", GREETINGS, pid) .then() - .statusCode(200) + .statusCode(200) .extract().response().jsonPath().getList("nodeInstanceId"); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MonitoringTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MonitoringTest.java similarity index 92% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MonitoringTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MonitoringTest.java index a0c088fd95b..2b7c82fea5c 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MonitoringTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MonitoringTest.java @@ -25,11 +25,10 @@ import org.kie.kogito.KogitoGAV; import org.kie.kogito.config.ConfigBean; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; -import io.restassured.RestAssured; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; @@ -102,11 +101,13 @@ public void test() { .extract().body().asString(); assertThat(response).contains(format("kogito_work_item_duration_seconds_max{artifactId=\"%s\",name=\"MonitoringTask\",version=\"%s\",}", kogitoGAV.getArtifactId(), kogitoGAV.getVersion())); - assertThat(response).contains(format("kogito_work_item_duration_seconds_count{artifactId=\"%s\",name=\"MonitoringTask\",version=\"%s\",} 1.0", kogitoGAV.getArtifactId(), kogitoGAV.getVersion())); + assertThat(response) + .contains(format("kogito_work_item_duration_seconds_count{artifactId=\"%s\",name=\"MonitoringTask\",version=\"%s\",} 1.0", kogitoGAV.getArtifactId(), kogitoGAV.getVersion())); assertThat(response).contains(format("kogito_work_item_duration_seconds_sum{artifactId=\"%s\",name=\"MonitoringTask\",version=\"%s\",}", kogitoGAV.getArtifactId(), kogitoGAV.getVersion())); assertThat(response) - .contains(format("kogito_process_instance_completed_total{app_id=\"default-process-monitoring-listener\",artifactId=\"%s\",process_id=\"monitoring\",process_state=\"Completed\",version=\"%s\",} 1.0", + .contains(format( + "kogito_process_instance_completed_total{app_id=\"default-process-monitoring-listener\",artifactId=\"%s\",process_id=\"monitoring\",process_state=\"Completed\",version=\"%s\",} 1.0", kogitoGAV.getArtifactId(), kogitoGAV.getVersion())); assertThat(response).contains(format("kogito_process_instance_running_total{app_id=\"default-process-monitoring-listener\",artifactId=\"%s\",process_id=\"monitoring\",version=\"%s\",} 0.0", kogitoGAV.getArtifactId(), kogitoGAV.getVersion())); diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java similarity index 97% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java index a9657758fc4..0ae08b7679b 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java @@ -24,11 +24,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; -import io.restassured.RestAssured; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java similarity index 97% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java index e0c2930fd17..6620c92f459 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java @@ -18,16 +18,15 @@ */ package org.kie.kogito.integrationtests.springboot; -import io.restassured.http.ContentType; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.apache.commons.lang3.RandomStringUtils; + +import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.notNullValue; @@ -99,4 +98,4 @@ public void testParentSubProcessRest() { .when().get("/parent") .then().statusCode(200).body("$.size()", is(0)); } -} \ No newline at end of file +} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessSvgAddonTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessSvgAddonTest.java similarity index 98% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessSvgAddonTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessSvgAddonTest.java index 656fa2396f9..eca65e8e925 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessSvgAddonTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessSvgAddonTest.java @@ -25,19 +25,17 @@ import java.nio.file.Paths; import java.util.HashMap; -import org.kie.kogito.integrationtests.springboot.utils.DataIndexWireMockSpringBootTestResource; -import org.kie.kogito.test.utils.CustomSVGMatcher; - -import io.restassured.http.ContentType; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.integrationtests.springboot.utils.DataIndexWireMockSpringBootTestResource; +import org.kie.kogito.test.utils.CustomSVGMatcher; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.equalTo; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessTest.java similarity index 97% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessTest.java index 7fce7feb24e..08122e3d34e 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/ProcessTest.java @@ -25,14 +25,11 @@ import org.acme.travels.Traveller; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - -import io.restassured.RestAssured; -import io.restassured.http.ContentType; - import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchema; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/SignalProcessTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/SignalProcessTest.java similarity index 92% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/SignalProcessTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/SignalProcessTest.java index e188c5b9ff4..8614dffdc37 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/SignalProcessTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/SignalProcessTest.java @@ -20,12 +20,13 @@ import java.util.HashMap; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @@ -56,50 +57,51 @@ void testSignalStartProcess() { .body("size()", is(1)) .body("[0].message", equalTo("hello world")); } + @Test void testProcessSignals() { String pid = given() .contentType(ContentType.JSON) - .when() + .when() .body(new HashMap<>()) .post("/greetings") - .then() + .then() .statusCode(201) .body("id", not(emptyOrNullString())) .body("test", nullValue()) - .extract() + .extract() .path("id"); given() .contentType(ContentType.JSON) - .when() + .when() .body("testvalue") .post("/greetings/{pid}/signalwithdata", pid) - .then() + .then() .statusCode(200) .body("id", not(emptyOrNullString())) .body("test", is("testvalue")); given() .contentType(ContentType.JSON) - .when() + .when() .get("/greetings/{pid}", pid) - .then() + .then() .statusCode(200) .body("test", is("testvalue")); given() .contentType(ContentType.JSON) - .when() + .when() .post("/greetings/{pid}/signalwithoutdata", pid) - .then() + .then() .statusCode(200); given() .contentType(ContentType.JSON) - .when() + .when() .get("/greetings/{pid}", pid) - .then() + .then() .statusCode(404); } } diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java similarity index 98% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java index ad02446a923..aa6cdab9675 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java @@ -20,29 +20,28 @@ import java.io.IOException; import java.io.UncheckedIOException; +import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.net.URI; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.Map; import java.util.stream.Stream; -import io.restassured.http.ContentType; -import org.acme.travels.Traveller; import org.acme.travels.Address; +import org.acme.travels.Traveller; import org.jbpm.util.JsonSchemaUtil; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.kogito.process.workitem.AttachmentInfo; import org.kie.kogito.task.management.service.TaskInfo; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -58,9 +57,9 @@ public class TaskTest extends BaseRestTest { void testJsonSchema() { given() .contentType(ContentType.JSON) - .when() + .when() .get("/approvals/firstLineApproval/schema") - .then() + .then() .statusCode(200) .body(matchesJsonSchemaInClasspath("testJsonSchema/test_approvals_firstLineApproval.json")); @@ -309,8 +308,8 @@ void testSaveTask() { .statusCode(200) .extract() .as(Map.class)); - - assertEquals(true , given().contentType(ContentType.JSON) + + assertEquals(true, given().contentType(ContentType.JSON) .when() .queryParam("user", "admin") .queryParam("group", "managers") @@ -349,7 +348,6 @@ void testUpdateExcludedUsers() { .extract() .path("[0].id"); - Collection excludedUsers = Arrays.asList("Javierito", "Manuel"); given().contentType(ContentType.JSON) .when() @@ -375,7 +373,7 @@ void testUpdateExcludedUsers() { .extract() .path("excludedUsers")); } - + @Test void testUpdateTaskInfo() { Traveller traveller = new Traveller("pepe", "rubiales", "pepe.rubiales@gmail.com", "Spanish", new Address("Alfredo Di Stefano", "Madrid", "28033", "Spain")); diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TestWorkItem.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TestWorkItem.java similarity index 81% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TestWorkItem.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TestWorkItem.java index 4f57cb8509e..3fdfb1ce787 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TestWorkItem.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TestWorkItem.java @@ -19,17 +19,17 @@ package org.kie.kogito.integrationtests.springboot; import java.util.Map; -import org.kie.kogito.process.workitem.TaskModel; +import org.kie.kogito.process.workitem.TaskModel; -public class TestWorkItem implements TaskModel,Map> { -/* - * It is interesting to have an implementation of WorkItem for testing that - * the information returned by REST API is consistent with the interface definition. - * This will force us to change this class every time we change the interface and - * will automatically test that the serialization/deserialization process is ok when - * that unlikely event occurs. - */ +public class TestWorkItem implements TaskModel, Map> { + /* + * It is interesting to have an implementation of WorkItem for testing that + * the information returned by REST API is consistent with the interface definition. + * This will force us to change this class every time we change the interface and + * will automatically test that the serialization/deserialization process is ok when + * that unlikely event occurs. + */ private String id; private String name; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/utils/DataIndexWireMockSpringBootTestResource.java b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/utils/DataIndexWireMockSpringBootTestResource.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/utils/DataIndexWireMockSpringBootTestResource.java rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/utils/DataIndexWireMockSpringBootTestResource.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals.json b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals.json similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals.json rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals.json diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval.json b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval.json similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval.json rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval.json diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval_instance.json b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval_instance.json similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval_instance.json rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_approvals_firstLineApproval_instance.json diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_cinema.json b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_cinema.json similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_cinema.json rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_cinema.json diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_greetings.json b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_greetings.json similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_greetings.json rename to springboot/integration-tests/integration-tests-springboot-processes-it/src/test/resources/testJsonSchema/test_greetings.json diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/.gitignore b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/.gitignore similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/.gitignore rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/.gitignore index cd27123c4fc..a180e83ba79 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/.gitignore +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/.gitignore @@ -18,3 +18,4 @@ ### *.bpmn +*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/pom.xml similarity index 85% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/pom.xml index 95dedd0e097..1e9c9cd5df7 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/pom.xml @@ -24,7 +24,7 @@ integration-tests-springboot-processes-persistence-it org.kie.kogito - @project.version@ + 999-SNAPSHOT ../pom.xml 4.0.0 @@ -88,9 +88,23 @@ ${project.artifactId} + + maven-clean-plugin + + + + ${project.basedir}/src/main/resources + + **/*.bpmn + **/*.wid + + + + + maven-resources-plugin - @version.resources.plugin@ + ${version.resources.plugin} generate-resources @@ -98,10 +112,10 @@ copy-resources - src/main/resources + ${project.basedir}/src/main/resources - @project.basedir@/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources + ${project.parent.basedir}/integration-tests-springboot-processes-persistence-common/src/main/resources **/*.bpmn **/*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/test/java/org/kie/kogito/it/FilesystemPersistenceIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/test/java/org/kie/kogito/it/FilesystemPersistenceIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/test/java/org/kie/kogito/it/FilesystemPersistenceIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-filesystem/src/test/java/org/kie/kogito/it/FilesystemPersistenceIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/.gitignore b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/.gitignore similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/.gitignore rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/.gitignore index cd27123c4fc..a180e83ba79 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/.gitignore +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/.gitignore @@ -18,3 +18,4 @@ ### *.bpmn +*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/pom.xml similarity index 87% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/pom.xml index bd21124d47b..0339cbf99af 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/pom.xml @@ -24,7 +24,7 @@ integration-tests-springboot-processes-persistence-it org.kie.kogito - @project.version@ + 999-SNAPSHOT ../pom.xml 4.0.0 @@ -113,9 +113,23 @@ ${project.artifactId} + + maven-clean-plugin + + + + ${project.basedir}/src/main/resources + + **/*.bpmn + **/*.wid + + + + + maven-resources-plugin - @version.resources.plugin@ + ${version.resources.plugin} generate-resources @@ -123,10 +137,10 @@ copy-resources - src/main/resources + ${project.basedir}/src/main/resources - @project.basedir@/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources + ${project.parent.basedir}/integration-tests-springboot-processes-persistence-common/src/main/resources **/*.bpmn **/*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanOptimisticLockingIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanOptimisticLockingIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanOptimisticLockingIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanOptimisticLockingIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanPersistenceIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanPersistenceIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanPersistenceIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-infinispan/src/test/java/org/kie/kogito/it/InfinispanPersistenceIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/.gitignore b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/.gitignore similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/.gitignore rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/.gitignore index cd27123c4fc..a180e83ba79 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/.gitignore +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/.gitignore @@ -18,3 +18,4 @@ ### *.bpmn +*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/pom.xml similarity index 86% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/pom.xml index 93bc7d9f7a6..230c010b4b3 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/pom.xml @@ -24,7 +24,7 @@ integration-tests-springboot-processes-persistence-it org.kie.kogito - @project.version@ + 999-SNAPSHOT ../pom.xml 4.0.0 @@ -101,9 +101,23 @@ ${project.artifactId} + + maven-clean-plugin + + + + ${project.basedir}/src/main/resources + + **/*.bpmn + **/*.wid + + + + + maven-resources-plugin - @version.resources.plugin@ + ${version.resources.plugin} generate-resources @@ -111,10 +125,10 @@ copy-resources - src/main/resources + ${project.basedir}/src/main/resources - @project.basedir@/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources + ${project.parent.basedir}/integration-tests-springboot-processes-persistence-common/src/main/resources **/*.bpmn **/*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCOptimisticLockingIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCOptimisticLockingIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCOptimisticLockingIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCOptimisticLockingIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCPersistenceIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCPersistenceIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCPersistenceIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-jdbc/src/test/java/org/kie/kogito/it/JDBCPersistenceIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/.gitignore b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/.gitignore similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/.gitignore rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/.gitignore index cd27123c4fc..a180e83ba79 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/.gitignore +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/.gitignore @@ -18,3 +18,4 @@ ### *.bpmn +*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/pom.xml similarity index 85% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/pom.xml index bee96b6b910..56437bbfd91 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/pom.xml @@ -24,7 +24,7 @@ integration-tests-springboot-processes-persistence-it org.kie.kogito - @project.version@ + 999-SNAPSHOT ../pom.xml 4.0.0 @@ -97,9 +97,23 @@ ${project.artifactId} + + maven-clean-plugin + + + + ${project.basedir}/src/main/resources + + **/*.bpmn + **/*.wid + + + + + maven-resources-plugin - @version.resources.plugin@ + ${version.resources.plugin} generate-resources @@ -107,10 +121,10 @@ copy-resources - src/main/resources + ${project.basedir}/src/main/resources - @project.basedir@/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources + ${project.parent.basedir}/integration-tests-springboot-processes-persistence-common/src/main/resources **/*.bpmn **/*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBOptimisticLockingIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBOptimisticLockingIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBOptimisticLockingIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBOptimisticLockingIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBPersistenceIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBPersistenceIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBPersistenceIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-mongodb/src/test/java/org/kie/kogito/it/MongoDBPersistenceIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/pom.xml similarity index 98% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/pom.xml index b7f86fd74a1..1304230a817 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/pom.xml @@ -24,7 +24,7 @@ integration-tests-springboot-processes-persistence-it org.kie.kogito - @project.version@ + 999-SNAPSHOT ../pom.xml 4.0.0 diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Address.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Address.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Address.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Address.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/AddressType.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/AddressType.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/AddressType.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/AddressType.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/HelloService.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/HelloService.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/HelloService.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/HelloService.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Person.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Person.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Person.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Person.java index a4231e38904..c7c883727c5 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Person.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Person.java @@ -22,7 +22,6 @@ import java.math.BigDecimal; import java.time.Instant; import java.time.ZonedDateTime; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Status.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Status.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Status.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/Status.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/CustomWorkItemHandler.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/CustomWorkItemHandler.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/CustomWorkItemHandler.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/CustomWorkItemHandler.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/WIHRegister.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/WIHRegister.java similarity index 99% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/WIHRegister.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/WIHRegister.java index 2db8e864aca..fd7658e63be 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/WIHRegister.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/java/org/kie/kogito/wih/WIHRegister.java @@ -18,9 +18,8 @@ */ package org.kie.kogito.wih; -import org.springframework.stereotype.Component; - import org.kie.kogito.process.impl.DefaultWorkItemHandlerConfig; +import org.springframework.stereotype.Component; @Component public class WIHRegister extends DefaultWorkItemHandlerConfig { diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AdHocProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AdHocProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AdHocProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AdHocProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AsyncWIH.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AsyncWIH.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AsyncWIH.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/AsyncWIH.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/CustomTask.wid b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/CustomTask.wid similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/CustomTask.wid rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/CustomTask.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloActivity.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloActivity.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloActivity.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloActivity.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/HelloProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceEmbeddedSubProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceEmbeddedSubProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceEmbeddedSubProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceEmbeddedSubProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceSubProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceSubProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceSubProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/MultipleInstanceSubProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/ParallelProcess.bpmn b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/ParallelProcess.bpmn similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/ParallelProcess.bpmn rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/ParallelProcess.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/OptimisticLockingTest.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/OptimisticLockingTest.java similarity index 97% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/OptimisticLockingTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/OptimisticLockingTest.java index c4c64d07b94..a115fdecde8 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/OptimisticLockingTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/OptimisticLockingTest.java @@ -18,7 +18,7 @@ */ package org.kie.kogito.it; -import java.time.Duration; +import java.util.Map; import org.junit.jupiter.api.Test; @@ -35,6 +35,7 @@ public abstract class OptimisticLockingTest extends PersistenceTest { void testParallelPersistence() { final String pid = given().contentType(ContentType.JSON) .when() + .body(Map.of()) .post("/parallel") .then() .statusCode(201) diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java similarity index 90% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java index 38ba84d680a..7ef8b40a8e8 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java @@ -25,6 +25,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; +import java.util.Arrays; import java.util.Map; import org.junit.jupiter.api.BeforeEach; @@ -43,9 +44,8 @@ import static java.util.Arrays.asList; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.emptyOrNullString; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -160,6 +160,7 @@ void testEmbeddedProcess() { final String pId = given().contentType(ContentType.JSON) .pathParam("processId", PROCESS_EMBEDDED_ID) .when() + .body(Map.of()) .post("/{processId}") .then() .statusCode(201) @@ -167,33 +168,33 @@ void testEmbeddedProcess() { .extract() .path("id"); - String taskId = given() + given() .contentType(ContentType.JSON) - .queryParam("user", "admin") - .queryParam("group", "managers") .pathParam("pId", pId) .pathParam("processId", PROCESS_EMBEDDED_ID) .when() - .get("/{processId}/{pId}/tasks") + .get("/{processId}/{pId}") .then() - .statusCode(200) - .body("$.size()", is(1)) - .body("[0].id", not(emptyOrNullString())) - .extract() - .path("[0].id"); + .statusCode(200); - given().contentType(ContentType.JSON) + given() + .contentType(ContentType.JSON) .pathParam("pId", pId) - .pathParam("taskId", taskId) .pathParam("processId", PROCESS_EMBEDDED_ID) - .queryParam("user", "test") - .queryParam("group", "test") - .body("{}") .when() - .post("/{processId}/{pId}/Task/{taskId}/phases/complete") + .delete("/{processId}/{pId}") .then() .statusCode(200); + given() + .contentType(ContentType.JSON) + .pathParam("pId", pId) + .pathParam("processId", PROCESS_EMBEDDED_ID) + .when() + .get("/{processId}/{pId}") + .then() + .statusCode(404); + } @Test @@ -201,6 +202,7 @@ void testMultipleEmbeddedInstance() { String pId = given().contentType(ContentType.JSON) .pathParam("processId", PROCESS_MULTIPLE_INSTANCES_EMBEDDED_ID) .when() + .body(Map.of("myList", Arrays.asList("John", "Smith"))) .post("/{processId}") .then() .statusCode(201) @@ -248,6 +250,7 @@ void testMultipleInstance() { String pId = given().contentType(ContentType.JSON) .pathParam("processId", PROCESS_MULTIPLE_INSTANCES_ID) .when() + .body(Map.of("myList", Arrays.asList("John", "Smith"))) .post("/{processId}") .then() .statusCode(201) @@ -268,6 +271,7 @@ void testMultipleInstance() { void testAsyncWIH() { String pId = given().contentType(ContentType.JSON) .pathParam("processId", PROCESS_ASYNC_WIH) + .body(Map.of()) .when() .post("/{processId}") .then() @@ -299,29 +303,19 @@ void testAdHocProcess() { .extract() .path("id"); - String location = given().contentType(ContentType.JSON) + given().contentType(ContentType.JSON) .pathParam("pId", pId) .when() - .post("/AdHocProcess/{pId}/CloseTask") + .get("/AdHocProcess/{pId}") .then() - .log().everything() - .statusCode(201) - .header("Location", notNullValue()) - .extract() - .header("Location"); - - String taskId = location.substring(location.lastIndexOf("/") + 1); + .statusCode(200); - given() - .queryParam("user", "user") - .queryParam("group", "agroup") - .contentType(ContentType.JSON) + given().contentType(ContentType.JSON) + .pathParam("pId", pId) .when() - .body(Map.of("status", "closed")) - .post("/AdHocProcess/{pId}/CloseTask/{taskId}", pId, taskId) + .delete("/AdHocProcess/{pId}") .then() - .statusCode(200) - .body("status", equalTo("closed")); + .statusCode(200); given().contentType(ContentType.JSON) .pathParam("pId", pId) diff --git a/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/.gitignore b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/.gitignore new file mode 100644 index 00000000000..a180e83ba79 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/.gitignore @@ -0,0 +1,21 @@ +### +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +### + +*.bpmn +*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/pom.xml similarity index 86% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/pom.xml index bcaa22f7b23..aa161e79cd9 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/pom.xml @@ -24,7 +24,7 @@ integration-tests-springboot-processes-persistence-it org.kie.kogito - @project.version@ + 999-SNAPSHOT ../pom.xml 4.0.0 @@ -102,9 +102,23 @@ ${project.artifactId} + + maven-clean-plugin + + + + ${project.basedir}/src/main/resources + + **/*.bpmn + **/*.wid + + + + + maven-resources-plugin - @version.resources.plugin@ + ${version.resources.plugin} generate-resources @@ -112,10 +126,10 @@ copy-resources - src/main/resources + ${project.basedir}/src/main/resources - @project.basedir@/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources + ${project.parent.basedir}/integration-tests-springboot-processes-persistence-common/src/main/resources **/*.bpmn **/*.wid diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/java/org.kie.kogito.it/KogitoSpringbootApplication.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/resources/application.properties similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/resources/application.properties rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/main/resources/application.properties diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLOptimisticLockingIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLOptimisticLockingIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLOptimisticLockingIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLOptimisticLockingIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLPersistenceIT.java b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLPersistenceIT.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLPersistenceIT.java rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/src/test/java/org/kie/kogito/it/PostgreSQLPersistenceIT.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/pom.xml b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/pom.xml similarity index 82% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/pom.xml rename to springboot/integration-tests/integration-tests-springboot-processes-persistence-it/pom.xml index 6a08772528c..48e62747fba 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/pom.xml +++ b/springboot/integration-tests/integration-tests-springboot-processes-persistence-it/pom.xml @@ -22,18 +22,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.kie.kogito + + org.kie.kogito + kogito-spring-boot-integration-tests + 999-SNAPSHOT + + integration-tests-springboot-processes-persistence-it - @project.version@ + + Kogito :: Integration Tests :: Spring Boot :: Processes :: Persistence :: Parent pom - @version.org.infinispan@ - @maven.compiler.release@ - @maven.compiler.release@ - @maven.compiler.release@ - @version.jar.plugin@ + integration.tests.springboot.processes.persistence.it @@ -118,7 +120,7 @@ org.springframework.boot spring-boot-maven-plugin - @version.org.springframework.boot@ + ${version.org.springframework.boot} @@ -155,32 +157,19 @@ - - maven-clean-plugin - - - - ${project.basedir}/src/main/ - - **/*.bpmn - - - - - org.apache.maven.plugins maven-failsafe-plugin - @version.maven-surefire@ + ${version.maven-surefire} ${project.build.outputDirectory} - @container.image.infinispan@ - @container.image.kafka@ - @container.image.mongodb@ + ${container.image.infinispan} + ${container.image.kafka} + ${container.image.mongodb} @@ -196,7 +185,7 @@ org.apache.maven.plugins maven-compiler-plugin - @version.compiler.plugin@ + ${version.compiler.plugin} diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index f9e7e609891..4bf6bb95a02 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -28,169 +28,20 @@ kogito-spring-boot-integration-tests Kogito :: Integration Tests :: Spring Boot + pom **/* org.kie.kogito.springboot.starter.tests - - - - org.kie.kogito - kogito-spring-boot-bom - ${project.version} - pom - import - - - org.kie.kogito - kogito-kie-bom - ${project.version} - pom - import - - - + + integration-tests-springboot-decisions-it + integration-tests-springboot-kafka-it + integration-tests-springboot-norest-it + integration-tests-springboot-processes-it + integration-tests-springboot-processes-persistence-it + - - - - - org.kie.kogito - kogito-bom - ${project.version} - pom - - - org.kie.kogito - kogito-spring-boot-bom - ${project.version} - pom - - - org.kie.kogito - kogito-kie-bom - ${project.version} - pom - - - org.kie.kogito - kogito-serverless-workflow-openapi-common - - - org.kie.kogito - kogito-maven-plugin - - - org.drools - drools-decisions-spring-boot-starter - - - org.kie - kie-predictions-spring-boot-starter - - - org.kie - kie-addons-springboot-messaging - - - org.kie.kogito - kogito-spring-boot-test-utils - - - org.kie - kie-addons-springboot-monitoring-prometheus - - - org.jbpm - jbpm-with-drools-spring-boot-starter - - - org.jbpm - jbpm-spring-boot-starter - - - org.kie - kie-addons-springboot-process-management - - - org.jbpm - jbpm-addons-springboot-task-management - - - org.kie - kie-addons-springboot-process-svg - - - org.kie - kie-addons-springboot-events-process-kafka - - - - org.kie - kie-addons-springboot-persistence-infinispan - - - org.kie - kie-addons-springboot-persistence-postgresql - - - org.kie - kie-addons-springboot-persistence-mongodb - - - org.kie - kie-addons-springboot-persistence-jdbc - - - org.kie - kie-addons-springboot-persistence-filesystem - - - org.kie - kie-core-bom - pom - - - org.kie - kie-dmn-bom - pom - - - org.drools - drools-bom - pom - - - - - - - - - maven-invoker-plugin - - true - verify - - - - - - - maven-invoker-plugin - - - integration-test - - install - run - - - - - - diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/pom.xml b/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/pom.xml deleted file mode 100644 index 67b083de821..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-decisions-it/pom.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - 4.0.0 - - org.kie.kogito - integration-tests-springboot-decisions-it - @project.version@ - - - @maven.compiler.release@ - - - - - - org.kie.kogito - kogito-spring-boot-bom - ${project.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter - - - - org.drools - drools-decisions-spring-boot-starter - - - - org.kie - kie-predictions-spring-boot-starter - - - - org.kie - kie-addons-springboot-monitoring-prometheus - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - - org.junit.jupiter - junit-jupiter-engine - test - - - - io.rest-assured - rest-assured - test - - - - org.kie.kogito - kogito-spring-boot-test-utils - test - - - - org.springdoc - springdoc-openapi-starter-webmvc-ui - - - io.swagger.parser.v3 - swagger-parser - test - - - io.swagger.parser.v3 - swagger-parser-v2-converter - - - - - - - - ${project.artifactId} - - - maven-compiler-plugin - @version.compiler.plugin@ - - @maven.compiler.release@ - - - - org.kie.kogito - kogito-maven-plugin - ${project.version} - true - - - org.springframework.boot - spring-boot-maven-plugin - @version.org.springframework.boot@ - - - - repackage - - - - - - org.apache.maven.plugins - maven-surefire-plugin - @version.surefire.plugin@ - - - org/kie/kogito/integrationtests/springboot/* - - - - - - diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/invoker.properties b/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/invoker.properties deleted file mode 100644 index 35f50068472..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-kafka-it/invoker.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -# disable verbose local download output -invoker.mavenOpts=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/invoker.properties b/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/invoker.properties deleted file mode 100644 index 35f50068472..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-norest-it/invoker.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -# disable verbose local download output -invoker.mavenOpts=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/invoker.properties b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/invoker.properties deleted file mode 100644 index 35f50068472..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/invoker.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -# disable verbose local download output -invoker.mavenOpts=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Address.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Address.java deleted file mode 100644 index b2e75caba15..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Address.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.acme.travels; - -public class Address { - - private String street; - private String city; - private String zipCode; - private String country; - - public Address() { - - } - - public Address(String street, String city, String zipCode, String country) { - super(); - this.street = street; - this.city = city; - this.zipCode = zipCode; - this.country = country; - } - - public String getStreet() { - return street; - } - - public void setStreet(String street) { - this.street = street; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getZipCode() { - return zipCode; - } - - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - @Override - public String toString() { - return "Address [street=" + street + ", city=" + city + ", zipCode=" + zipCode + ", country=" + country + "]"; - } -} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Traveller.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Traveller.java deleted file mode 100644 index 9f49de8cd0f..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/travels/Traveller.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.acme.travels; - -public class Traveller { - - private String firstName; - private String lastName; - private String email; - private String nationality; - private Address address; - - public Traveller() { - - } - - public Traveller(String firstName, String lastName, String email, String nationality) { - this(firstName, lastName, email, nationality, null); - } - - public Traveller(String firstName, String lastName, String email, String nationality, Address address) { - super(); - this.firstName = firstName; - this.lastName = lastName; - this.email = email; - this.nationality = nationality; - this.address = address; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getNationality() { - return nationality; - } - - public void setNationality(String nationality) { - this.nationality = nationality; - } - - public Address getAddress() { - return address; - } - - public void setAddress(Address address) { - this.address = address; - } - - @Override - public String toString() { - return "Traveller [firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + ", nationality=" - + nationality + ", address=" + address + "]"; - } - -} diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/.gitignore b/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/.gitignore deleted file mode 100644 index cd27123c4fc..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-postgresql/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -### -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -### - -*.bpmn diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/invoker.properties b/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/invoker.properties deleted file mode 100644 index ee81a7c516d..00000000000 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-persistence-it/invoker.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -# disable verbose local download output -invoker.mavenOpts=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ No newline at end of file