From a460426a4b995864d7b419024c4433d2fc821d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Wed, 16 Oct 2024 09:41:26 +0200 Subject: [PATCH 1/9] incubator-kie-issues#1545: Create JPA persistence layer for Human Tasks --- .../common/jbpm-usertask-storage-jpa/pom.xml | 63 +++ .../usertask/jpa/JPAUserTaskInstances.java | 125 +++++ .../jpa/mapper/AttachmentsEntityMapper.java | 73 +++ .../jpa/mapper/CommentsEntityMapper.java | 72 +++ .../jpa/mapper/TaskInputsEntityMapper.java | 73 +++ .../jpa/mapper/TaskMetadataEntityMapper.java | 71 +++ .../jpa/mapper/TaskOutputsEntityMapper.java | 73 +++ .../mapper/UserTaskInstanceEntityMapper.java | 101 ++++ .../jpa/mapper/json/utils/JSONUtils.java | 54 ++ .../usertask/jpa/model/AttachmentEntity.java | 95 ++++ .../usertask/jpa/model/CommentEntity.java | 85 +++ .../jpa/model/TaskMetadataEntity.java | 95 ++++ .../jpa/model/UserTaskInstanceEntity.java | 337 +++++++++++ .../model/data/AbstractTaskDataEntity.java | 76 +++ .../jpa/model/data/TaskInputEntity.java | 47 ++ .../jpa/model/data/TaskOutputEntity.java | 48 ++ .../jpa/repository/AttachmentRepository.java | 34 ++ .../jpa/repository/BaseRepository.java | 63 +++ .../jpa/repository/CommentRepository.java | 34 ++ .../jpa/repository/TaskInputRepository.java | 34 ++ .../repository/TaskMetadataRepository.java | 34 ++ .../jpa/repository/TaskOutputRepository.java | 34 ++ .../UserTaskInstanceRepository.java | 48 ++ .../jpa/repository/UserTaskJPAContext.java | 27 + .../src/main/resources/META-INF/beans.xml | 0 .../resources/META-INF/kie-flyway.properties | 23 + .../h2/V1.0.0__jBPM_user_task_create.sql | 172 ++++++ .../V1.0.0__jBPM_user_task_create.sql | 170 ++++++ addons/common/pom.xml | 1 + .../kie/kogito/auth/IdentityProviders.java | 5 +- .../kogito/usertask/UserTaskInstances.java | 2 +- .../canonical/WorkItemModelMetaData.java | 5 +- .../UserTaskKogitoWorkItemHandler.java | 7 +- .../usertask/impl/AbstractUserTask.java | 3 +- .../impl/DefaultUserTaskInstance.java | 3 +- .../impl/InMemoryUserTaskInstances.java | 9 +- kogito-bom/pom.xml | 46 ++ kogito-build/kogito-dependencies-bom/pom.xml | 8 + quarkus/addons/flyway/deployment/pom.xml | 1 + .../deployment/pom.xml | 110 ++++ ...MUserTaskStorageJPAExtensionProcessor.java | 40 ++ .../integration-tests/pom.xml | 149 +++++ .../main/java/org/acme/travels/Address.java | 76 +++ .../main/java/org/acme/travels/Traveller.java | 88 +++ .../src/main/resources/application.properties | 24 + .../src/main/resources/approval.bpmn | 304 ++++++++++ .../jpa/it/JBPMUserTaskJPAStorageIT.java | 82 +++ .../src/test/resources/application.properties | 0 .../addons/jbpm-usertask-storage-jpa/pom.xml | 46 ++ .../jbpm-usertask-storage-jpa/runtime/pom.xml | 169 ++++++ .../jpa/QuarkusJPAUserTaskInstances.java | 41 ++ .../QuarkusAttachmentsEntityMapper.java | 38 ++ .../mapper/QuarkusCommentsEntityMapper.java | 38 ++ .../mapper/QuarkusTaskInputsEntityMapper.java | 38 ++ .../QuarkusTaskMetadataEntityMapper.java | 38 ++ .../QuarkusTaskOutputsEntityMapper.java | 38 ++ .../QuarkusUserTaskInstanceEntityMapper.java | 37 ++ .../QuarkusAttachmentRepository.java | 38 ++ .../repository/QuarkusCommentRepository.java | 38 ++ .../QuarkusTaskInputEntityRepository.java | 37 ++ .../QuarkusTaskMetadataEntityRepository.java | 37 ++ .../QuarkusTaskOutputEntityRepository.java | 37 ++ .../QuarkusUserTaskInstanceRepository.java | 38 ++ .../repository/QuarkusUserTaskJPAContext.java | 38 ++ .../src/main/resources/META-INF/beans.xml | 20 + .../resources/META-INF/quarkus-extension.yaml | 37 ++ .../BaseQuarkusJPAUserTaskInstancesTest.java | 528 ++++++++++++++++++ .../H2QuarkusJPAUserTaskInstancesTest.java | 33 ++ .../usertask/jpa/H2QuarkusTestProfile.java | 30 + ...greSQLQuarkusJPAUserTaskInstancesTest.java | 35 ++ .../jpa/PostgreSQLQuarkusTestProfile.java | 30 + .../org/jbpm/usertask/jpa/models/Person.java | 76 +++ .../src/test/resources/META-INF/beans.xml | 0 .../src/test/resources/application.properties | 28 + quarkus/addons/pom.xml | 1 + 75 files changed, 4675 insertions(+), 13 deletions(-) create mode 100644 addons/common/jbpm-usertask-storage-jpa/pom.xml create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/json/utils/JSONUtils.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/AttachmentEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/CommentEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/beans.xml create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/kie-flyway.properties create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/deployment/pom.xml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Address.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/pom.xml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/beans.xml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/META-INF/beans.xml create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/application.properties diff --git a/addons/common/jbpm-usertask-storage-jpa/pom.xml b/addons/common/jbpm-usertask-storage-jpa/pom.xml new file mode 100644 index 00000000000..dd1a487512f --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + org.kie + kogito-addons-common-parent + 999-SNAPSHOT + + + org.jbpm + jbpm-addons-usertask-storage-jpa + + jBPM :: Add-Ons :: User Task Storage JPA :: Common + jBPM Add-Ons User Task Storage JPA Common + + + UTF-8 + org.jbpm.usertask.storage.jpa + + + + + jakarta.persistence + jakarta.persistence-api + + + org.slf4j + slf4j-api + + + org.kie.kogito + kogito-api + + + org.kie.kogito + jbpm-usertask + + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter-params + test + + + ch.qos.logback + logback-classic + test + + + org.assertj + assertj-core + test + + + + diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java new file mode 100644 index 00000000000..0540bf05d2e --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java @@ -0,0 +1,125 @@ +/* + * 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.jbpm.usertask.jpa; + +import java.util.*; +import java.util.function.Function; + +import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.kie.kogito.auth.IdentityProvider; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.UserTaskInstances; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class JPAUserTaskInstances implements UserTaskInstances { + public static final Logger LOGGER = LoggerFactory.getLogger(JPAUserTaskInstances.class); + + private final UserTaskInstanceRepository userTaskInstanceRepository; + private final UserTaskInstanceEntityMapper userTaskInstanceEntityMapper; + + private Function reconnectUserTaskInstance; + private Function disconnectUserTaskInstance; + + public JPAUserTaskInstances(UserTaskInstanceRepository userTaskInstanceRepository, UserTaskInstanceEntityMapper userTaskInstanceEntityMapper) { + this.userTaskInstanceRepository = userTaskInstanceRepository; + this.userTaskInstanceEntityMapper = userTaskInstanceEntityMapper; + } + + @Override + public Optional findById(String userTaskInstanceId) { + return this.userTaskInstanceRepository.findById(userTaskInstanceId) + .map(userTaskInstanceEntityMapper::mapTaskEntityToInstance) + .map(reconnectUserTaskInstance); + } + + @Override + public List findByIdentity(IdentityProvider identityProvider) { + return userTaskInstanceRepository.findByIdentity(identityProvider) + .stream() + .map(userTaskInstanceEntityMapper::mapTaskEntityToInstance) + .map(reconnectUserTaskInstance) + .toList(); + } + + @Override + public boolean exists(String userTaskInstanceId) { + return userTaskInstanceRepository.findById(userTaskInstanceId).isPresent(); + } + + @Override + public UserTaskInstance create(UserTaskInstance userTaskInstance) { + + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + entity.setId(userTaskInstance.getId()); + + this.userTaskInstanceRepository.persist(entity); + + userTaskInstanceEntityMapper.mapTaskInstanceToEntity(userTaskInstance, entity); + + this.userTaskInstanceRepository.update(entity); + + return this.reconnectUserTaskInstance.apply(userTaskInstance); + } + + @Override + public UserTaskInstance update(UserTaskInstance userTaskInstance) { + + Optional optional = userTaskInstanceRepository.findById(userTaskInstance.getId()); + + if (optional.isEmpty()) { + LOGGER.error("Could not find userTaskInstance with id {}", userTaskInstance.getId()); + throw new RuntimeException("Could not find userTaskInstance with id " + userTaskInstance.getId()); + } + + UserTaskInstanceEntity userTaskInstanceEntity = optional.get(); + + userTaskInstanceEntityMapper.mapTaskInstanceToEntity(userTaskInstance, userTaskInstanceEntity); + + userTaskInstanceRepository.update(userTaskInstanceEntity); + + return userTaskInstance; + } + + @Override + public UserTaskInstance remove(UserTaskInstance userTaskInstance) { + Optional optional = userTaskInstanceRepository.findById(userTaskInstance.getId()); + + if (optional.isEmpty()) { + LOGGER.warn("Could not remove userTaskInstance with id {}, task cannot be found", userTaskInstance.getId()); + throw new RuntimeException("Could not remove userTaskInstance with id " + userTaskInstance.getId() + ", userTaskInstance cannot be found"); + } + + this.userTaskInstanceRepository.remove(optional.get()); + return this.disconnectUserTaskInstance.apply(userTaskInstance); + } + + @Override + public void setReconnectUserTaskInstance(Function reconnectUserTaskInstance) { + this.reconnectUserTaskInstance = reconnectUserTaskInstance; + } + + @Override + public void setDisconnectUserTaskInstance(Function disconnectUserTaskInstance) { + this.disconnectUserTaskInstance = disconnectUserTaskInstance; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java new file mode 100644 index 00000000000..aa706319253 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java @@ -0,0 +1,73 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.net.URI; +import java.util.Collection; + +import org.jbpm.usertask.jpa.model.AttachmentEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.model.Attachment; + +public class AttachmentsEntityMapper { + private final AttachmentRepository repository; + + public AttachmentsEntityMapper(AttachmentRepository repository) { + this.repository = repository; + } + + public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + Collection toRemove = userTaskInstanceEntity.getAttachments() + .stream() + .filter(entity -> userTaskInstance.getAttachments().stream().noneMatch(attachment -> attachment.getId().equals(entity.getId()))) + .toList(); + + toRemove.forEach(attachment -> { + repository.remove(attachment); + userTaskInstanceEntity.removeAttachment(attachment); + }); + + userTaskInstance.getAttachments().forEach(attachment -> { + AttachmentEntity attachmentEntity = userTaskInstanceEntity.getAttachments().stream().filter(entity -> entity.getId().equals(attachment.getId())).findFirst().orElseGet(() -> { + AttachmentEntity entity = new AttachmentEntity(); + userTaskInstanceEntity.addAttachment(entity); + return entity; + }); + attachmentEntity.setId(attachment.getId()); + attachmentEntity.setUpdatedBy(attachment.getUpdatedBy()); + attachmentEntity.setName(attachment.getName()); + attachmentEntity.setUrl(attachment.getContent().toString()); + attachmentEntity.setUpdatedAt(attachment.getUpdatedAt()); + }); + } + + public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + userTaskInstance.getAttachments().clear(); + userTaskInstanceEntity.getAttachments().forEach(attachmentEntity -> { + Attachment attachment = new Attachment(attachmentEntity.getId(), attachmentEntity.getUpdatedBy()); + attachment.setId(attachmentEntity.getId()); + attachment.setContent(URI.create(attachmentEntity.getUrl())); + attachment.setUpdatedAt(attachmentEntity.getUpdatedAt()); + userTaskInstance.addAttachment(attachment); + }); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java new file mode 100644 index 00000000000..309463894c6 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java @@ -0,0 +1,72 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.util.Collection; + +import org.jbpm.usertask.jpa.model.CommentEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.model.Comment; + +public class CommentsEntityMapper { + + private final CommentRepository repository; + + public CommentsEntityMapper(CommentRepository repository) { + this.repository = repository; + } + + public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + Collection toRemove = userTaskInstanceEntity.getComments() + .stream() + .filter(entity -> userTaskInstance.getComments().stream().noneMatch(comment -> comment.getId().equals(entity.getId()))) + .toList(); + + toRemove.forEach(comment -> { + repository.remove(comment); + userTaskInstanceEntity.removeComment(comment); + }); + + userTaskInstance.getComments().forEach(comment -> { + CommentEntity commentEntity = userTaskInstanceEntity.getComments().stream().filter(entity -> entity.getId().equals(comment.getId())).findFirst().orElseGet(() -> { + CommentEntity entity = new CommentEntity(); + userTaskInstanceEntity.addComment(entity); + return entity; + }); + commentEntity.setId(comment.getId()); + commentEntity.setUpdatedBy(comment.getUpdatedBy()); + commentEntity.setComment(comment.getContent()); + commentEntity.setUpdatedAt(comment.getUpdatedAt()); + }); + } + + public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + userTaskInstance.getComments().clear(); + userTaskInstanceEntity.getComments().forEach(commentEntity -> { + Comment comment = new Comment(commentEntity.getId(), commentEntity.getUpdatedBy()); + comment.setId(commentEntity.getId()); + comment.setContent(commentEntity.getComment()); + comment.setUpdatedAt(commentEntity.getUpdatedAt()); + userTaskInstance.addComment(comment); + }); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java new file mode 100644 index 00000000000..d1f83596d05 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java @@ -0,0 +1,73 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Objects; + +import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.model.data.TaskInputEntity; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.kie.kogito.usertask.UserTaskInstance; + +public class TaskInputsEntityMapper { + + private TaskInputRepository repository; + + public TaskInputsEntityMapper(TaskInputRepository repository) { + this.repository = repository; + } + + public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + Collection toRemove = userTaskInstanceEntity.getInputs() + .stream() + .filter(entity -> !userTaskInstance.getInputs().containsKey(entity.getName())) + .toList(); + + toRemove.forEach(input -> { + repository.remove(input); + userTaskInstanceEntity.removeInput(input); + }); + + userTaskInstance.getInputs().forEach((key, value) -> { + TaskInputEntity inputEntity = userTaskInstanceEntity.getInputs().stream().filter(entity -> entity.getName().equals(key)).findFirst().orElseGet(() -> { + TaskInputEntity entity = new TaskInputEntity(); + userTaskInstanceEntity.addInput(entity); + return entity; + }); + inputEntity.setName(key); + if (Objects.nonNull(value)) { + inputEntity.setValue(JSONUtils.valueToString(value).getBytes(StandardCharsets.UTF_8)); + inputEntity.setJavaType(value.getClass().getName()); + } + }); + } + + public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + userTaskInstance.getInputs().clear(); + + userTaskInstanceEntity.getInputs().forEach(taskInputEntity -> { + String value = taskInputEntity.getValue() == null ? null : new String(taskInputEntity.getValue(), StandardCharsets.UTF_8); + userTaskInstance.getInputs().put(taskInputEntity.getName(), value); + }); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java new file mode 100644 index 00000000000..c8f0b41e88d --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.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.jbpm.usertask.jpa.mapper; + +import java.util.Collection; +import java.util.Objects; + +import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; +import org.jbpm.usertask.jpa.model.TaskMetadataEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.kie.kogito.usertask.UserTaskInstance; + +public class TaskMetadataEntityMapper { + + private final TaskMetadataRepository repository; + + public TaskMetadataEntityMapper(TaskMetadataRepository repository) { + this.repository = repository; + } + + public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + Collection toRemove = userTaskInstanceEntity.getMetadata() + .stream() + .filter(entity -> !userTaskInstance.getMetadata().containsKey(entity.getName())) + .toList(); + + toRemove.forEach(metadata -> { + repository.remove(metadata); + userTaskInstanceEntity.removeMetadata(metadata); + }); + + userTaskInstance.getMetadata().forEach((key, value) -> { + TaskMetadataEntity metadataEntity = userTaskInstanceEntity.getMetadata().stream().filter(entity -> entity.getName().equals(key)).findFirst().orElseGet(() -> { + TaskMetadataEntity entity = new TaskMetadataEntity(); + userTaskInstanceEntity.addMetadata(entity); + return entity; + }); + metadataEntity.setName(key); + if (Objects.nonNull(value)) { + metadataEntity.setValue(JSONUtils.valueToString(value)); + metadataEntity.setJavaType(value.getClass().getName()); + } + }); + } + + public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + userTaskInstance.getMetadata().clear(); + userTaskInstanceEntity.getMetadata().forEach(metadataEntity -> { + Object value = JSONUtils.stringTreeToValue(metadataEntity.getValue(), metadataEntity.getJavaType()); + userTaskInstance.getMetadata().put(metadataEntity.getName(), value); + }); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java new file mode 100644 index 00000000000..011077bc67e --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java @@ -0,0 +1,73 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Objects; + +import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.model.data.TaskOutputEntity; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.kie.kogito.usertask.UserTaskInstance; + +public class TaskOutputsEntityMapper { + + private final TaskOutputRepository repository; + + public TaskOutputsEntityMapper(TaskOutputRepository repository) { + this.repository = repository; + } + + public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + Collection toRemove = userTaskInstanceEntity.getOutputs() + .stream() + .filter(entity -> !userTaskInstance.getOutputs().containsKey(entity.getName())) + .toList(); + + toRemove.forEach(output -> { + repository.remove(output); + userTaskInstanceEntity.removeOutput(output); + }); + + userTaskInstance.getOutputs().forEach((key, value) -> { + TaskOutputEntity outputEntity = userTaskInstanceEntity.getOutputs().stream().filter(entity -> entity.getName().equals(key)).findFirst().orElseGet(() -> { + TaskOutputEntity entity = new TaskOutputEntity(); + userTaskInstanceEntity.addOutput(entity); + return entity; + }); + outputEntity.setName(key); + if (Objects.nonNull(value)) { + outputEntity.setValue(JSONUtils.valueToString(value).getBytes(StandardCharsets.UTF_8)); + outputEntity.setJavaType(value.getClass().getName()); + } + }); + } + + public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + userTaskInstance.getOutputs().clear(); + + userTaskInstanceEntity.getOutputs().forEach(TaskOutputEntity -> { + String value = TaskOutputEntity.getValue() == null ? null : new String(TaskOutputEntity.getValue(), StandardCharsets.UTF_8); + userTaskInstance.getOutputs().put(TaskOutputEntity.getName(), value); + }); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java new file mode 100644 index 00000000000..b77b10abbdb --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java @@ -0,0 +1,101 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.util.Set; + +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; +import org.kie.kogito.usertask.lifecycle.UserTaskState; + +public class UserTaskInstanceEntityMapper { + + private final AttachmentsEntityMapper attachmentsMapper; + private final CommentsEntityMapper commentMapper; + private final TaskInputsEntityMapper taskInputsMapper; + private final TaskOutputsEntityMapper taskOutputsMapper; + private final TaskMetadataEntityMapper taskMetadataMapper; + + public UserTaskInstanceEntityMapper(AttachmentsEntityMapper attachmentsMapper, CommentsEntityMapper commentsMapper, TaskMetadataEntityMapper taskMetadataMapper, + TaskInputsEntityMapper taskInputsMapper, TaskOutputsEntityMapper taskOutputMapper) { + this.attachmentsMapper = attachmentsMapper; + this.commentMapper = commentsMapper; + this.taskMetadataMapper = taskMetadataMapper; + this.taskInputsMapper = taskInputsMapper; + this.taskOutputsMapper = taskOutputMapper; + } + + public UserTaskInstanceEntity mapTaskInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInstanceEntity entity) { + entity.setId(userTaskInstance.getId()); + entity.setTaskName(userTaskInstance.getTaskName()); + entity.setTaskDescription(userTaskInstance.getTaskDescription()); + entity.setTaskPriority(userTaskInstance.getTaskPriority()); + entity.setStatus(userTaskInstance.getStatus().getName()); + entity.setTerminationType(userTaskInstance.getStatus().getTerminate() == null ? null : userTaskInstance.getStatus().getTerminate().name()); + entity.setExternalReferenceId(userTaskInstance.getExternalReferenceId()); + entity.setUserTaskId(userTaskInstance.getUserTaskId()); + + entity.setActualOwner(userTaskInstance.getActualOwner()); + entity.setPotentialUsers(Set.copyOf(userTaskInstance.getPotentialUsers())); + entity.setPotentialGroups(Set.copyOf(userTaskInstance.getPotentialGroups())); + entity.setAdminUsers(Set.copyOf(userTaskInstance.getAdminUsers())); + entity.setAdminGroups(Set.copyOf(userTaskInstance.getAdminGroups())); + entity.setExcludedUsers(Set.copyOf(userTaskInstance.getExcludedUsers())); + + attachmentsMapper.mapInstanceToEntity(userTaskInstance, entity); + commentMapper.mapInstanceToEntity(userTaskInstance, entity); + taskInputsMapper.mapInstanceToEntity(userTaskInstance, entity); + taskOutputsMapper.mapInstanceToEntity(userTaskInstance, entity); + taskMetadataMapper.mapInstanceToEntity(userTaskInstance, entity); + + return entity; + } + + public UserTaskInstance mapTaskEntityToInstance(UserTaskInstanceEntity entity) { + + DefaultUserTaskInstance instance = new DefaultUserTaskInstance(); + + instance.setId(entity.getId()); + instance.setUserTaskId(entity.getUserTaskId()); + instance.setExternalReferenceId(entity.getExternalReferenceId()); + instance.setTaskName(entity.getTaskName()); + instance.setTaskDescription(entity.getTaskDescription()); + instance.setTaskPriority(entity.getTaskPriority()); + + UserTaskState.TerminationType terminationType = entity.getTerminationType() == null ? null : UserTaskState.TerminationType.valueOf(entity.getTerminationType()); + instance.setStatus(UserTaskState.of(entity.getStatus(), terminationType)); + + instance.setActuaOwner(entity.getActualOwner()); + instance.setPotentialUsers(Set.copyOf(entity.getPotentialUsers())); + instance.setPotentialGroups(Set.copyOf(entity.getPotentialGroups())); + instance.setAdminUsers(Set.copyOf(entity.getAdminUsers())); + instance.setAdminGroups(Set.copyOf(entity.getAdminGroups())); + instance.setExcludedUsers(Set.copyOf(entity.getExcludedUsers())); + + attachmentsMapper.mapEntityToInstance(entity, instance); + commentMapper.mapEntityToInstance(entity, instance); + taskInputsMapper.mapEntityToInstance(entity, instance); + taskOutputsMapper.mapEntityToInstance(entity, instance); + taskMetadataMapper.mapEntityToInstance(entity, instance); + + return instance; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/json/utils/JSONUtils.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/json/utils/JSONUtils.java new file mode 100644 index 00000000000..b7e33589800 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/json/utils/JSONUtils.java @@ -0,0 +1,54 @@ +/* + * 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.jbpm.usertask.jpa.mapper.json.utils; + +import java.util.Objects; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +public class JSONUtils { + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + static { + OBJECT_MAPPER.registerModule(new JavaTimeModule()); + } + + public static String valueToString(Object value) { + try { + return OBJECT_MAPPER.writeValueAsString(value); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public static Object stringTreeToValue(String value, String javaType) { + try { + if (Objects.isNull(value) || Objects.isNull(javaType)) { + return null; + } + return OBJECT_MAPPER.readValue(value, Class.forName(javaType)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/AttachmentEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/AttachmentEntity.java new file mode 100644 index 00000000000..a0bff107682 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/AttachmentEntity.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.jbpm.usertask.jpa.model; + +import java.util.Date; + +import jakarta.persistence.*; + +@Entity +@Table(name = "jbpm_user_tasks_attachments") +public class AttachmentEntity { + + @Id + private String id; + + private String name; + + private String url; + + @Column(name = "updated_by") + private String updatedBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "updated_at") + private Date updatedAt; + + @ManyToOne + @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "fk_user_task_attachment_tid")) + private UserTaskInstanceEntity taskInstance; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/CommentEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/CommentEntity.java new file mode 100644 index 00000000000..cf70f4e7bca --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/CommentEntity.java @@ -0,0 +1,85 @@ +/* + * 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.jbpm.usertask.jpa.model; + +import java.util.Date; + +import jakarta.persistence.*; + +@Entity +@Table(name = "jbpm_user_tasks_comments") +public class CommentEntity { + + @Id + private String id; + + private String comment; + + @Column(name = "updated_by") + private String updatedBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "updated_at") + private Date updatedAt; + + @ManyToOne(optional = false) + @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "fk_user_task_comment_tid")) + private UserTaskInstanceEntity taskInstance; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String user) { + this.updatedBy = user; + } + + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java new file mode 100644 index 00000000000..5bcff9c2afe --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.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.jbpm.usertask.jpa.model; + +import java.util.Objects; + +import jakarta.persistence.*; + +@Entity +@Table(name = "jbpm_user_tasks_metadata") +@SequenceGenerator(name = "jbpm_user_task_metadata_id_seq", sequenceName = "jbpm_user_task_metadata_id_seq") +public class TaskMetadataEntity { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "jbpm_user_task_metadata_id_seq") + private Long id; + + @Column(name = "metadata_name") + protected String name; + + @Column(name = "metadata_value") + protected String value; + + @Column(name = "java_type") + protected String javaType; + + @ManyToOne(optional = false) + @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_metadata_tid")) + private UserTaskInstanceEntity taskInstance; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getJavaType() { + return javaType; + } + + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + TaskMetadataEntity that = (TaskMetadataEntity) o; + return Objects.equals(name, that.name) && Objects.equals(value, that.value) && Objects.equals(javaType, that.javaType) && Objects.equals(taskInstance, + that.taskInstance); + } + + @Override + public int hashCode() { + return Objects.hash(name, value, javaType, taskInstance); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java new file mode 100644 index 00000000000..b5d54fce40d --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java @@ -0,0 +1,337 @@ +/* + * 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.jbpm.usertask.jpa.model; + +import java.util.*; + +import org.jbpm.usertask.jpa.model.data.TaskInputEntity; +import org.jbpm.usertask.jpa.model.data.TaskOutputEntity; + +import jakarta.persistence.*; + +@Entity +@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY, + query = "select userTask from UserTaskInstanceEntity userTask " + + "left join userTask.adminGroups ag " + + "left join userTask.potentialGroups pg " + + "where :userId not member of userTask.excludedUsers and (" + + "userTask.actualOwner = :userId or " + + "ag in (:roles) or pg in (:roles)" + + "or :userId member of userTask.adminUsers " + + "or :userId member of userTask.potentialUsers)") +@Table(name = "jbpm_user_tasks") +public class UserTaskInstanceEntity { + public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity"; + + @Id + private String id; + + @Column(name = "user_task_id") + private String userTaskId; + + @Column(name = "task_name") + private String taskName; + + @Column(name = "task_description") + private String taskDescription; + + @Column(name = "task_priority") + private Integer taskPriority; + + private String status; + + @Column(name = "termination_type") + private String terminationType; + + @Column(name = "actual_owner") + private String actualOwner; + + @Column(name = "external_reference_id") + private String externalReferenceId; + + @ElementCollection + @CollectionTable(name = "jbpm_user_tasks_potential_users", joinColumns = @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "fk_jbpm_user_tasks_potential_users_tid"))) + @Column(name = "user_id", nullable = false) + private Set potentialUsers = new HashSet<>(); + + @ElementCollection + @CollectionTable(name = "jbpm_user_tasks_potential_groups", joinColumns = @JoinColumn(name = "task_id"), + foreignKey = @ForeignKey(name = "fk_jbpm_user_tasks_potential_groups_tid")) + @Column(name = "group_id") + private Set potentialGroups = new HashSet<>(); + + @ElementCollection + @CollectionTable(name = "jbpm_user_tasks_admin_users", joinColumns = @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "fk_jbpm_user_tasks_admin_users_tid"))) + @Column(name = "user_id", nullable = false) + private Set adminUsers = new HashSet<>(); + + @ElementCollection + @CollectionTable(name = "jbpm_user_tasks_admin_groups", joinColumns = @JoinColumn(name = "task_id"), + foreignKey = @ForeignKey(name = "fk_jbpm_user_tasks_admin_groups_tid")) + @Column(name = "group_id") + private Set adminGroups = new HashSet<>(); + + @ElementCollection + @CollectionTable(name = "jbpm_user_tasks_excluded_users", joinColumns = @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "fk_jbpm_user_tasks_excluded_users_tid"))) + @Column(name = "user_id", nullable = false) + private Set excludedUsers = new HashSet<>(); + + @OneToMany(mappedBy = "taskInstance", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List attachments = new ArrayList<>(); + + @OneToMany(mappedBy = "taskInstance", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List comments = new ArrayList<>(); + + @OneToMany(mappedBy = "taskInstance", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List inputs = new ArrayList<>(); + + @OneToMany(mappedBy = "taskInstance", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List outputs = new ArrayList<>(); + + @OneToMany(mappedBy = "taskInstance", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List metadata = new ArrayList<>(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getActualOwner() { + return actualOwner; + } + + public void setActualOwner(String actualOwner) { + this.actualOwner = actualOwner; + } + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public String getTaskDescription() { + return taskDescription; + } + + public void setTaskDescription(String taskDescription) { + this.taskDescription = taskDescription; + } + + public Integer getTaskPriority() { + return taskPriority; + } + + public void setTaskPriority(Integer taskPriority) { + this.taskPriority = taskPriority; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getExternalReferenceId() { + return externalReferenceId; + } + + public void setExternalReferenceId(String externalReferenceId) { + this.externalReferenceId = externalReferenceId; + } + + public void setPotentialUsers(Set potentialUsers) { + this.potentialUsers.clear(); + this.potentialUsers.addAll(potentialUsers); + } + + public Set getPotentialUsers() { + return potentialUsers; + } + + public Set getPotentialGroups() { + return potentialGroups; + } + + public void setPotentialGroups(Set potentialGroups) { + this.potentialGroups.clear(); + this.potentialGroups.addAll(potentialGroups); + } + + public Set getAdminUsers() { + return adminUsers; + } + + public void setAdminUsers(Set adminUsers) { + this.adminUsers.clear(); + this.adminUsers.addAll(adminUsers); + } + + public Collection getAdminGroups() { + return adminGroups; + } + + public void setAdminGroups(Set adminGroups) { + this.adminGroups.clear(); + this.adminGroups.addAll(adminGroups); + } + + public Collection getExcludedUsers() { + return excludedUsers; + } + + public void setExcludedUsers(Set excludedUsers) { + this.excludedUsers.clear(); + this.excludedUsers.addAll(excludedUsers); + } + + public void clearAttachments() { + this.attachments.clear(); + } + + public Collection getAttachments() { + return attachments; + } + + public void addAttachment(AttachmentEntity attachment) { + attachment.setTaskInstance(this); + this.attachments.add(attachment); + } + + public void removeAttachment(AttachmentEntity attachmentEntity) { + this.attachments.remove(attachmentEntity); + } + + public void setAttachments(Collection attachments) { + this.clearAttachments(); + this.attachments.addAll(attachments); + } + + public void clearComments() { + this.comments.clear(); + } + + public void removeComment(CommentEntity comment) { + this.comments.remove(comment); + } + + public Collection getComments() { + return comments; + } + + public void addComment(CommentEntity comment) { + comment.setTaskInstance(this); + this.comments.add(comment); + } + + public void setComments(Collection comments) { + this.clearComments(); + this.comments.addAll(comments); + } + + public void clearInputs() { + this.inputs.clear(); + } + + public Collection getInputs() { + return inputs; + } + + public void setInputs(Collection inputs) { + this.clearInputs(); + this.inputs.addAll(inputs); + } + + public void addInput(TaskInputEntity input) { + input.setTaskInstance(this); + this.inputs.add(input); + } + + public void removeInput(TaskInputEntity input) { + this.inputs.remove(input); + } + + public void clearOutputs() { + this.outputs.clear(); + } + + public Collection getOutputs() { + return outputs; + } + + public void addOutput(TaskOutputEntity output) { + output.setTaskInstance(this); + this.outputs.add(output); + } + + public void removeOutput(TaskOutputEntity output) { + this.outputs.remove(output); + } + + public void setOutputs(Collection outputs) { + this.clearOutputs(); + this.outputs.addAll(outputs); + } + + public void clearMetadata() { + this.metadata.clear(); + } + + public Collection getMetadata() { + return metadata; + } + + public void addMetadata(TaskMetadataEntity metadata) { + metadata.setTaskInstance(this); + this.metadata.add(metadata); + } + + public void removeMetadata(TaskMetadataEntity metadata) { + this.metadata.remove(metadata); + } + + public void setMetadata(Collection metadata) { + this.clearMetadata(); + this.metadata.addAll(metadata); + } + + public void setUserTaskId(String userTaskId) { + this.userTaskId = userTaskId; + } + + public String getUserTaskId() { + return userTaskId; + } + + public void setTerminationType(String terminationType) { + this.terminationType = terminationType; + } + + public String getTerminationType() { + return terminationType; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.java new file mode 100644 index 00000000000..893bbd68c31 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.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.jbpm.usertask.jpa.model.data; + +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; + +import jakarta.persistence.*; + +@MappedSuperclass +@SequenceGenerator(name = "jbpm_user_task_data_mapping_id_seq", sequenceName = "jbpm_user_task_data_mapping_id_seq") +public abstract class AbstractTaskDataEntity { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "jbpm_user_task_data_mapping_id_seq") + protected Long id; + + protected String name; + + protected byte[] value; + + @Column(name = "java_type") + protected String javaType; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public byte[] getValue() { + return value; + } + + public void setValue(byte[] value) { + this.value = value; + } + + public String getJavaType() { + return javaType; + } + + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + abstract UserTaskInstanceEntity getTaskInstance(); + + abstract void setTaskInstance(UserTaskInstanceEntity taskInstance); +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java new file mode 100644 index 00000000000..19a6c7efa32 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java @@ -0,0 +1,47 @@ +/* + * 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.jbpm.usertask.jpa.model.data; + +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; + +import jakarta.persistence.*; + +@Entity +@Table(name = "jbpm_user_tasks_inputs") +@AttributeOverrides({ + @AttributeOverride(name = "name", column = @Column(name = "input_name")), + @AttributeOverride(name = "value", column = @Column(name = "input_value")) +}) +public class TaskInputEntity extends AbstractTaskDataEntity { + + @ManyToOne(optional = false) + @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_inputs_tid")) + private UserTaskInstanceEntity taskInstance; + + @Override + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + @Override + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java new file mode 100644 index 00000000000..d986de0f63e --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java @@ -0,0 +1,48 @@ +/* + * 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.jbpm.usertask.jpa.model.data; + +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; + +import jakarta.persistence.*; + +@Entity +@Table(name = "jbpm_user_tasks_outputs") +@AttributeOverrides({ + @AttributeOverride(name = "name", column = @Column(name = "output_name")), + @AttributeOverride(name = "value", column = @Column(name = "output_value")) +}) +public class TaskOutputEntity extends AbstractTaskDataEntity { + + @ManyToOne(optional = false) + @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_outputs_tid")) + private UserTaskInstanceEntity taskInstance; + + @Override + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + @Override + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } + +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java new file mode 100644 index 00000000000..51fd669321e --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import org.jbpm.usertask.jpa.model.AttachmentEntity; + +public class AttachmentRepository extends BaseRepository { + + public AttachmentRepository(UserTaskJPAContext context) { + super(context); + } + + @Override + public Class getEntityClass() { + return AttachmentEntity.class; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java new file mode 100644 index 00000000000..d2672e7efef --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java @@ -0,0 +1,63 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import java.util.List; +import java.util.Optional; + +import jakarta.persistence.EntityManager; + +public abstract class BaseRepository { + + protected UserTaskJPAContext context; + + public BaseRepository(UserTaskJPAContext context) { + this.context = context; + } + + public Optional findById(String id) { + return Optional.ofNullable(getEntityManager().find(getEntityClass(), id)); + } + + public List findAll() { + return getEntityManager().createQuery("from " + getEntityClass().getName(), getEntityClass()).getResultList(); + } + + public T persist(T entity) { + getEntityManager().persist(entity); + + return entity; + } + + public T update(T entity) { + return this.getEntityManager().merge(entity); + } + + public T remove(T entity) { + this.getEntityManager().remove(entity); + return entity; + } + + public abstract Class getEntityClass(); + + protected EntityManager getEntityManager() { + return context.getEntityManager(); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java new file mode 100644 index 00000000000..a13d66e3ff0 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import org.jbpm.usertask.jpa.model.CommentEntity; + +public class CommentRepository extends BaseRepository { + + public CommentRepository(UserTaskJPAContext context) { + super(context); + } + + @Override + public Class getEntityClass() { + return CommentEntity.class; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java new file mode 100644 index 00000000000..fa139621943 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import org.jbpm.usertask.jpa.model.data.TaskInputEntity; + +public class TaskInputRepository extends BaseRepository { + + public TaskInputRepository(UserTaskJPAContext context) { + super(context); + } + + @Override + public Class getEntityClass() { + return TaskInputEntity.class; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java new file mode 100644 index 00000000000..29dd469c85f --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import org.jbpm.usertask.jpa.model.TaskMetadataEntity; + +public class TaskMetadataRepository extends BaseRepository { + + public TaskMetadataRepository(UserTaskJPAContext context) { + super(context); + } + + @Override + public Class getEntityClass() { + return TaskMetadataEntity.class; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java new file mode 100644 index 00000000000..0d1f13353f1 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import org.jbpm.usertask.jpa.model.data.TaskOutputEntity; + +public class TaskOutputRepository extends BaseRepository { + + public TaskOutputRepository(UserTaskJPAContext context) { + super(context); + } + + @Override + public Class getEntityClass() { + return TaskOutputEntity.class; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java new file mode 100644 index 00000000000..89c91df765e --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java @@ -0,0 +1,48 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import java.util.List; + +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.kie.kogito.auth.IdentityProvider; + +import jakarta.persistence.TypedQuery; + +import static org.jbpm.usertask.jpa.model.UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY; + +public class UserTaskInstanceRepository extends BaseRepository { + + public UserTaskInstanceRepository(UserTaskJPAContext context) { + super(context); + } + + public List findByIdentity(IdentityProvider identityProvider) { + TypedQuery query = getEntityManager().createNamedQuery(GET_INSTANCES_BY_IDENTITY, UserTaskInstanceEntity.class); + query.setParameter("userId", identityProvider.getName()); + query.setParameter("roles", identityProvider.getRoles()); + return query.getResultList(); + } + + @Override + public Class getEntityClass() { + return UserTaskInstanceEntity.class; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java new file mode 100644 index 00000000000..8606184dd58 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java @@ -0,0 +1,27 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import jakarta.persistence.EntityManager; + +public interface UserTaskJPAContext { + + EntityManager getEntityManager(); +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/beans.xml b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/kie-flyway.properties b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/kie-flyway.properties new file mode 100644 index 00000000000..67ce94390d9 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/META-INF/kie-flyway.properties @@ -0,0 +1,23 @@ +# +# 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. +# + +module.name=jbpm-user-task-storage + +module.locations.h2=classpath:kie-flyway/db/user-tasks/h2 +module.locations.postgresql=classpath:kie-flyway/db/user-tasks/postgresql \ No newline at end of file diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql new file mode 100644 index 00000000000..25500c2d831 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql @@ -0,0 +1,172 @@ +/* + * 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. + */ + +create table jbpm_user_tasks ( + id varchar(50) not null, + user_task_id varchar(255), + task_priority integer, + actual_owner varchar(255), + task_description varchar(255), + status varchar(255), + termination_type varchar(255), + external_reference_id varchar(255), + task_name varchar(255), + primary key (id) +); + +create table jbpm_user_tasks_potential_users( + task_id varchar(50) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) +); + +create table jbpm_user_tasks_potential_groups( + task_id varchar(50) not null, + group_id varchar(255) not null, + primary key (task_id, group_id) +); + +create table jbpm_user_tasks_admin_users ( + task_id varchar(50) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) +); + +create table jbpm_user_tasks_admin_groups ( + task_id varchar(50) not null, + group_id varchar(255) not null, + primary key (task_id, group_id) +); + +create table jbpm_user_tasks_excluded_users( + task_id varchar(50) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) +); + +create table jbpm_user_tasks_attachments ( + id varchar(50) not null, + name varchar(255), + updated_by varchar(255), + updated_at timestamp, + url varchar(255), + task_id varchar(50) not null, + primary key (id) +); + +create table jbpm_user_tasks_comments ( + id varchar(50) not null, + updated_by varchar(255), + updated_at timestamp, + comment varchar(255), + task_id varchar(50) not null, + primary key (id) +); + +create table jbpm_user_tasks_inputs ( + id bigint not null, + task_id varchar(50) not null, + input_name varchar(255) not null, + input_value varbinary(max), + java_type varchar(255), + primary key (id) +); + +create table jbpm_user_tasks_outputs ( + id bigint not null, + task_id varchar(50) not null, + output_name varchar(255) not null, + output_value varbinary(max), + java_type varchar(255), + primary key (id) +); + +create table jbpm_user_tasks_metadata ( + id bigint not null, + task_id varchar(50) not null, + metadata_name varchar(255) not null, + metadata_value varchar(512), + java_type varchar(255), + primary key (id) +); + +alter table if exists jbpm_user_tasks_potential_users +drop constraint if exists fk_jbpm_user_tasks_potential_users_tid cascade; + +alter table if exists jbpm_user_tasks_potential_users +add constraint fk_jbpm_user_fk_tasks_potential_users_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_potential_groups +drop constraint if exists fk_jbpm_user_tasks_potential_groups_tid cascade; + +alter table if exists jbpm_user_tasks_potential_groups +add constraint fk_jbpm_user_tasks_potential_groups_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_admin_users +drop constraint if exists fk_jbpm_user_tasks_admin_users_tid cascade; + +alter table if exists jbpm_user_tasks_admin_users +add constraint fk_jbpm_user_tasks_admin_users_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_admin_groups +drop constraint if exists fk_jbpm_user_tasks_admin_groups_tid cascade; + +alter table if exists jbpm_user_tasks_admin_groups +add constraint fk_jbpm_user_tasks_admin_groups_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_excluded_users +drop constraint if exists fk_jbpm_user_tasks_excluded_users_tid cascade; + +alter table if exists jbpm_user_tasks_excluded_users +add constraint fk_jbpm_user_tasks_excluded_users_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_attachments +drop constraint if exists fk_user_task_attachment_tid cascade; + +alter table if exists jbpm_user_tasks_attachments +add constraint fk_user_task_attachment_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_comments +drop constraint if exists fk_user_task_comment_tid cascade; + +alter table if exists jbpm_user_tasks_comments +add constraint fk_user_task_comment_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_inputs +drop constraint if exists fk_jbpm_user_tasks_inputs_tid cascade; + +alter table if exists jbpm_user_tasks_inputs +add constraint fk_jbpm_user_tasks_inputs_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_outputs +drop constraint if exists fk_jbpm_user_tasks_outputs_tid cascade; + +alter table if exists jbpm_user_tasks_outputs +add constraint fk_jbpm_user_tasks_outputs_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_metadata +drop constraint if exists fk_jbpm_user_tasks_metadata_tid cascade; + +alter table if exists jbpm_user_tasks_metadata +add constraint fk_jbpm_user_tasks_metadata_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +create sequence jbpm_user_task_data_mapping_id_seq start with 1 increment by 10; +create sequence jbpm_user_task_metadata_id_seq start with 1 increment by 10; + + diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql new file mode 100644 index 00000000000..8e6fb2a0407 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql @@ -0,0 +1,170 @@ +/* + * 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. + */ + +create table jbpm_user_tasks ( + id varchar(50) not null, + user_task_id varchar(255), + task_priority integer, + actual_owner varchar(255), + task_description varchar(255), + status varchar(255), + termination_type varchar(255), + external_reference_id varchar(255), + task_name varchar(255), + primary key (id) +); + +create table jbpm_user_tasks_potential_users( + task_id varchar(50) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) +); + +create table jbpm_user_tasks_potential_groups( + task_id varchar(50) not null, + group_id varchar(255) not null, + primary key (task_id, group_id) +); + +create table jbpm_user_tasks_admin_users ( + task_id varchar(50) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) +); + +create table jbpm_user_tasks_admin_groups ( + task_id varchar(50) not null, + group_id varchar(255) not null, + primary key (task_id, group_id) +); + +create table jbpm_user_tasks_excluded_users( + task_id varchar(50) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) +); + +create table jbpm_user_tasks_attachments ( + id varchar(50) not null, + name varchar(255), + updated_by varchar(255), + updated_at timestamp(6), + url varchar(255), + task_id varchar(50) not null, + primary key (id) +); + +create table jbpm_user_tasks_comments ( + id varchar(50) not null, + updated_by varchar(255), + updated_at timestamp(6), + comment varchar(255), + task_id varchar(50) not null, + primary key (id) +); + +create table jbpm_user_tasks_inputs ( + id bigint not null, + task_id varchar(50) not null, + input_name varchar(255) not null, + input_value bytea, + java_type varchar(255), + primary key (id) +); + +create table jbpm_user_tasks_outputs ( + id bigint not null, + task_id varchar(50) not null, + output_name varchar(255) not null, + output_value bytea, + java_type varchar(255), + primary key (id) +); + +create table jbpm_user_tasks_metadata ( + id bigint not null, + task_id varchar(50), + metadata_name varchar(255) not null, + metadata_value varchar(512), + java_type varchar(255), + primary key (id) +); + +alter table if exists jbpm_user_tasks_potential_users +drop constraint if exists fk_jbpm_user_tasks_potential_users_tid cascade; + +alter table if exists jbpm_user_tasks_potential_users +add constraint fk_jbpm_user_fk_tasks_potential_users_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_potential_groups +drop constraint if exists fk_jbpm_user_tasks_potential_groups_tid cascade; + +alter table if exists jbpm_user_tasks_potential_groups +add constraint fk_jbpm_user_tasks_potential_groups_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_admin_users +drop constraint if exists fk_jbpm_user_tasks_admin_users_tid cascade; + +alter table if exists jbpm_user_tasks_admin_users +add constraint fk_jbpm_user_tasks_admin_users_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_admin_groups +drop constraint if exists fk_jbpm_user_tasks_admin_groups_tid cascade; + +alter table if exists jbpm_user_tasks_admin_groups +add constraint fk_jbpm_user_tasks_admin_groups_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_excluded_users +drop constraint if exists fk_jbpm_user_tasks_excluded_users_tid cascade; + +alter table if exists jbpm_user_tasks_excluded_users +add constraint fk_jbpm_user_tasks_excluded_users_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_attachments +drop constraint if exists fk_user_task_attachment_tid cascade; + +alter table if exists jbpm_user_tasks_attachments +add constraint fk_user_task_attachment_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_comments +drop constraint if exists fk_user_task_comment_tid cascade; + +alter table if exists jbpm_user_tasks_comments +add constraint fk_user_task_comment_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_inputs +drop constraint if exists fk_jbpm_user_tasks_inputs_tid cascade; + +alter table if exists jbpm_user_tasks_inputs +add constraint fk_jbpm_user_tasks_inputs_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_outputs +drop constraint if exists fk_jbpm_user_tasks_outputs_tid cascade; + +alter table if exists jbpm_user_tasks_outputs +add constraint fk_jbpm_user_tasks_outputs_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +alter table if exists jbpm_user_tasks_metadata +drop constraint if exists fk_jbpm_user_tasks_metadata_tid cascade; + +alter table if exists jbpm_user_tasks_metadata +add constraint fk_jbpm_user_tasks_metadata_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; + +create sequence jbpm_user_task_data_mapping_id_seq start with 1 increment by 10; +create sequence jbpm_user_task_metadata_id_seq start with 1 increment by 10; \ No newline at end of file diff --git a/addons/common/pom.xml b/addons/common/pom.xml index 1a12e57c0c9..fe7ccb1dcf6 100644 --- a/addons/common/pom.xml +++ b/addons/common/pom.xml @@ -55,6 +55,7 @@ task-management marshallers flyway + jbpm-usertask-storage-jpa diff --git a/api/kogito-api/src/main/java/org/kie/kogito/auth/IdentityProviders.java b/api/kogito-api/src/main/java/org/kie/kogito/auth/IdentityProviders.java index 2d1073893f7..8d560bc801f 100644 --- a/api/kogito-api/src/main/java/org/kie/kogito/auth/IdentityProviders.java +++ b/api/kogito-api/src/main/java/org/kie/kogito/auth/IdentityProviders.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.List; public class IdentityProviders { @@ -52,8 +53,8 @@ public boolean hasRole(String role) { } - public static IdentityProvider of(String name) { - return new DefaultIdentityProvider(name, Collections.emptyList()); + public static IdentityProvider of(String name, String... roles) { + return new DefaultIdentityProvider(name, List.of(roles)); } public static IdentityProvider of(String name, Collection roles) { diff --git a/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstances.java b/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstances.java index 7f294b15fed..8372c4e2747 100644 --- a/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstances.java +++ b/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstances.java @@ -40,6 +40,6 @@ public interface UserTaskInstances { UserTaskInstance update(UserTaskInstance userTaskInstance); - UserTaskInstance remove(String userTaskInstanceId); + UserTaskInstance remove(UserTaskInstance userTaskInstanceId); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemModelMetaData.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemModelMetaData.java index 5ae74187907..20658f01b5b 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemModelMetaData.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemModelMetaData.java @@ -80,7 +80,10 @@ public class WorkItemModelMetaData { private static final String PARAMS = "params"; protected static final List INTERNAL_FIELDS = Arrays.asList(TASK_NAME, "NodeName", "ActorId", "GroupId", "Priority", "Comment", "Skippable", "Content", "Locale", - "NotStartedNotify", "NotCompletedNotify", "NotCompletedReassign", "NotStartedReassign"); + "NotStartedNotify", "NotCompletedNotify", "NotCompletedReassign", "NotStartedReassign", + "ExcludedOwnerId", + "BusinessAdministratorId", + "BusinessAdministratorGroupId"); private final String packageName; diff --git a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java index d612a692961..a1b678e6a4c 100644 --- a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java +++ b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java @@ -79,10 +79,14 @@ public Optional activateWorkItemHandler(KogitoWorkItemManage UserTask userTask = userTasks.userTaskById((String) workItem.getParameter(KogitoWorkItem.PARAMETER_UNIQUE_TASK_ID)); DefaultUserTaskInstance instance = (DefaultUserTaskInstance) userTask.createInstance(); + + instance.setExternalReferenceId(workItem.getStringId()); + + userTask.instances().create(instance); + instance.setTaskName((String) workItem.getParameter(TASK_NAME)); instance.setTaskDescription((String) workItem.getParameter(DESCRIPTION)); instance.setTaskPriority(priorityInteger); - instance.setExternalReferenceId(workItem.getStringId()); instance.setMetadata("ProcessId", workItem.getProcessInstance().getProcessId()); instance.setMetadata("ProcessType", workItem.getProcessInstance().getProcess().getType()); @@ -93,7 +97,6 @@ public Optional activateWorkItemHandler(KogitoWorkItemManage instance.setMetadata("RootProcessInstanceId", workItem.getProcessInstance().getRootProcessInstanceId()); instance.setMetadata("ParentProcessInstanceId", workItem.getProcessInstance().getParentProcessInstanceId()); - userTask.instances().create(instance); instance.fireInitialStateChange(); workItem.getParameters().forEach(instance::setInput); diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/AbstractUserTask.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/AbstractUserTask.java index 19a7d8c1e74..7e662cf47ac 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/AbstractUserTask.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/AbstractUserTask.java @@ -74,8 +74,9 @@ public UserTaskInstance createInstance() { instance.setPotentialUsers(getPotentialUsers()); instance.setPotentialGroups(getPotentialGroups()); instance.setAdminUsers(getAdminUsers()); - instance.setPotentialGroups(getPotentialGroups()); + instance.setAdminGroups(getAdminGroups()); instance.setExcludedUsers(getExcludedUsers()); + instance.setInstances(this.instances()); return instance; } diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java index e5265ae3f7f..ab5fb202bff 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java @@ -94,7 +94,6 @@ public DefaultUserTaskInstance(UserTask userTask) { this(); this.id = UUID.randomUUID().toString(); this.userTask = userTask; - this.instances = userTask.instances(); } public void setUserTaskEventSupport(KogitoUserTaskEventSupport userTaskEventSupport) { @@ -185,7 +184,7 @@ private void updatePersistence() { private void updatePersistenceOrRemove() { if (this.status.isTerminate()) { - this.instances.remove(this.id); + this.instances.remove(this); } else { this.instances.update(this); } diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/InMemoryUserTaskInstances.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/InMemoryUserTaskInstances.java index def2088da39..256144c4849 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/InMemoryUserTaskInstances.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/InMemoryUserTaskInstances.java @@ -161,14 +161,15 @@ public UserTaskInstance update(UserTaskInstance userTaskInstance) { } @Override - public UserTaskInstance remove(String userTaskInstanceId) { + public UserTaskInstance remove(UserTaskInstance userTaskInstance) { try { - if (!userTaskInstances.containsKey(userTaskInstanceId)) { + if (!userTaskInstances.containsKey(userTaskInstance.getId())) { return null; } - return disconnectUserTaskInstance.apply(mapper.readValue(userTaskInstances.remove(userTaskInstanceId), DefaultUserTaskInstance.class)); + userTaskInstances.remove(userTaskInstance.getId()); + return disconnectUserTaskInstance.apply(userTaskInstance); } catch (Exception e) { - LOG.error("during remove {}", userTaskInstanceId, e); + LOG.error("during remove {}", userTaskInstance, e); return null; } } diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index 6e4af07c46d..7320c0f5827 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -1732,6 +1732,41 @@ sources + + + org.jbpm + jbpm-addons-usertask-storage-jpa + ${project.version} + + + org.jbpm + jbpm-addons-usertask-storage-jpa + ${project.version} + sources + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa + ${project.version} + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa + ${project.version} + sources + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa-deployment + ${project.version} + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa-deployment + ${project.version} + sources + + org.kie @@ -1898,6 +1933,17 @@ jbpm-usertask ${project.version} + + org.kie.kogito + jbpm-usertask-storage-jpa + ${project.version} + + + org.kie.kogito + jbpm-usertask-storage-jpa + ${project.version} + sources + org.kie.kogito jbpm-usertask-workitem diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index 26fae00aa0d..f085d103e0a 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -108,6 +108,8 @@ 7.10.2 3.1.0 + 3.1.0 + 6.2.7.Final 24.0.4 @@ -443,6 +445,12 @@ ${version.jakarta.ws.rs} + + jakarta.persistence + jakarta.persistence-api + ${version.jakarta.persistence-api} + + org.junit.jupiter junit-jupiter-api diff --git a/quarkus/addons/flyway/deployment/pom.xml b/quarkus/addons/flyway/deployment/pom.xml index 1e6eefccdc8..de160bad027 100644 --- a/quarkus/addons/flyway/deployment/pom.xml +++ b/quarkus/addons/flyway/deployment/pom.xml @@ -50,6 +50,7 @@ io.quarkus quarkus-agroal-deployment + org.mockito diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/deployment/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/deployment/pom.xml new file mode 100644 index 00000000000..fe131a6e27f --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/deployment/pom.xml @@ -0,0 +1,110 @@ + + + + + jbpm-addon-quarkus-usertask-storage-jpa-parent + org.jbpm + 999-SNAPSHOT + + 4.0.0 + + jbpm-addons-quarkus-usertask-storage-jpa-deployment + jBPM :: Add-Ons :: Quarkus :: User Task Storage JPA :: Deployment + jBPM Add-On Quarkus User Task Storage JPA Deployment + + + UTF-8 + org.jbpm.usertask.storage.jpa.quarkus.deployment + + + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa + + + org.kie + kogito-addons-quarkus-common-deployment + + + org.kie + kie-addons-quarkus-flyway-deployment + + + + io.quarkus + quarkus-arc-deployment + + + io.quarkus + quarkus-agroal-deployment + + + io.quarkus + quarkus-hibernate-orm-deployment + + + + io.quarkus + quarkus-junit5 + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.mockito + mockito-core + test + + + io.rest-assured + rest-assured + test + + + io.quarkus + quarkus-junit5-mockito + test + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java b/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java new file mode 100644 index 00000000000..d0fa34a4ad5 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java @@ -0,0 +1,40 @@ +/* + * 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.jbpm.usertask.storage.jpa.deployment; + +import org.kie.kogito.quarkus.addons.common.deployment.KogitoCapability; +import org.kie.kogito.quarkus.addons.common.deployment.RequireCapabilityKogitoAddOnProcessor; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +public class JBPMUserTaskStorageJPAExtensionProcessor extends RequireCapabilityKogitoAddOnProcessor { + + private static final String FEATURE = "jbpm-addon-usertask-storage-jpa"; + + public JBPMUserTaskStorageJPAExtensionProcessor() { + super(KogitoCapability.PROCESSES); + } + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml new file mode 100644 index 00000000000..a49c94f7e9a --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml @@ -0,0 +1,149 @@ + + + + + jbpm-addon-quarkus-usertask-storage-jpa-parent + org.jbpm + 999-SNAPSHOT + + 4.0.0 + + jbpm-addons-quarkus-usertask-storage-jpa-integration-tests + jBPM :: Add-Ons :: Quarkus :: User Task Storage JPA :: Integration Tests + jBPM Add-On Quarkus User Task Storage JPA Integration Tests + + + org.jbpm.usertask.storage.jpa.quarkus.test + + + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + org.jbpm + jbpm-quarkus + + + org.kie + kie-addons-quarkus-persistence-jdbc + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-agroal + + + io.quarkus + quarkus-jdbc-postgresql + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.assertj + assertj-core + test + + + org.kie.kogito + kogito-quarkus-test-utils + test + + + + + org.jbpm + jbpm-quarkus-deployment + ${project.version} + pom + test + + + * + * + + + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + maven-compiler-plugin + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Address.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Address.java new file mode 100644 index 00000000000..662dfa9b9f7 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/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/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java new file mode 100644 index 00000000000..c24685803d2 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java @@ -0,0 +1,88 @@ +/* + * 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, 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/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties new file mode 100644 index 00000000000..5458fa57f9c --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties @@ -0,0 +1,24 @@ +# +# 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. +# + +quarkus.datasource.db-kind=postgresql + +kogito.persistence.type=jdbc + +kie.flyway.enabled=true \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn new file mode 100644 index 00000000000..275d148f7ac --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 + _C13522F1-230A-4C26-B5A9-533A5D9FEE9D + + + + + + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + + + + traveller + _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX + approver + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX + firstLineApproval + + + + manager + + + + + + + + + + _C13522F1-230A-4C26-B5A9-533A5D9FEE9D + _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 + + + + + + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + + + + approver + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX + + + traveller + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX + secondLineApproval + + + + + + + + + _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 + + + + + + + + _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _F0jB8En5EeqlfsIhq1UCRQ + _F0jB8En5EeqlfsIhq1UCRQ + + diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java new file mode 100644 index 00000000000..0037fa3bd8a --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java @@ -0,0 +1,82 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.time.Duration; +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.emptyOrNullString; + +@QuarkusIntegrationTest +@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) +public class JBPMUserTaskJPAStorageIT { + public static final Duration TIMEOUT = Duration.ofSeconds(10); + public static final String PROCESS_ID = "approvals"; + public static final String USERTASKS_ENDPOINT = "/usertasks/instance"; + + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + + @Test + public void testFullProcess() { + + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = given().contentType(ContentType.JSON) + .when() + .body(Map.of("traveller", traveller)) + .post("/{processId}", PROCESS_ID) + .then() + .statusCode(201) + .header("Location", not(emptyOrNullString())) + .body("id", not(emptyOrNullString())) + .extract() + .path("id"); + + System.out.println(pid); + + final String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USERTASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + System.out.println(taskId); + + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml new file mode 100644 index 00000000000..a6ce8cbcc97 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml @@ -0,0 +1,46 @@ + + + + + kogito-addons-quarkus-parent + org.kie + 999-SNAPSHOT + + 4.0.0 + + org.jbpm + jbpm-addon-quarkus-usertask-storage-jpa-parent + + jBPM :: Add-Ons :: Quarkus :: User Task Storage JPA :: Parent + jBPM Add-On Quarkus User Task Storage JPA Parent + + pom + + + deployment + runtime + integration-tests + + + \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml new file mode 100644 index 00000000000..492e403c10d --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml @@ -0,0 +1,169 @@ + + + + + jbpm-addon-quarkus-usertask-storage-jpa-parent + org.jbpm + 999-SNAPSHOT + + 4.0.0 + + jbpm-addons-quarkus-usertask-storage-jpa + jBPM :: Add-Ons :: Quarkus :: User Task Storage JPA :: Runtime + jBPM Add-On Quarkus User Task Storage JPA Runtime + + + UTF-8 + org.jbpm.usertask.storage.jpa.quarkus + + + + + org.jbpm + jbpm-addons-usertask-storage-jpa + + + org.kie + kie-addons-quarkus-flyway + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-hibernate-orm + + + + io.quarkus + quarkus-agroal + test + + + io.quarkus + quarkus-jdbc-postgresql + test + + + io.quarkus + quarkus-jdbc-h2 + test + + + io.quarkus + quarkus-test-h2 + test + + + io.quarkus + quarkus-junit5 + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.mockito + mockito-core + test + + + io.rest-assured + rest-assured + test + + + io.quarkus + quarkus-junit5-mockito + test + + + org.kie.kogito + kogito-quarkus-test-utils + test + + + + + + io.quarkus + quarkus-extension-maven-plugin + ${version.io.quarkus} + + + compile + + extension-descriptor + + + ${project.groupId}:${project.artifactId}-deployment:${project.version} + + org.jbpm.addons.usertask.storage + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.jboss.logmanager.LogManager + + + + + default + + integration-test + + + + verify + + verify + + + + + + + + \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.java new file mode 100644 index 00000000000..55d5d585dfd --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.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.jbpm.usertask.jpa; + +import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@Transactional +@ApplicationScoped +public class QuarkusJPAUserTaskInstances extends JPAUserTaskInstances { + + QuarkusJPAUserTaskInstances() { + super(null, null); + } + + @Inject + public QuarkusJPAUserTaskInstances(UserTaskInstanceRepository userTaskInstanceRepository, UserTaskInstanceEntityMapper userTaskInstanceEntityMapper) { + super(userTaskInstanceRepository, userTaskInstanceEntityMapper); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java new file mode 100644 index 00000000000..54ceedf98b7 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.jbpm.usertask.jpa.repository.AttachmentRepository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusAttachmentsEntityMapper extends AttachmentsEntityMapper { + + QuarkusAttachmentsEntityMapper() { + this(null); + } + + @Inject + public QuarkusAttachmentsEntityMapper(AttachmentRepository attachmentRepository) { + super(attachmentRepository); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java new file mode 100644 index 00000000000..445208d9622 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.jbpm.usertask.jpa.repository.CommentRepository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusCommentsEntityMapper extends CommentsEntityMapper { + + public QuarkusCommentsEntityMapper() { + this(null); + } + + @Inject + public QuarkusCommentsEntityMapper(CommentRepository commentRepository) { + super(commentRepository); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java new file mode 100644 index 00000000000..5437555466b --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.jbpm.usertask.jpa.repository.TaskInputRepository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusTaskInputsEntityMapper extends TaskInputsEntityMapper { + + public QuarkusTaskInputsEntityMapper() { + this(null); + } + + @Inject + public QuarkusTaskInputsEntityMapper(TaskInputRepository repository) { + super(repository); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java new file mode 100644 index 00000000000..6395fa25631 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusTaskMetadataEntityMapper extends TaskMetadataEntityMapper { + + public QuarkusTaskMetadataEntityMapper() { + this(null); + } + + @Inject + public QuarkusTaskMetadataEntityMapper(TaskMetadataRepository repository) { + super(repository); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java new file mode 100644 index 00000000000..f3063948b60 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusTaskOutputsEntityMapper extends TaskOutputsEntityMapper { + + public QuarkusTaskOutputsEntityMapper() { + this(null); + } + + @Inject + public QuarkusTaskOutputsEntityMapper(TaskOutputRepository repository) { + super(repository); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.java new file mode 100644 index 00000000000..7747573f056 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.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.jbpm.usertask.jpa.mapper; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusUserTaskInstanceEntityMapper extends UserTaskInstanceEntityMapper { + + QuarkusUserTaskInstanceEntityMapper() { + this(null, null, null, null, null); + } + + @Inject + public QuarkusUserTaskInstanceEntityMapper(AttachmentsEntityMapper attachmentsMapper, CommentsEntityMapper commentsMapper, TaskMetadataEntityMapper taskMetadataEntityMapper, + TaskInputsEntityMapper taskInputsEntityMapper, TaskOutputsEntityMapper taskOutputsEntityMapper) { + super(attachmentsMapper, commentsMapper, taskMetadataEntityMapper, taskInputsEntityMapper, taskOutputsEntityMapper); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java new file mode 100644 index 00000000000..16273612e96 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@ApplicationScoped +@Transactional +public class QuarkusAttachmentRepository extends AttachmentRepository { + + QuarkusAttachmentRepository() { + this(null); + } + + @Inject + public QuarkusAttachmentRepository(UserTaskJPAContext context) { + super(context); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java new file mode 100644 index 00000000000..a52bca69eac --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@ApplicationScoped +@Transactional +public class QuarkusCommentRepository extends CommentRepository { + + QuarkusCommentRepository() { + this(null); + } + + @Inject + public QuarkusCommentRepository(UserTaskJPAContext context) { + super(context); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.java new file mode 100644 index 00000000000..2c27ac939c5 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusTaskInputEntityRepository extends TaskInputRepository { + + QuarkusTaskInputEntityRepository() { + this(null); + } + + @Inject + public QuarkusTaskInputEntityRepository(UserTaskJPAContext context) { + super(context); + } + +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.java new file mode 100644 index 00000000000..67946f07a06 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusTaskMetadataEntityRepository extends TaskMetadataRepository { + + QuarkusTaskMetadataEntityRepository() { + this(null); + } + + @Inject + public QuarkusTaskMetadataEntityRepository(UserTaskJPAContext context) { + super(context); + } + +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.java new file mode 100644 index 00000000000..ae76b3d5e12 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class QuarkusTaskOutputEntityRepository extends TaskOutputRepository { + + QuarkusTaskOutputEntityRepository() { + this(null); + } + + @Inject + public QuarkusTaskOutputEntityRepository(UserTaskJPAContext context) { + super(context); + } + +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java new file mode 100644 index 00000000000..18e7e51d01e --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@ApplicationScoped +@Transactional +public class QuarkusUserTaskInstanceRepository extends UserTaskInstanceRepository { + + QuarkusUserTaskInstanceRepository() { + this(null); + } + + @Inject + public QuarkusUserTaskInstanceRepository(UserTaskJPAContext context) { + super(context); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java new file mode 100644 index 00000000000..9831caed3ee --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java @@ -0,0 +1,38 @@ +/* + * 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.jbpm.usertask.jpa.repository; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.transaction.Transactional; + +@ApplicationScoped +@Transactional +public class QuarkusUserTaskJPAContext implements UserTaskJPAContext { + + @PersistenceContext + private EntityManager em; + + @Override + public EntityManager getEntityManager() { + return em; + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/beans.xml b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..a0eb9fbf8cd --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/beans.xml @@ -0,0 +1,20 @@ + diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 00000000000..4983be32275 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -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. +# + +name: jBPM User Task Storage JPS +description: Add-On that enables JPA storage for jBPM User Tasks +metadata: + keywords: + - KIE + - jBPM + - persistence + - JPA + guide: https://quarkus.io/guides/kie + categories: + - "business-automation" + - "cloud" + - "jBPM" + - "persistence" + - "JPA" + status: "stable" + config: + - "org.jbpm" diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java new file mode 100644 index 00000000000..e31e5220324 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java @@ -0,0 +1,528 @@ +/* + * 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.jbpm.usertask.jpa; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import java.util.function.Function; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.model.AttachmentEntity; +import org.jbpm.usertask.jpa.model.CommentEntity; +import org.jbpm.usertask.jpa.model.TaskMetadataEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.model.data.AbstractTaskDataEntity; +import org.jbpm.usertask.jpa.models.Person; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.QuarkusUserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kie.kogito.auth.IdentityProvider; +import org.kie.kogito.auth.IdentityProviders; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; +import org.kie.kogito.usertask.lifecycle.UserTaskState; +import org.kie.kogito.usertask.model.Attachment; +import org.kie.kogito.usertask.model.Comment; +import org.mockito.Mockito; + +import jakarta.inject.Inject; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +public abstract class BaseQuarkusJPAUserTaskInstancesTest { + + @Inject + QuarkusUserTaskJPAContext context; + + @Inject + JPAUserTaskInstances userTaskInstances; + + @Inject + UserTaskInstanceRepository userTaskInstanceRepository; + + @Inject + AttachmentRepository attachmentRepository; + + @Inject + CommentRepository commentRepository; + + private Function connect; + private Function disconnect; + + @BeforeEach + public void init() { + connect = Mockito.mock(Function.class); + disconnect = Mockito.mock(Function.class); + + when(connect.apply(any(UserTaskInstance.class))).thenAnswer(i -> i.getArgument(0)); + when(disconnect.apply(any(UserTaskInstance.class))).thenAnswer(i -> i.getArgument(0)); + + userTaskInstances.setReconnectUserTaskInstance(connect); + userTaskInstances.setDisconnectUserTaskInstance(disconnect); + } + + @Test + public void testCreateUserTask() { + UserTaskInstance instance = createUserTaskInstance(); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + + Assertions.assertThat(userTaskInstances.findById(instance.getId())) + .isNotNull() + .isEmpty(); + + userTaskInstances.create(instance); + + verify(connect, times(1)).apply(any(UserTaskInstance.class)); + + Optional entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + Assertions.assertThat(entityOptional) + .isNotNull() + .isPresent(); + + UserTaskInstanceEntity entity = entityOptional.get(); + + assertEntityAndInstance(entity, instance); + + Optional persistedInstanceOptional = userTaskInstances.findById(instance.getId()); + + Assertions.assertThat(persistedInstanceOptional) + .isNotNull() + .isPresent(); + + assertEntityAndInstance(entity, persistedInstanceOptional.get()); + + userTaskInstances.remove(instance); + + Assertions.assertThat(attachmentRepository.findAll()) + .isEmpty(); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByActualOwner() { + + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Homer", "Group"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(1); + + verify(connect, times(2)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByPotentialOwners() { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Bart", "Group"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(1); + + verify(connect, times(2)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByPotentialGroups() { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Abraham", "Admin", "Simpson"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(1); + + verify(connect, times(2)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByAdminUsers() { + + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Seymour", "Group"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(1); + + verify(connect, times(2)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByAdminGroups() { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Abraham", "Administrator", "Managers"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(1); + + verify(connect, times(2)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByExcludedUser() { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Ned", "Simpson", "Family", "Administrators", "Managers"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(0); + + verify(connect, times(1)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testFindByIdentityByUnknownUser() { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + IdentityProvider identityProvider = IdentityProviders.of("Someone", "Group"); + + List result = userTaskInstances.findByIdentity(identityProvider); + + Assertions.assertThat(result) + .hasSize(0); + + verify(connect, times(1)).apply(any(UserTaskInstance.class)); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testAttachments() throws URISyntaxException { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + Optional entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + Assertions.assertThat(entityOptional) + .isNotNull() + .isPresent(); + + assertEntityAndInstance(entityOptional.get(), instance); + + Attachment attachment = new Attachment("1", "Admin"); + attachment.setName("attachment 1"); + attachment.setContent(new URI("http://url.com/to/my/attachment")); + attachment.setUpdatedAt(new Date()); + + instance.addAttachment(attachment); + + entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + assertTaskAttachments(entityOptional.get().getAttachments(), instance.getAttachments()); + + Attachment attachment2 = new Attachment("2", "Admin"); + attachment2.setName("attachment 2"); + attachment2.setContent(new URI("http://url.com/to/my/attachment2")); + attachment2.setUpdatedAt(new Date()); + + instance.addAttachment(attachment2); + + entityOptional = userTaskInstanceRepository.findById(instance.getId()); + assertTaskAttachments(entityOptional.get().getAttachments(), instance.getAttachments()); + + instance.removeAttachment(attachment); + instance.removeAttachment(attachment2); + + userTaskInstances.update(instance); + + entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + Assertions.assertThat(entityOptional.get().getAttachments()) + .isEmpty(); + + Assertions.assertThat(attachmentRepository.findAll()) + .isEmpty(); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testComments() throws URISyntaxException { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + Optional entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + Assertions.assertThat(entityOptional) + .isNotNull() + .isPresent(); + + assertEntityAndInstance(entityOptional.get(), instance); + + Comment comment = new Comment("1", "Admin"); + comment.setContent("This the comment 1"); + comment.setUpdatedAt(new Date()); + + instance.addComment(comment); + + entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + UserTaskInstanceEntity userTaskInstanceEntity = entityOptional.get(); + + Assertions.assertThat(userTaskInstanceEntity.getComments()) + .hasSize(1); + + assertTaskComments(entityOptional.get().getComments(), instance.getComments()); + + Comment comment2 = new Comment("2", "Admin"); + comment2.setContent("This the comment 2"); + comment2.setUpdatedAt(new Date()); + + instance.addComment(comment2); + + entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + userTaskInstanceEntity = entityOptional.get(); + + Assertions.assertThat(userTaskInstanceEntity.getComments()) + .hasSize(2); + + assertTaskComments(userTaskInstanceEntity.getComments(), instance.getComments()); + + instance.removeComment(comment); + instance.removeComment(comment2); + + entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + Assertions.assertThat(entityOptional.get().getComments()) + .isEmpty(); + + Assertions.assertThat(commentRepository.findAll()) + .isEmpty(); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + private void assertEntityAndInstance(UserTaskInstanceEntity entity, UserTaskInstance instance) { + Assertions.assertThat(entity) + .hasFieldOrPropertyWithValue("id", instance.getId()) + .hasFieldOrPropertyWithValue("userTaskId", instance.getUserTaskId()) + .hasFieldOrPropertyWithValue("taskName", instance.getTaskName()) + .hasFieldOrPropertyWithValue("taskDescription", instance.getTaskDescription()) + .hasFieldOrPropertyWithValue("taskPriority", instance.getTaskPriority()) + .hasFieldOrPropertyWithValue("status", instance.getStatus().getName()) + .hasFieldOrPropertyWithValue("terminationType", instance.getStatus().getTerminate().toString()) + .hasFieldOrPropertyWithValue("externalReferenceId", instance.getExternalReferenceId()) + .hasFieldOrPropertyWithValue("actualOwner", instance.getActualOwner()); + + assertTaskUserAssignment(entity.getPotentialUsers(), instance.getPotentialUsers()); + assertTaskUserAssignment(entity.getPotentialGroups(), instance.getPotentialGroups()); + assertTaskUserAssignment(entity.getAdminUsers(), instance.getAdminUsers()); + assertTaskUserAssignment(entity.getAdminGroups(), instance.getAdminGroups()); + assertTaskUserAssignment(entity.getExcludedUsers(), instance.getExcludedUsers()); + + assertTaskDataAssignments(entity.getInputs(), instance.getInputs()); + assertTaskDataAssignments(entity.getOutputs(), instance.getOutputs()); + + assertTaskAttachments(entity.getAttachments(), instance.getAttachments()); + assertTaskComments(entity.getComments(), instance.getComments()); + assertTaskMetaData(entity.getMetadata(), instance.getMetadata()); + } + + private void assertTaskUserAssignment(Collection entityAssignments, Set instanceAssignments) { + Assertions.assertThat(entityAssignments) + .hasSize(instanceAssignments.size()) + .containsExactlyInAnyOrder(instanceAssignments.toArray(new String[0])); + } + + private void assertTaskDataAssignments(Collection entityData, Map instanceData) { + Assertions.assertThat(entityData) + .hasSize(instanceData.size()) + .allMatch(data -> instanceData.containsKey(data.getName())) + .allMatch(data -> Objects.nonNull(data.getValue())); + } + + private void assertTaskMetaData(Collection metadata, Map instanceMetadata) { + Assertions.assertThat(metadata) + .hasSize(instanceMetadata.size()) + .allMatch(data -> instanceMetadata.containsKey(data.getName())) + .allMatch(data -> Objects.nonNull(data.getValue())) + .allMatch(data -> data.getJavaType().equals(instanceMetadata.get(data.getName()).getClass().getName())); + } + + private void assertTaskAttachments(Collection entityAttachments, Collection instanceAttachments) { + Assertions.assertThat(entityAttachments) + .hasSize(instanceAttachments.size()); + + entityAttachments.forEach(entityAttachment -> { + Optional optional = instanceAttachments.stream() + .filter(instanceAttachment -> instanceAttachment.getId().equals(entityAttachment.getId())) + .findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + Attachment instanceAttachment = optional.get(); + + Assertions.assertThat(entityAttachment) + .hasFieldOrPropertyWithValue("id", instanceAttachment.getId()) + .hasFieldOrPropertyWithValue("name", instanceAttachment.getName()) + .hasFieldOrPropertyWithValue("updatedBy", instanceAttachment.getUpdatedBy()) + .matches(entity -> entity.getUpdatedAt().getTime() == instanceAttachment.getUpdatedAt().getTime()) + .hasFieldOrPropertyWithValue("url", instanceAttachment.getContent().toString()); + }); + } + + private void assertTaskComments(Collection entityComments, Collection instanceComments) { + Assertions.assertThat(entityComments) + .hasSize(instanceComments.size()); + + entityComments.forEach(entityComment -> { + Optional optional = instanceComments.stream() + .filter(comment -> comment.getId().equals(entityComment.getId())) + .findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + Comment instanceComment = optional.get(); + + Assertions.assertThat(instanceComment) + .hasFieldOrPropertyWithValue("id", instanceComment.getId()) + .hasFieldOrPropertyWithValue("updatedBy", instanceComment.getUpdatedBy()) + .hasFieldOrPropertyWithValue("updatedAt", instanceComment.getUpdatedAt()) + .hasFieldOrPropertyWithValue("content", instanceComment.getContent()); + }); + } + + private UserTaskInstance createUserTaskInstance() { + DefaultUserTaskInstance instance = new DefaultUserTaskInstance(); + instance.setId(UUID.randomUUID().toString()); + instance.setUserTaskId("user-task-id"); + instance.setTaskName("test-task"); + instance.setTaskDescription("this is a test task description"); + instance.setTaskPriority(1); + instance.setStatus(UserTaskState.of("Complete", UserTaskState.TerminationType.COMPLETED)); + + instance.setActuaOwner("Homer"); + instance.setPotentialUsers(Set.of("Bart")); + instance.setPotentialGroups(Set.of("Simpson", "Family")); + instance.setAdminUsers(Set.of("Seymour")); + instance.setAdminGroups(Set.of("Administrators", "Managers")); + instance.setExcludedUsers(Set.of("Ned")); + + instance.setExternalReferenceId("external-reference-id"); + + instance.setMetadata("ProcessId", "process-id"); + instance.setMetadata("ProcessType", "BPMN"); + instance.setMetadata("ProcessVersion", "1.0.0"); + instance.setMetadata("boolean", true); + instance.setMetadata("integer", 0); + + instance.setInput("string", "hello this is a string"); + instance.setInput("integer", 1); + instance.setInput("long", 1000L); + instance.setInput("float", 1.02f); + instance.setInput("boolean", true); + instance.setInput("date", new Date()); + instance.setInput("person", new Person("Ned", "Stark", 50)); + + instance.setOutput("person", new Person("Jon", "Snow", 17)); + + instance.setInstances(userTaskInstances); + + return instance; + } + + @AfterAll + public static void tearDown() { + System.out.println("down"); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java new file mode 100644 index 00000000000..6fd0b78218e --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java @@ -0,0 +1,33 @@ +/* + * 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.jbpm.usertask.jpa; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +public class H2QuarkusJPAUserTaskInstancesTest extends BaseQuarkusJPAUserTaskInstancesTest { +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java new file mode 100644 index 00000000000..d02a789b903 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * 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.jbpm.usertask.jpa; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class H2QuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-h2"; + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java new file mode 100644 index 00000000000..eec2099837c --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java @@ -0,0 +1,35 @@ +/* + * 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.jbpm.usertask.jpa; + +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLQuarkusJPAUserTaskInstancesTest extends BaseQuarkusJPAUserTaskInstancesTest { + +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java new file mode 100644 index 00000000000..8733f3ad29d --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * 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.jbpm.usertask.jpa; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class PostgreSQLQuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-postgresql"; + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.java new file mode 100644 index 00000000000..5a502115e08 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.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.jbpm.usertask.jpa.models; + +import java.util.Objects; + +public class Person { + String name; + String lastName; + int age; + + public Person() { + } + + public Person(String name, String lastName, int age) { + this.name = name; + this.lastName = lastName; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Person person = (Person) o; + return age == person.age && Objects.equals(name, person.name) && Objects.equals(lastName, person.lastName); + } + + @Override + public int hashCode() { + return Objects.hash(name, lastName, age); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/META-INF/beans.xml b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/META-INF/beans.xml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/application.properties b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/application.properties new file mode 100644 index 00000000000..62677c92319 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/resources/application.properties @@ -0,0 +1,28 @@ +# +# 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. +# + + +%test-postgresql.quarkus.datasource.db-kind=postgresql +%test-postgresql.quarkus.datasource.devservices.enabled=false + +%test-h2.quarkus.datasource.db-kind=h2 +%test-h2.quarkus.datasource.username=kogito +%test-h2.quarkus.datasource.jdbc.url=jdbc:h2:mem:default + +kie.flyway.enabled=true diff --git a/quarkus/addons/pom.xml b/quarkus/addons/pom.xml index 2a51d08ca82..de5f6685ed0 100644 --- a/quarkus/addons/pom.xml +++ b/quarkus/addons/pom.xml @@ -60,6 +60,7 @@ marshallers process-definitions dynamic + jbpm-usertask-storage-jpa From 6412028fd81ee5ac599ce7bcde08b7bf76b558eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Fri, 18 Oct 2024 15:33:45 +0200 Subject: [PATCH 2/9] - testing --- .../common/jbpm-usertask-storage-jpa/pom.xml | 10 + .../usertask/jpa/JPAUserTaskInstances.java | 10 +- .../jpa/mapper/AttachmentsEntityMapper.java | 13 +- .../jpa/mapper/CommentsEntityMapper.java | 11 +- .../jpa/mapper/TaskInputsEntityMapper.java | 12 +- .../jpa/mapper/TaskMetadataEntityMapper.java | 11 +- .../jpa/mapper/TaskOutputsEntityMapper.java | 16 +- .../mapper/UserTaskInstanceEntityMapper.java | 2 +- ...askDataEntity.java => TaskDataEntity.java} | 43 +-- .../jpa/model/{data => }/TaskInputEntity.java | 24 +- .../jpa/model/TaskMetadataEntity.java | 61 +--- .../model/{data => }/TaskOutputEntity.java | 23 +- .../jpa/model/UserTaskInstanceEntity.java | 3 - .../jpa/repository/TaskInputRepository.java | 2 +- .../jpa/repository/TaskOutputRepository.java | 2 +- .../h2/V1.0.0__jBPM_user_task_create.sql | 12 +- .../V1.0.0__jBPM_user_task_create.sql | 14 +- .../jpa/JPAUserTaskInstancesTest.java | 220 ++++++++++++ .../mapper/AttachmentsEntityMapperTest.java | 135 ++++++++ .../jpa/mapper/CommentsEntityMapperTest.java | 145 ++++++++ .../mapper/TaskInputsEntityMapperTest.java | 144 ++++++++ .../mapper/TaskMetadataEntityMapperTest.java | 145 ++++++++ .../mapper/TaskOutputsEntityMapperTest.java | 143 ++++++++ .../UserTaskInstanceEntityMapperTest.java | 101 ++++++ .../usertask/jpa/mapper}/models/Person.java | 2 +- .../usertask/jpa/mapper/utils/TestUtils.java | 317 ++++++++++++++++++ .../kie/kogito/usertask/UserTaskInstance.java | 2 +- .../impl/DefaultUserTaskInstance.java | 20 +- .../lifecycle/DefaultUserTaskLifeCycle.java | 6 +- kogito-bom/pom.xml | 18 +- .../jbpm-usertask-storage-jpa/runtime/pom.xml | 11 +- .../BaseQuarkusJPAUserTaskInstancesTest.java | 211 +++++------- 32 files changed, 1585 insertions(+), 304 deletions(-) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/{data/AbstractTaskDataEntity.java => TaskDataEntity.java} (61%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/{data => }/TaskInputEntity.java (70%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/{data => }/TaskOutputEntity.java (70%) create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapperTest.java rename {quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa => addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper}/models/Person.java (97%) create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java diff --git a/addons/common/jbpm-usertask-storage-jpa/pom.xml b/addons/common/jbpm-usertask-storage-jpa/pom.xml index dd1a487512f..dd28be272d2 100644 --- a/addons/common/jbpm-usertask-storage-jpa/pom.xml +++ b/addons/common/jbpm-usertask-storage-jpa/pom.xml @@ -38,6 +38,16 @@ jbpm-usertask + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + org.junit.jupiter junit-jupiter-engine diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java index 0540bf05d2e..d2f6a5e4cbf 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java @@ -31,7 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class JPAUserTaskInstances implements UserTaskInstances { +public class JPAUserTaskInstances implements UserTaskInstances { public static final Logger LOGGER = LoggerFactory.getLogger(JPAUserTaskInstances.class); private final UserTaskInstanceRepository userTaskInstanceRepository; @@ -68,6 +68,12 @@ public boolean exists(String userTaskInstanceId) { @Override public UserTaskInstance create(UserTaskInstance userTaskInstance) { + Optional optional = userTaskInstanceRepository.findById(userTaskInstance.getId()); + + if (optional.isPresent()) { + LOGGER.error("Cannot create userTaskInstance with id {}. Task Already exists.", userTaskInstance.getId()); + throw new IllegalArgumentException("Cannot create userTaskInstance with id " + userTaskInstance.getId() + ". Task Already exists."); + } UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); entity.setId(userTaskInstance.getId()); @@ -76,8 +82,6 @@ public UserTaskInstance create(UserTaskInstance userTaskInstance) { userTaskInstanceEntityMapper.mapTaskInstanceToEntity(userTaskInstance, entity); - this.userTaskInstanceRepository.update(entity); - return this.reconnectUserTaskInstance.apply(userTaskInstance); } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java index aa706319253..b22735db2eb 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java @@ -21,11 +21,13 @@ import java.net.URI; import java.util.Collection; +import java.util.List; import org.jbpm.usertask.jpa.model.AttachmentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; import org.jbpm.usertask.jpa.repository.AttachmentRepository; import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; import org.kie.kogito.usertask.model.Attachment; public class AttachmentsEntityMapper { @@ -61,13 +63,16 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta } public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { - userTaskInstance.getAttachments().clear(); - userTaskInstanceEntity.getAttachments().forEach(attachmentEntity -> { + + List attachments = userTaskInstanceEntity.getAttachments().stream().map(attachmentEntity -> { Attachment attachment = new Attachment(attachmentEntity.getId(), attachmentEntity.getUpdatedBy()); attachment.setId(attachmentEntity.getId()); + attachment.setName(attachmentEntity.getName()); attachment.setContent(URI.create(attachmentEntity.getUrl())); attachment.setUpdatedAt(attachmentEntity.getUpdatedAt()); - userTaskInstance.addAttachment(attachment); - }); + return attachment; + }).toList(); + + ((DefaultUserTaskInstance) userTaskInstance).setAttachments(attachments); } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java index 309463894c6..da767fdfadd 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java @@ -20,11 +20,13 @@ package org.jbpm.usertask.jpa.mapper; import java.util.Collection; +import java.util.List; import org.jbpm.usertask.jpa.model.CommentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; import org.jbpm.usertask.jpa.repository.CommentRepository; import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; import org.kie.kogito.usertask.model.Comment; public class CommentsEntityMapper { @@ -60,13 +62,14 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta } public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { - userTaskInstance.getComments().clear(); - userTaskInstanceEntity.getComments().forEach(commentEntity -> { + List comments = userTaskInstanceEntity.getComments().stream().map(commentEntity -> { Comment comment = new Comment(commentEntity.getId(), commentEntity.getUpdatedBy()); comment.setId(commentEntity.getId()); comment.setContent(commentEntity.getComment()); comment.setUpdatedAt(commentEntity.getUpdatedAt()); - userTaskInstance.addComment(comment); - }); + return comment; + }).toList(); + + ((DefaultUserTaskInstance) userTaskInstance).setComments(comments); } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java index d1f83596d05..12a6c50f986 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java @@ -21,13 +21,16 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; +import org.jbpm.usertask.jpa.model.TaskInputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.model.data.TaskInputEntity; import org.jbpm.usertask.jpa.repository.TaskInputRepository; import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; public class TaskInputsEntityMapper { @@ -51,6 +54,7 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta userTaskInstance.getInputs().forEach((key, value) -> { TaskInputEntity inputEntity = userTaskInstanceEntity.getInputs().stream().filter(entity -> entity.getName().equals(key)).findFirst().orElseGet(() -> { TaskInputEntity entity = new TaskInputEntity(); + entity.setName(key); userTaskInstanceEntity.addInput(entity); return entity; }); @@ -63,11 +67,11 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta } public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { - userTaskInstance.getInputs().clear(); - + Map inputs = new HashMap<>(); userTaskInstanceEntity.getInputs().forEach(taskInputEntity -> { String value = taskInputEntity.getValue() == null ? null : new String(taskInputEntity.getValue(), StandardCharsets.UTF_8); - userTaskInstance.getInputs().put(taskInputEntity.getName(), value); + inputs.put(taskInputEntity.getName(), JSONUtils.stringTreeToValue(value, taskInputEntity.getJavaType())); }); + ((DefaultUserTaskInstance) userTaskInstance).setInputs(inputs); } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java index c8f0b41e88d..999c7357496 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java @@ -20,6 +20,8 @@ package org.jbpm.usertask.jpa.mapper; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; @@ -27,6 +29,7 @@ import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; public class TaskMetadataEntityMapper { @@ -62,10 +65,10 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta } public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { - userTaskInstance.getMetadata().clear(); - userTaskInstanceEntity.getMetadata().forEach(metadataEntity -> { - Object value = JSONUtils.stringTreeToValue(metadataEntity.getValue(), metadataEntity.getJavaType()); - userTaskInstance.getMetadata().put(metadataEntity.getName(), value); + Map metadata = new HashMap<>(); + userTaskInstanceEntity.getMetadata().forEach(metadataEntry -> { + metadata.put(metadataEntry.getName(), JSONUtils.stringTreeToValue(metadataEntry.getValue(), metadataEntry.getJavaType())); }); + ((DefaultUserTaskInstance) userTaskInstance).setMetadata(metadata); } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java index 011077bc67e..1fa7d4ae282 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java @@ -21,13 +21,16 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; +import org.jbpm.usertask.jpa.model.TaskOutputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.model.data.TaskOutputEntity; import org.jbpm.usertask.jpa.repository.TaskOutputRepository; import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; public class TaskOutputsEntityMapper { @@ -51,6 +54,7 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta userTaskInstance.getOutputs().forEach((key, value) -> { TaskOutputEntity outputEntity = userTaskInstanceEntity.getOutputs().stream().filter(entity -> entity.getName().equals(key)).findFirst().orElseGet(() -> { TaskOutputEntity entity = new TaskOutputEntity(); + entity.setName(key); userTaskInstanceEntity.addOutput(entity); return entity; }); @@ -63,11 +67,11 @@ public void mapInstanceToEntity(UserTaskInstance userTaskInstance, UserTaskInsta } public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { - userTaskInstance.getOutputs().clear(); - - userTaskInstanceEntity.getOutputs().forEach(TaskOutputEntity -> { - String value = TaskOutputEntity.getValue() == null ? null : new String(TaskOutputEntity.getValue(), StandardCharsets.UTF_8); - userTaskInstance.getOutputs().put(TaskOutputEntity.getName(), value); + Map outputs = new HashMap<>(); + userTaskInstanceEntity.getOutputs().forEach(taskOutputEntity -> { + String value = taskOutputEntity.getValue() == null ? null : new String(taskOutputEntity.getValue(), StandardCharsets.UTF_8); + outputs.put(taskOutputEntity.getName(), JSONUtils.stringTreeToValue(value, taskOutputEntity.getJavaType())); }); + ((DefaultUserTaskInstance) userTaskInstance).setOutputs(outputs); } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java index b77b10abbdb..e03125742ba 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapper.java @@ -83,7 +83,7 @@ public UserTaskInstance mapTaskEntityToInstance(UserTaskInstanceEntity entity) { UserTaskState.TerminationType terminationType = entity.getTerminationType() == null ? null : UserTaskState.TerminationType.valueOf(entity.getTerminationType()); instance.setStatus(UserTaskState.of(entity.getStatus(), terminationType)); - instance.setActuaOwner(entity.getActualOwner()); + instance.setActualOwner(entity.getActualOwner()); instance.setPotentialUsers(Set.copyOf(entity.getPotentialUsers())); instance.setPotentialGroups(Set.copyOf(entity.getPotentialGroups())); instance.setAdminUsers(Set.copyOf(entity.getAdminUsers())); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java similarity index 61% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java index 893bbd68c31..163e45af01f 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/AbstractTaskDataEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java @@ -17,35 +17,23 @@ * under the License. */ -package org.jbpm.usertask.jpa.model.data; +package org.jbpm.usertask.jpa.model; -import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import java.util.Objects; import jakarta.persistence.*; @MappedSuperclass -@SequenceGenerator(name = "jbpm_user_task_data_mapping_id_seq", sequenceName = "jbpm_user_task_data_mapping_id_seq") -public abstract class AbstractTaskDataEntity { +public abstract class TaskDataEntity { @Id - @GeneratedValue(strategy = GenerationType.AUTO, generator = "jbpm_user_task_data_mapping_id_seq") - protected Long id; - protected String name; - protected byte[] value; + protected T value; @Column(name = "java_type") protected String javaType; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - public String getName() { return name; } @@ -54,11 +42,11 @@ public void setName(String name) { this.name = name; } - public byte[] getValue() { + public T getValue() { return value; } - public void setValue(byte[] value) { + public void setValue(T value) { this.value = value; } @@ -70,7 +58,22 @@ public void setJavaType(String javaType) { this.javaType = javaType; } - abstract UserTaskInstanceEntity getTaskInstance(); + public abstract UserTaskInstanceEntity getTaskInstance(); - abstract void setTaskInstance(UserTaskInstanceEntity taskInstance); + public abstract void setTaskInstance(UserTaskInstanceEntity taskInstance); + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + TaskDataEntity that = (TaskDataEntity) o; + return Objects.equals(getName(), that.getName()) && Objects.equals(getValue(), that.getValue()) && Objects.equals(getJavaType(), that.getJavaType()); + } + + @Override + public int hashCode() { + return Objects.hash(getName(), getValue(), getJavaType()); + } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java similarity index 70% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java index 19a6c7efa32..3b1b54e92d7 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskInputEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java @@ -17,9 +17,9 @@ * under the License. */ -package org.jbpm.usertask.jpa.model.data; +package org.jbpm.usertask.jpa.model; -import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import java.util.Objects; import jakarta.persistence.*; @@ -29,8 +29,9 @@ @AttributeOverride(name = "name", column = @Column(name = "input_name")), @AttributeOverride(name = "value", column = @Column(name = "input_value")) }) -public class TaskInputEntity extends AbstractTaskDataEntity { +public class TaskInputEntity extends TaskDataEntity { + @Id @ManyToOne(optional = false) @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_inputs_tid")) private UserTaskInstanceEntity taskInstance; @@ -44,4 +45,21 @@ public UserTaskInstanceEntity getTaskInstance() { public void setTaskInstance(UserTaskInstanceEntity taskInstance) { this.taskInstance = taskInstance; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + TaskInputEntity that = (TaskInputEntity) o; + return Objects.equals(getTaskInstance(), that.getTaskInstance()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getTaskInstance()); + } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java index 5bcff9c2afe..8d8a714997a 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java @@ -19,56 +19,20 @@ package org.jbpm.usertask.jpa.model; -import java.util.Objects; - import jakarta.persistence.*; @Entity @Table(name = "jbpm_user_tasks_metadata") -@SequenceGenerator(name = "jbpm_user_task_metadata_id_seq", sequenceName = "jbpm_user_task_metadata_id_seq") -public class TaskMetadataEntity { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO, generator = "jbpm_user_task_metadata_id_seq") - private Long id; - - @Column(name = "metadata_name") - protected String name; - - @Column(name = "metadata_value") - protected String value; - - @Column(name = "java_type") - protected String javaType; +@AttributeOverrides({ + @AttributeOverride(name = "name", column = @Column(name = "metadata_name")), + @AttributeOverride(name = "value", column = @Column(name = "metadata_value")) +}) +public class TaskMetadataEntity extends TaskDataEntity { @ManyToOne(optional = false) @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_metadata_tid")) private UserTaskInstanceEntity taskInstance; - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getJavaType() { - return javaType; - } - - public void setJavaType(String javaType) { - this.javaType = javaType; - } - public UserTaskInstanceEntity getTaskInstance() { return taskInstance; } @@ -77,19 +41,4 @@ public void setTaskInstance(UserTaskInstanceEntity taskInstance) { this.taskInstance = taskInstance; } - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - TaskMetadataEntity that = (TaskMetadataEntity) o; - return Objects.equals(name, that.name) && Objects.equals(value, that.value) && Objects.equals(javaType, that.javaType) && Objects.equals(taskInstance, - that.taskInstance); - } - - @Override - public int hashCode() { - return Objects.hash(name, value, javaType, taskInstance); - } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java similarity index 70% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java index d986de0f63e..6a67ea047f4 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/data/TaskOutputEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java @@ -17,9 +17,9 @@ * under the License. */ -package org.jbpm.usertask.jpa.model.data; +package org.jbpm.usertask.jpa.model; -import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import java.util.Objects; import jakarta.persistence.*; @@ -29,8 +29,9 @@ @AttributeOverride(name = "name", column = @Column(name = "output_name")), @AttributeOverride(name = "value", column = @Column(name = "output_value")) }) -public class TaskOutputEntity extends AbstractTaskDataEntity { +public class TaskOutputEntity extends TaskDataEntity { + @Id @ManyToOne(optional = false) @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_outputs_tid")) private UserTaskInstanceEntity taskInstance; @@ -45,4 +46,20 @@ public void setTaskInstance(UserTaskInstanceEntity taskInstance) { this.taskInstance = taskInstance; } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + TaskOutputEntity that = (TaskOutputEntity) o; + return Objects.equals(getTaskInstance(), that.getTaskInstance()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getTaskInstance()); + } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java index b5d54fce40d..365d0c75bec 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java @@ -21,9 +21,6 @@ import java.util.*; -import org.jbpm.usertask.jpa.model.data.TaskInputEntity; -import org.jbpm.usertask.jpa.model.data.TaskOutputEntity; - import jakarta.persistence.*; @Entity diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java index fa139621943..9b7fdcc3c7b 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java @@ -19,7 +19,7 @@ package org.jbpm.usertask.jpa.repository; -import org.jbpm.usertask.jpa.model.data.TaskInputEntity; +import org.jbpm.usertask.jpa.model.TaskInputEntity; public class TaskInputRepository extends BaseRepository { diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java index 0d1f13353f1..0346f88fca2 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java @@ -19,7 +19,7 @@ package org.jbpm.usertask.jpa.repository; -import org.jbpm.usertask.jpa.model.data.TaskOutputEntity; +import org.jbpm.usertask.jpa.model.TaskOutputEntity; public class TaskOutputRepository extends BaseRepository { diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql index 25500c2d831..803df5ce2eb 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql @@ -80,30 +80,27 @@ create table jbpm_user_tasks_comments ( ); create table jbpm_user_tasks_inputs ( - id bigint not null, task_id varchar(50) not null, input_name varchar(255) not null, input_value varbinary(max), java_type varchar(255), - primary key (id) + primary key (task_id, input_name) ); create table jbpm_user_tasks_outputs ( - id bigint not null, task_id varchar(50) not null, output_name varchar(255) not null, output_value varbinary(max), java_type varchar(255), - primary key (id) + primary key (task_id, output_name) ); create table jbpm_user_tasks_metadata ( - id bigint not null, task_id varchar(50) not null, metadata_name varchar(255) not null, metadata_value varchar(512), java_type varchar(255), - primary key (id) + primary key (task_id, metadata_name) ); alter table if exists jbpm_user_tasks_potential_users @@ -166,7 +163,4 @@ drop constraint if exists fk_jbpm_user_tasks_metadata_tid cascade; alter table if exists jbpm_user_tasks_metadata add constraint fk_jbpm_user_tasks_metadata_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; -create sequence jbpm_user_task_data_mapping_id_seq start with 1 increment by 10; -create sequence jbpm_user_task_metadata_id_seq start with 1 increment by 10; - diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql index 8e6fb2a0407..814b72addbc 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql @@ -80,30 +80,27 @@ create table jbpm_user_tasks_comments ( ); create table jbpm_user_tasks_inputs ( - id bigint not null, task_id varchar(50) not null, input_name varchar(255) not null, input_value bytea, java_type varchar(255), - primary key (id) + primary key (task_id, input_name) ); create table jbpm_user_tasks_outputs ( - id bigint not null, task_id varchar(50) not null, output_name varchar(255) not null, output_value bytea, java_type varchar(255), - primary key (id) + primary key (task_id, output_name) ); create table jbpm_user_tasks_metadata ( - id bigint not null, task_id varchar(50), metadata_name varchar(255) not null, metadata_value varchar(512), java_type varchar(255), - primary key (id) + primary key (task_id, metadata_name) ); alter table if exists jbpm_user_tasks_potential_users @@ -164,7 +161,4 @@ alter table if exists jbpm_user_tasks_metadata drop constraint if exists fk_jbpm_user_tasks_metadata_tid cascade; alter table if exists jbpm_user_tasks_metadata -add constraint fk_jbpm_user_tasks_metadata_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; - -create sequence jbpm_user_task_data_mapping_id_seq start with 1 increment by 10; -create sequence jbpm_user_task_metadata_id_seq start with 1 increment by 10; \ No newline at end of file +add constraint fk_jbpm_user_tasks_metadata_tid foreign key (task_id) references jbpm_user_tasks(id) on delete cascade; \ No newline at end of file diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java new file mode 100644 index 00000000000..4054ca12eb2 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java @@ -0,0 +1,220 @@ +/* + * 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.jbpm.usertask.jpa; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.*; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.auth.IdentityProviders; +import org.kie.kogito.usertask.UserTaskInstance; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class JPAUserTaskInstancesTest { + + @Mock + private UserTaskInstanceRepository userTaskInstanceRepository; + + @Mock + private AttachmentsEntityMapper attachmentsEntityMapper; + @Mock + private CommentsEntityMapper commentsEntityMapper; + @Mock + private TaskMetadataEntityMapper metadataEntityMapper; + @Mock + private TaskInputsEntityMapper inputsEntityMapper; + @Mock + private TaskOutputsEntityMapper outputsEntityMapper; + + private UserTaskInstanceEntityMapper userTaskInstanceEntityMapper; + @Mock + private Function reconnectUserTaskInstance; + @Mock + private Function disconnectUserTaskInstance; + + private JPAUserTaskInstances jpaUserTaskInstances; + + @BeforeEach + public void setup() { + userTaskInstanceEntityMapper = spy(new UserTaskInstanceEntityMapper(attachmentsEntityMapper, commentsEntityMapper, metadataEntityMapper, inputsEntityMapper, outputsEntityMapper)); + jpaUserTaskInstances = new JPAUserTaskInstances(userTaskInstanceRepository, userTaskInstanceEntityMapper); + jpaUserTaskInstances.setReconnectUserTaskInstance(reconnectUserTaskInstance); + jpaUserTaskInstances.setDisconnectUserTaskInstance(disconnectUserTaskInstance); + } + + @Test + public void testSuccessfulFindById() { + Optional result = Optional.of(TestUtils.createUserTaskInstanceEntity()); + + when(userTaskInstanceRepository.findById(any())).thenReturn(result); + + jpaUserTaskInstances.findById("1234"); + + verify(userTaskInstanceEntityMapper, times(1)).mapTaskEntityToInstance(any()); + verify(reconnectUserTaskInstance, times(1)).apply(any()); + } + + @Test + public void testUnSuccessfulFindById() { + when(userTaskInstanceRepository.findById(any())).thenReturn(Optional.empty()); + + jpaUserTaskInstances.findById("1234"); + + verify(userTaskInstanceEntityMapper, never()).mapTaskEntityToInstance(any()); + verify(reconnectUserTaskInstance, never()).apply(any()); + } + + @Test + public void testSuccessfulExists() { + Optional result = Optional.of(TestUtils.createUserTaskInstanceEntity()); + + when(userTaskInstanceRepository.findById(any())).thenReturn(result); + + Assertions.assertThat(jpaUserTaskInstances.exists("1234")) + .isTrue(); + + verify(userTaskInstanceEntityMapper, never()).mapTaskEntityToInstance(any()); + verify(reconnectUserTaskInstance, never()).apply(any()); + } + + @Test + public void testUnSuccessfulExists() { + when(userTaskInstanceRepository.findById(any())).thenReturn(Optional.empty()); + + Assertions.assertThat(jpaUserTaskInstances.exists("1234")) + .isFalse(); + + verify(userTaskInstanceEntityMapper, never()).mapTaskEntityToInstance(any()); + verify(reconnectUserTaskInstance, never()).apply(any()); + } + + @Test + public void testSuccessfulFindByIdentity() { + List result = List.of(TestUtils.createUserTaskInstanceEntity(), TestUtils.createUserTaskInstanceEntity()); + + when(userTaskInstanceRepository.findByIdentity(any())).thenReturn(result); + + List instances = jpaUserTaskInstances.findByIdentity(IdentityProviders.of("user", "group")); + + Assertions.assertThat(instances) + .hasSize(2); + + verify(userTaskInstanceEntityMapper, times(2)).mapTaskEntityToInstance(any()); + verify(reconnectUserTaskInstance, times(2)).apply(any()); + + } + + @Test + public void testUnSuccessfulFindByIdentity() { + when(userTaskInstanceRepository.findByIdentity(any())).thenReturn(List.of()); + + List instances = jpaUserTaskInstances.findByIdentity(IdentityProviders.of("user", "group")); + + Assertions.assertThat(instances) + .isEmpty(); + + verify(userTaskInstanceEntityMapper, never()).mapTaskEntityToInstance(any()); + verify(reconnectUserTaskInstance, never()).apply(any()); + } + + @Test + public void testSuccessfulCreate() { + when(userTaskInstanceRepository.findById(any())).thenReturn(Optional.empty()); + + jpaUserTaskInstances.create(TestUtils.createUserTaskInstance()); + + verify(userTaskInstanceRepository, times(1)).persist(any()); + verify(userTaskInstanceEntityMapper, times(1)).mapTaskInstanceToEntity(any(), any()); + verify(reconnectUserTaskInstance, times(1)).apply(any()); + } + + @Test + public void testUnSuccessfulCreate() { + Optional result = Optional.of(TestUtils.createUserTaskInstanceEntity()); + when(userTaskInstanceRepository.findById(any())).thenReturn(result); + + Assertions.assertThatThrownBy(() -> { + jpaUserTaskInstances.create(TestUtils.createUserTaskInstance()); + }).hasMessageContaining("Task Already exists."); + + verify(userTaskInstanceRepository, never()).persist(any()); + verify(userTaskInstanceEntityMapper, never()).mapTaskInstanceToEntity(any(), any()); + verify(reconnectUserTaskInstance, never()).apply(any()); + } + + @Test + public void testSuccessfulUpdate() { + Optional result = Optional.of(TestUtils.createUserTaskInstanceEntity()); + when(userTaskInstanceRepository.findById(any())).thenReturn(result); + + jpaUserTaskInstances.update(TestUtils.createUserTaskInstance()); + + verify(userTaskInstanceRepository, times(1)).update(any()); + verify(userTaskInstanceEntityMapper, times(1)).mapTaskInstanceToEntity(any(), any()); + } + + @Test + public void testUnSuccessfulUpdate() { + when(userTaskInstanceRepository.findById(any())).thenReturn(Optional.empty()); + + Assertions.assertThatThrownBy(() -> { + jpaUserTaskInstances.update(TestUtils.createUserTaskInstance()); + }).hasMessageContaining("Could not find userTaskInstance with id "); + + verify(userTaskInstanceRepository, never()).persist(any()); + verify(userTaskInstanceEntityMapper, never()).mapTaskInstanceToEntity(any(), any()); + } + + @Test + public void testSuccessfulRemove() { + Optional result = Optional.of(TestUtils.createUserTaskInstanceEntity()); + when(userTaskInstanceRepository.findById(any())).thenReturn(result); + + jpaUserTaskInstances.remove(TestUtils.createUserTaskInstance()); + + verify(userTaskInstanceRepository, times(1)).remove(any()); + verify(disconnectUserTaskInstance, times(1)).apply(any()); + } + + @Test + public void testUnSuccessfulRemove() { + when(userTaskInstanceRepository.findById(any())).thenReturn(Optional.empty()); + + Assertions.assertThatThrownBy(() -> { + jpaUserTaskInstances.remove(TestUtils.createUserTaskInstance()); + }).hasMessageContaining("Could not remove userTaskInstance with id"); + + verify(userTaskInstanceRepository, never()).persist(any()); + verify(disconnectUserTaskInstance, never()).apply(any()); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java new file mode 100644 index 00000000000..cafdb8e166b --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java @@ -0,0 +1,135 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.net.URI; +import java.util.Date; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.AttachmentEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.model.Attachment; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class AttachmentsEntityMapperTest { + + @Mock + private AttachmentRepository repository; + private AttachmentsEntityMapper mapper; + + @BeforeEach + public void setup() { + mapper = new AttachmentsEntityMapper(repository); + } + + @Test + public void testMapAttachmentsFromInstanceToEntity() { + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + Attachment attachment = new Attachment("1", "John"); + attachment.setName("attachment 1"); + attachment.setContent(URI.create("http://localhost:8080/my-attachment.txt")); + attachment.setUpdatedAt(new Date()); + + Attachment attachment2 = new Attachment("2", "Ned"); + attachment2.setName("attachment 2"); + attachment2.setContent(URI.create("http://localhost:8080/my-attachment2.txt")); + attachment2.setUpdatedAt(new Date()); + + instance.addAttachment(attachment); + instance.addAttachment(attachment2); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getAttachments()) + .hasSize(2); + verify(repository, never()) + .remove(any()); + TestUtils.assertUserTaskEntityAttachments(entity.getAttachments(), instance.getAttachments()); + + instance.removeAttachment(attachment); + mapper.mapInstanceToEntity(instance, entity); + + verify(repository, times(1)) + .remove(any()); + Assertions.assertThat(entity.getAttachments()) + .hasSize(1); + TestUtils.assertUserTaskEntityAttachments(entity.getAttachments(), instance.getAttachments()); + + instance.removeAttachment(attachment2); + mapper.mapInstanceToEntity(instance, entity); + + verify(repository, times(2)) + .remove(any()); + Assertions.assertThat(entity.getAttachments()) + .hasSize(0); + } + + @Test + public void testMapAttachmentsFromEntityToInstance() { + + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + + AttachmentEntity attachment = new AttachmentEntity(); + attachment.setId("1"); + attachment.setUpdatedBy("John"); + attachment.setName("attachment 1"); + attachment.setUrl("http://localhost:8080/my-attachment.txt"); + attachment.setUpdatedAt(new Date()); + + AttachmentEntity attachment2 = new AttachmentEntity(); + attachment2.setId("2"); + attachment2.setUpdatedBy("Ned"); + attachment2.setName("attachment 2"); + attachment2.setUrl("http://localhost:8080/my-attachment_2.txt"); + attachment2.setUpdatedAt(new Date()); + + entity.addAttachment(attachment); + entity.addAttachment(attachment2); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getAttachments()) + .hasSize(2); + verify(repository, never()) + .remove(any()); + TestUtils.assertUserTaskInstanceAttachments(instance.getAttachments(), entity.getAttachments()); + + entity.removeAttachment(attachment); + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(entity.getAttachments()) + .hasSize(1); + TestUtils.assertUserTaskInstanceAttachments(instance.getAttachments(), entity.getAttachments()); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java new file mode 100644 index 00000000000..62477c2d7ab --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java @@ -0,0 +1,145 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.util.Date; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.CommentEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.model.Comment; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class CommentsEntityMapperTest { + + @Mock + private CommentRepository repository; + private CommentsEntityMapper mapper; + + @BeforeEach + public void setup() { + mapper = new CommentsEntityMapper(repository); + } + + @Test + public void testMapCommentsFromInstanceToEntity() { + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + Comment comment = new Comment("1", "John"); + comment.setContent("This is comment 1"); + comment.setUpdatedAt(new Date()); + + Comment comment2 = new Comment("2", "Ned"); + comment2.setContent("This is comment 2"); + comment2.setUpdatedAt(new Date()); + + instance.addComment(comment); + instance.addComment(comment2); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getComments()) + .hasSize(2); + verify(repository, never()) + .remove(any()); + + TestUtils.assertUserTaskEntityComments(entity.getComments(), instance.getComments()); + + instance.removeComment(comment); + mapper.mapInstanceToEntity(instance, entity); + + verify(repository, times(1)) + .remove(any()); + Assertions.assertThat(entity.getComments()) + .hasSize(1); + TestUtils.assertUserTaskEntityComments(entity.getComments(), instance.getComments()); + + instance.removeComment(comment2); + mapper.mapInstanceToEntity(instance, entity); + + verify(repository, times(2)) + .remove(any()); + Assertions.assertThat(entity.getComments()) + .hasSize(0); + } + + @Test + public void testMapCommentsFromEntityToInstance() { + + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + + CommentEntity comment = new CommentEntity(); + comment.setId("1"); + comment.setUpdatedBy("John"); + comment.setComment("This is comment 1"); + comment.setUpdatedAt(new Date()); + + CommentEntity comment2 = new CommentEntity(); + comment2.setId("2"); + comment2.setUpdatedBy("Ned"); + comment2.setComment("This is comment 2"); + comment2.setUpdatedAt(new Date()); + + entity.addComment(comment); + entity.addComment(comment2); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getComments()) + .hasSize(2); + verify(repository, never()) + .remove(any()); + + TestUtils.assertUserTaskInstanceComments(instance.getComments(), entity.getComments()); + + entity.removeComment(comment); + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(entity.getComments()) + .hasSize(1); + TestUtils.assertUserTaskInstanceComments(instance.getComments(), entity.getComments()); + + entity.removeComment(comment); + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(entity.getComments()) + .hasSize(1); + TestUtils.assertUserTaskInstanceComments(instance.getComments(), entity.getComments()); + + entity.removeComment(comment2); + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(entity.getComments()) + .hasSize(0); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java new file mode 100644 index 00000000000..1aaeed39d30 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java @@ -0,0 +1,144 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.nio.charset.StandardCharsets; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.TaskInputEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class TaskInputsEntityMapperTest { + + @Mock + private TaskInputRepository repository; + private TaskInputsEntityMapper mapper; + + @BeforeEach + public void setup() { + mapper = new TaskInputsEntityMapper(repository); + } + + @Test + public void testMapInputsFromInstanceToEntity() { + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getInputs()) + .hasSize(8); + verify(repository, never()) + .remove(any()); + TestUtils.assertUserTaskEntityInputs(entity, instance); + + instance.getInputs().remove("in_string"); + instance.getInputs().remove("in_integer"); + instance.getInputs().remove("in_null"); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getInputs()) + .hasSize(5); + verify(repository, times(3)) + .remove(any()); + + TestUtils.assertUserTaskEntityInputs(entity, instance); + + instance.getInputs().clear(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getInputs()) + .hasSize(0); + verify(repository, times(8)) + .remove(any()); + } + + @Test + public void testMapInputsFromEntityToInstance() { + final String stringValue = "This is the input value"; + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + TaskInputEntity input = new TaskInputEntity(); + input.setName("in_string"); + input.setValue(stringValue.getBytes(StandardCharsets.UTF_8)); + + entity.addInput(input); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getInputs()) + .hasSize(1); + + TestUtils.assertUserTaskInstanceInputs(instance, entity); + + entity.getInputs().clear(); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getInputs()) + .hasSize(0); + } + + @Test + public void testMappingRoundCircle() { + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getInputs()) + .hasSize(8); + verify(repository, never()) + .remove(any()); + + TestUtils.assertUserTaskEntityInputs(entity, instance); + + DefaultUserTaskInstance instance2 = new DefaultUserTaskInstance(); + + mapper.mapEntityToInstance(entity, instance2); + + Assertions.assertThat(instance2.getInputs()) + .hasSize(8); + + TestUtils.assertUserTaskInstanceInputs(instance2, entity); + + Assertions.assertThat(instance2.getInputs()) + .usingRecursiveComparison() + .isEqualTo(instance.getInputs()); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java new file mode 100644 index 00000000000..1e6d18de1fd --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java @@ -0,0 +1,145 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.TaskMetadataEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class TaskMetadataEntityMapperTest { + + @Mock + private TaskMetadataRepository repository; + private TaskMetadataEntityMapper mapper; + + @BeforeEach + public void setup() { + mapper = new TaskMetadataEntityMapper(repository); + } + + @Test + public void testMapMetadataFromInstanceToEntity() { + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getMetadata()) + .hasSize(6); + verify(repository, never()) + .remove(any()); + TestUtils.assertUserTaskEntityMetadata(entity, instance); + + instance.getMetadata().remove("ProcessId"); + instance.getMetadata().remove("ProcessType"); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getMetadata()) + .hasSize(4); + verify(repository, times(2)) + .remove(any()); + + TestUtils.assertUserTaskEntityMetadata(entity, instance); + + instance.getMetadata().clear(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getMetadata()) + .hasSize(0); + verify(repository, times(6)) + .remove(any()); + } + + @Test + public void testMapMetadataFromEntityToInstance() { + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + TaskMetadataEntity metadata = new TaskMetadataEntity(); + metadata.setName("ProcessId"); + metadata.setValue("1234"); + + TaskMetadataEntity metadata2 = new TaskMetadataEntity(); + metadata2.setName("CustomMetadata"); + metadata2.setValue("This is the metadata value"); + + entity.addMetadata(metadata); + entity.addMetadata(metadata2); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getMetadata()) + .hasSize(2); + + TestUtils.assertUserTaskInstanceMetadata(instance, entity); + + entity.getMetadata().clear(); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getMetadata()) + .hasSize(0); + } + + @Test + public void testFullMappingCircle() { + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getMetadata()) + .hasSize(6); + verify(repository, never()) + .remove(any()); + + TestUtils.assertUserTaskEntityMetadata(entity, instance); + + DefaultUserTaskInstance instance2 = new DefaultUserTaskInstance(); + + mapper.mapEntityToInstance(entity, instance2); + + Assertions.assertThat(instance2.getMetadata()) + .hasSize(6); + + TestUtils.assertUserTaskInstanceMetadata(instance2, entity); + + Assertions.assertThat(instance2.getMetadata()) + .usingRecursiveComparison() + .isEqualTo(instance.getMetadata()); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java new file mode 100644 index 00000000000..52da167c9d1 --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java @@ -0,0 +1,143 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import java.nio.charset.StandardCharsets; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.TaskOutputEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class TaskOutputsEntityMapperTest { + + @Mock + private TaskOutputRepository repository; + private TaskOutputsEntityMapper mapper; + + @BeforeEach + public void setup() { + mapper = new TaskOutputsEntityMapper(repository); + } + + @Test + public void testMapOutputsFromInstanceToEntity() { + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getOutputs()) + .hasSize(8); + verify(repository, never()) + .remove(any()); + TestUtils.assertUserTaskEntityOutputs(entity, instance); + + instance.getOutputs().remove("out_string"); + instance.getOutputs().remove("out_integer"); + instance.getOutputs().remove("out_null"); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getOutputs()) + .hasSize(5); + verify(repository, times(3)) + .remove(any()); + + TestUtils.assertUserTaskEntityOutputs(entity, instance); + + instance.getOutputs().clear(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getOutputs()) + .hasSize(0); + verify(repository, times(8)) + .remove(any()); + } + + @Test + public void testMapOutputsFromEntityToInstance() { + final String stringValue = "This is the output value"; + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + TaskOutputEntity output = new TaskOutputEntity(); + output.setName("out_string"); + output.setValue(stringValue.getBytes(StandardCharsets.UTF_8)); + + entity.addOutput(output); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getOutputs()) + .hasSize(1); + + TestUtils.assertUserTaskInstanceOutputs(instance, entity); + + entity.getOutputs().clear(); + + mapper.mapEntityToInstance(entity, instance); + + Assertions.assertThat(instance.getOutputs()) + .hasSize(0); + } + + @Test + public void testMappingRoundCircle() { + + UserTaskInstance instance = TestUtils.createUserTaskInstance(); + UserTaskInstanceEntity entity = new UserTaskInstanceEntity(); + + mapper.mapInstanceToEntity(instance, entity); + + Assertions.assertThat(entity.getOutputs()) + .hasSize(8); + verify(repository, never()) + .remove(any()); + TestUtils.assertUserTaskEntityOutputs(entity, instance); + + DefaultUserTaskInstance instance2 = new DefaultUserTaskInstance(); + + mapper.mapEntityToInstance(entity, instance2); + + Assertions.assertThat(instance2.getOutputs()) + .hasSize(8); + + TestUtils.assertUserTaskInstanceOutputs(instance2, entity); + + Assertions.assertThat(instance2.getOutputs()) + .usingRecursiveComparison() + .isEqualTo(instance.getOutputs()); + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapperTest.java new file mode 100644 index 00000000000..3b49d9b445d --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/UserTaskInstanceEntityMapperTest.java @@ -0,0 +1,101 @@ +/* + * 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.jbpm.usertask.jpa.mapper; + +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.usertask.UserTaskInstance; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +public class UserTaskInstanceEntityMapperTest { + + @Mock + private AttachmentsEntityMapper attachmentsEntityMapper; + @Mock + private CommentsEntityMapper commentsEntityMapper; + @Mock + private TaskMetadataEntityMapper metadataEntityMapper; + @Mock + private TaskInputsEntityMapper inputsEntityMapper; + @Mock + private TaskOutputsEntityMapper outputsEntityMapper; + + private UserTaskInstanceEntityMapper userTaskInstanceEntityMapper; + + @BeforeEach + public void setUp() { + this.userTaskInstanceEntityMapper = new UserTaskInstanceEntityMapper(attachmentsEntityMapper, commentsEntityMapper, metadataEntityMapper, inputsEntityMapper, outputsEntityMapper); + } + + @Test + public void testUserTaskInstanceToUserTaskEntityMapper() { + UserTaskInstance userTaskInstance = TestUtils.createUserTaskInstance(); + + UserTaskInstanceEntity userTaskInstanceEntity = new UserTaskInstanceEntity(); + + userTaskInstanceEntityMapper.mapTaskInstanceToEntity(userTaskInstance, userTaskInstanceEntity); + + verify(attachmentsEntityMapper, times(1)) + .mapInstanceToEntity(same(userTaskInstance), same(userTaskInstanceEntity)); + verify(commentsEntityMapper, times(1)) + .mapInstanceToEntity(same(userTaskInstance), same(userTaskInstanceEntity)); + verify(metadataEntityMapper, times(1)) + .mapInstanceToEntity(same(userTaskInstance), same(userTaskInstanceEntity)); + verify(inputsEntityMapper, times(1)) + .mapInstanceToEntity(same(userTaskInstance), same(userTaskInstanceEntity)); + verify(outputsEntityMapper, times(1)) + .mapInstanceToEntity(same(userTaskInstance), same(userTaskInstanceEntity)); + + TestUtils.assertUserTaskEntityData(userTaskInstanceEntity, userTaskInstance); + TestUtils.assertUserTaskEntityPotentialUserAndGroups(userTaskInstanceEntity, userTaskInstance); + TestUtils.assertUserTaskEntityAdminUserAndGroups(userTaskInstanceEntity, userTaskInstance); + TestUtils.assertUserTaskEntityExcludedUsers(userTaskInstanceEntity, userTaskInstance); + } + + @Test + public void testUserTaskEntityToUserTaskInstanceMapper() { + UserTaskInstanceEntity userTaskInstanceEntity = TestUtils.createUserTaskInstanceEntity(); + + UserTaskInstance userTaskInstance = userTaskInstanceEntityMapper.mapTaskEntityToInstance(userTaskInstanceEntity); + + verify(attachmentsEntityMapper, times(1)) + .mapEntityToInstance(same(userTaskInstanceEntity), same(userTaskInstance)); + verify(commentsEntityMapper, times(1)) + .mapEntityToInstance(same(userTaskInstanceEntity), same(userTaskInstance)); + verify(metadataEntityMapper, times(1)) + .mapEntityToInstance(same(userTaskInstanceEntity), same(userTaskInstance)); + verify(inputsEntityMapper, times(1)) + .mapEntityToInstance(same(userTaskInstanceEntity), same(userTaskInstance)); + verify(outputsEntityMapper, times(1)) + .mapEntityToInstance(same(userTaskInstanceEntity), same(userTaskInstance)); + + TestUtils.assertUserTaskInstanceData(userTaskInstance, userTaskInstanceEntity); + TestUtils.assertUserTaskInstancePotentialUserAndGroups(userTaskInstance, userTaskInstanceEntity); + TestUtils.assertUserTaskInstanceAdminUserAndGroups(userTaskInstance, userTaskInstanceEntity); + TestUtils.assertUserTaskInstanceExcludedUsers(userTaskInstance, userTaskInstanceEntity); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/models/Person.java similarity index 97% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.java rename to addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/models/Person.java index 5a502115e08..3c1d911f1e6 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/models/Person.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/models/Person.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.models; +package org.jbpm.usertask.jpa.mapper.models; import java.util.Objects; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java new file mode 100644 index 00000000000..bfc70f5624b --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java @@ -0,0 +1,317 @@ +/* + * 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.jbpm.usertask.jpa.mapper.utils; + +import java.util.*; + +import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.mapper.models.Person; +import org.jbpm.usertask.jpa.model.AttachmentEntity; +import org.jbpm.usertask.jpa.model.CommentEntity; +import org.jbpm.usertask.jpa.model.TaskDataEntity; +import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; +import org.kie.kogito.usertask.UserTaskInstance; +import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; +import org.kie.kogito.usertask.lifecycle.UserTaskState; +import org.kie.kogito.usertask.model.Attachment; +import org.kie.kogito.usertask.model.Comment; + +public class TestUtils { + + private TestUtils() { + } + + public static void assertUserTaskEntityData(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + Assertions.assertThat(userTaskInstanceEntity) + .hasFieldOrPropertyWithValue("id", userTaskInstance.getId()) + .hasFieldOrPropertyWithValue("userTaskId", userTaskInstance.getUserTaskId()) + .hasFieldOrPropertyWithValue("taskName", userTaskInstance.getTaskName()) + .hasFieldOrPropertyWithValue("taskDescription", userTaskInstance.getTaskDescription()) + .hasFieldOrPropertyWithValue("taskPriority", userTaskInstance.getTaskPriority()) + .hasFieldOrPropertyWithValue("status", userTaskInstance.getStatus().getName()) + .hasFieldOrPropertyWithValue("terminationType", userTaskInstance.getStatus().getTerminate().toString()) + .hasFieldOrPropertyWithValue("externalReferenceId", userTaskInstance.getExternalReferenceId()) + .hasFieldOrPropertyWithValue("actualOwner", userTaskInstance.getActualOwner()); + } + + public static void assertUserTaskInstanceData(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + UserTaskState.TerminationType terminationType = + Objects.isNull(userTaskInstanceEntity.getTerminationType()) ? null : UserTaskState.TerminationType.valueOf(userTaskInstanceEntity.getTerminationType()); + UserTaskState state = UserTaskState.of(userTaskInstanceEntity.getStatus(), terminationType); + + Assertions.assertThat(userTaskInstance) + .hasFieldOrPropertyWithValue("id", userTaskInstanceEntity.getId()) + .hasFieldOrPropertyWithValue("userTaskId", userTaskInstanceEntity.getUserTaskId()) + .hasFieldOrPropertyWithValue("taskName", userTaskInstanceEntity.getTaskName()) + .hasFieldOrPropertyWithValue("taskDescription", userTaskInstanceEntity.getTaskDescription()) + .hasFieldOrPropertyWithValue("taskPriority", userTaskInstanceEntity.getTaskPriority()) + .hasFieldOrPropertyWithValue("status", state) + .hasFieldOrPropertyWithValue("externalReferenceId", userTaskInstanceEntity.getExternalReferenceId()) + .hasFieldOrPropertyWithValue("actualOwner", userTaskInstanceEntity.getActualOwner()); + } + + public static void assertUserTaskEntityPotentialUserAndGroups(UserTaskInstanceEntity userTaskEntity, UserTaskInstance userTaskInstance) { + assertUserOrGroupsAssignments(userTaskEntity.getPotentialUsers(), userTaskInstance.getPotentialUsers()); + assertUserOrGroupsAssignments(userTaskEntity.getPotentialGroups(), userTaskInstance.getPotentialGroups()); + } + + public static void assertUserTaskEntityAdminUserAndGroups(UserTaskInstanceEntity userTaskEntity, UserTaskInstance userTaskInstance) { + assertUserOrGroupsAssignments(userTaskEntity.getAdminUsers(), userTaskInstance.getAdminUsers()); + assertUserOrGroupsAssignments(userTaskEntity.getAdminGroups(), userTaskInstance.getAdminGroups()); + } + + public static void assertUserTaskEntityExcludedUsers(UserTaskInstanceEntity userTaskEntity, UserTaskInstance userTaskInstance) { + assertUserOrGroupsAssignments(userTaskEntity.getExcludedUsers(), userTaskInstance.getExcludedUsers()); + } + + public static void assertUserTaskInstancePotentialUserAndGroups(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskEntity) { + assertUserOrGroupsAssignments(userTaskInstance.getPotentialUsers(), userTaskEntity.getPotentialUsers()); + assertUserOrGroupsAssignments(userTaskInstance.getPotentialGroups(), userTaskEntity.getPotentialGroups()); + } + + public static void assertUserTaskInstanceAdminUserAndGroups(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskEntity) { + assertUserOrGroupsAssignments(userTaskInstance.getAdminUsers(), userTaskEntity.getAdminUsers()); + assertUserOrGroupsAssignments(userTaskInstance.getAdminGroups(), userTaskEntity.getAdminGroups()); + } + + public static void assertUserTaskInstanceExcludedUsers(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskEntity) { + assertUserOrGroupsAssignments(userTaskInstance.getExcludedUsers(), userTaskEntity.getExcludedUsers()); + } + + private static void assertUserOrGroupsAssignments(Collection entityAssignments, Collection instanceAssignments) { + Assertions.assertThat(entityAssignments) + .hasSize(instanceAssignments.size()) + .containsExactlyInAnyOrder(instanceAssignments.toArray(new String[0])); + } + + public static void assertUserTaskEntityComments(Collection entityComments, Collection instanceComments) { + Assertions.assertThat(entityComments) + .hasSize(instanceComments.size()); + + entityComments.forEach(entityComment -> { + Optional optional = instanceComments.stream() + .filter(instanceComment -> instanceComment.getId().equals(entityComment.getId())) + .findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + Comment instanceComment = optional.get(); + + Assertions.assertThat(entityComment) + .hasFieldOrPropertyWithValue("id", instanceComment.getId()) + .hasFieldOrPropertyWithValue("comment", instanceComment.getContent()) + .hasFieldOrPropertyWithValue("updatedBy", instanceComment.getUpdatedBy()) + .matches(entity -> entity.getUpdatedAt().getTime() == instanceComment.getUpdatedAt().getTime()); + }); + } + + public static void assertUserTaskInstanceComments(Collection instanceComments, Collection entityComments) { + Assertions.assertThat(instanceComments) + .hasSize(instanceComments.size()); + + instanceComments.forEach(instanceComment -> { + Optional optional = entityComments.stream() + .filter(entityComment -> entityComment.getId().equals(instanceComment.getId())) + .findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + CommentEntity entityComment = optional.get(); + + Assertions.assertThat(instanceComment) + .hasFieldOrPropertyWithValue("id", entityComment.getId()) + .hasFieldOrPropertyWithValue("content", entityComment.getComment()) + .hasFieldOrPropertyWithValue("updatedBy", entityComment.getUpdatedBy()) + .matches(entity -> entity.getUpdatedAt().getTime() == entityComment.getUpdatedAt().getTime()); + }); + } + + public static void assertUserTaskEntityAttachments(Collection entityAttachments, Collection instanceAttachments) { + Assertions.assertThat(entityAttachments) + .hasSize(instanceAttachments.size()); + + entityAttachments.forEach(entityAttachment -> { + Optional optional = instanceAttachments.stream() + .filter(instanceAttachment -> instanceAttachment.getId().equals(entityAttachment.getId())) + .findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + Attachment instanceAttachment = optional.get(); + + Assertions.assertThat(entityAttachment) + .hasFieldOrPropertyWithValue("id", instanceAttachment.getId()) + .hasFieldOrPropertyWithValue("name", instanceAttachment.getName()) + .hasFieldOrPropertyWithValue("updatedBy", instanceAttachment.getUpdatedBy()) + .matches(entity -> entity.getUpdatedAt().getTime() == instanceAttachment.getUpdatedAt().getTime()) + .hasFieldOrPropertyWithValue("url", instanceAttachment.getContent().toString()); + }); + } + + public static void assertUserTaskInstanceAttachments(Collection instanceAttachments, Collection entityAttachments) { + Assertions.assertThat(instanceAttachments) + .hasSize(instanceAttachments.size()); + + instanceAttachments.forEach(instanceAttachment -> { + Optional optional = entityAttachments.stream() + .filter(entityAttachment -> entityAttachment.getId().equals(instanceAttachment.getId())) + .findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + AttachmentEntity entityAttachment = optional.get(); + + Assertions.assertThat(instanceAttachment) + .hasFieldOrPropertyWithValue("id", entityAttachment.getId()) + .hasFieldOrPropertyWithValue("name", entityAttachment.getName()) + .hasFieldOrPropertyWithValue("updatedBy", entityAttachment.getUpdatedBy()) + .matches(entity -> entity.getUpdatedAt().getTime() == entityAttachment.getUpdatedAt().getTime()) + .matches(entity -> entity.getContent().toString().equals(entityAttachment.getUrl())); + }); + } + + public static void assertUserTaskEntityInputs(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + assertUserTaskEntityMapData(userTaskInstanceEntity.getInputs(), userTaskInstance.getInputs()); + } + + public static void assertUserTaskEntityOutputs(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + assertUserTaskEntityMapData(userTaskInstanceEntity.getOutputs(), userTaskInstance.getOutputs()); + } + + public static void assertUserTaskEntityMetadata(UserTaskInstanceEntity userTaskInstanceEntity, UserTaskInstance userTaskInstance) { + assertUserTaskEntityMapData(userTaskInstanceEntity.getMetadata(), userTaskInstance.getMetadata()); + } + + private static void assertUserTaskEntityMapData(Collection entityData, Map instanceData) { + Assertions.assertThat(entityData.size()) + .isEqualTo(instanceData.size()); + + entityData.stream().forEach(entity -> { + Object value = instanceData.get(entity.getName()); + Assertions.assertThat(entity) + .isNotNull() + .matches(e -> instanceData.containsKey(e.getName())) + .matches(e -> Objects.isNull(e.getValue()) ? Objects.isNull(value) : e.getJavaType().equals(value.getClass().getName())); + }); + } + + public static void assertUserTaskInstanceInputs(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + assertUserTaskInstanceMapData(userTaskInstance.getInputs(), userTaskInstanceEntity.getInputs()); + } + + public static void assertUserTaskInstanceOutputs(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + assertUserTaskInstanceMapData(userTaskInstance.getOutputs(), userTaskInstanceEntity.getOutputs()); + } + + public static void assertUserTaskInstanceMetadata(UserTaskInstance userTaskInstance, UserTaskInstanceEntity userTaskInstanceEntity) { + assertUserTaskInstanceMapData(userTaskInstance.getMetadata(), userTaskInstanceEntity.getMetadata()); + } + + private static void assertUserTaskInstanceMapData(Map instanceData, Collection entityData) { + Assertions.assertThat(instanceData.size()) + .isEqualTo(entityData.size()); + + instanceData.forEach((key, value) -> { + Optional optional = entityData.stream().filter(data -> data.getName().equals(key)).findFirst(); + + Assertions.assertThat(optional) + .isPresent(); + + if (Objects.nonNull(value)) { + TaskDataEntity data = optional.get(); + Assertions.assertThat(value.getClass().getName()) + .isEqualTo(data.getJavaType()); + } + }); + } + + public static DefaultUserTaskInstance createUserTaskInstance() { + DefaultUserTaskInstance instance = new DefaultUserTaskInstance(); + instance.setId(UUID.randomUUID().toString()); + instance.setUserTaskId("user-task-id"); + instance.setTaskName("test-task"); + instance.setTaskDescription("this is a test task description"); + instance.setTaskPriority(1); + instance.setStatus(UserTaskState.of("Complete", UserTaskState.TerminationType.COMPLETED)); + + instance.setActualOwner("Homer"); + instance.setPotentialUsers(Set.of("Bart")); + instance.setPotentialGroups(Set.of("Simpson", "Family")); + instance.setAdminUsers(Set.of("Seymour")); + instance.setAdminGroups(Set.of("Administrators", "Managers")); + instance.setExcludedUsers(Set.of("Ned")); + + instance.setExternalReferenceId("external-reference-id"); + + instance.setMetadata("ProcessId", "process-id"); + instance.setMetadata("ProcessType", "BPMN"); + instance.setMetadata("ProcessVersion", "1.0.0"); + instance.setMetadata("boolean", true); + instance.setMetadata("integer", 0); + instance.setMetadata("null", 0); + + instance.setInput("in_string", "hello this is a string"); + instance.setInput("in_integer", 1); + instance.setInput("in_long", 1000L); + instance.setInput("in_float", 1.02f); + instance.setInput("in_boolean", true); + instance.setInput("in_date", new Date()); + instance.setInput("in_person", new Person("Ned", "Stark", 50)); + instance.setInput("in_null", null); + + instance.setOutput("out_string", "hello this is an output string"); + instance.setOutput("out_integer", 12); + instance.setOutput("out_long", 2000L); + instance.setOutput("out_float", 3.5f); + instance.setOutput("out_boolean", false); + instance.setOutput("out_date", new Date()); + instance.setOutput("out_person", new Person("Jon", "Snow", 17)); + instance.setOutput("out_null", null); + + return instance; + } + + public static UserTaskInstanceEntity createUserTaskInstanceEntity() { + UserTaskInstanceEntity instance = new UserTaskInstanceEntity(); + + instance.setId(UUID.randomUUID().toString()); + instance.setUserTaskId("user-task-id"); + instance.setTaskName("test-task"); + instance.setTaskDescription("this is a test task description"); + instance.setTaskPriority(1); + instance.setStatus("Complete"); + instance.setTerminationType(UserTaskState.TerminationType.COMPLETED.name()); + + instance.setActualOwner("Homer"); + instance.setPotentialUsers(Set.of("Bart")); + instance.setPotentialGroups(Set.of("Simpson", "Family")); + instance.setAdminUsers(Set.of("Seymour")); + instance.setAdminGroups(Set.of("Administrators", "Managers")); + instance.setExcludedUsers(Set.of("Ned")); + + instance.setExternalReferenceId("external-reference-id"); + + return instance; + } +} diff --git a/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java b/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java index 4a0023a0c41..192d53c1c27 100644 --- a/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java +++ b/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java @@ -39,7 +39,7 @@ public interface UserTaskInstance { boolean hasActualOwner(); - void setActuaOwner(String actualOwner); + void setActualOwner(String actualOwner); String getActualOwner(); diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java index ab5fb202bff..5aeba621c1d 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java @@ -18,15 +18,7 @@ */ package org.kie.kogito.usertask.impl; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; +import java.util.*; import org.kie.kogito.auth.IdentityProvider; import org.kie.kogito.internal.usertask.event.KogitoUserTaskEventSupport; @@ -141,7 +133,7 @@ public boolean hasActualOwner() { } @Override - public void setActuaOwner(String actualOwner) { + public void setActualOwner(String actualOwner) { this.actualOwner = actualOwner; if (this.userTaskEventSupport != null) { this.userTaskEventSupport.fireOneUserTaskStateChange(this, this.status, this.status); @@ -204,7 +196,7 @@ public Map getInputs() { } public void setInputs(Map inputs) { - inputs.forEach(this::setInput); + this.inputs = inputs; } public Map getOutputs() { @@ -212,7 +204,7 @@ public Map getOutputs() { } public void setOutputs(Map outputs) { - outputs.forEach(this::setOutput); + this.outputs = outputs; } @Override @@ -450,8 +442,6 @@ public Attachment removeAttachment(Attachment attachment) { public void setAttachments(List attachments) { this.attachments = attachments; - updatePersistence(); - } /** @@ -508,7 +498,6 @@ public Comment removeComment(Comment comment) { public void setComments(List comments) { this.comments = comments; - updatePersistence(); } public void setMetadata(String key, Object value) { @@ -522,7 +511,6 @@ public Map getMetadata() { public void setMetadata(Map metadata) { this.metadata = metadata; - updatePersistence(); } @Override diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java index a28a5accfde..6af8a612fcf 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java @@ -127,9 +127,9 @@ public Optional activate(UserTaskInstance userTaskInsta public Optional claim(UserTaskInstance userTaskInstance, UserTaskTransitionToken token, IdentityProvider identityProvider) { if (userTaskInstance instanceof DefaultUserTaskInstance defaultUserTaskInstance) { if (token.data().containsKey(PARAMETER_USER)) { - defaultUserTaskInstance.setActuaOwner((String) token.data().get(PARAMETER_USER)); + defaultUserTaskInstance.setActualOwner((String) token.data().get(PARAMETER_USER)); } else { - defaultUserTaskInstance.setActuaOwner(identityProvider.getName()); + defaultUserTaskInstance.setActualOwner(identityProvider.getName()); } } return Optional.empty(); @@ -137,7 +137,7 @@ public Optional claim(UserTaskInstance userTaskInstance public Optional release(UserTaskInstance userTaskInstance, UserTaskTransitionToken token, IdentityProvider identityProvider) { if (userTaskInstance instanceof DefaultUserTaskInstance defaultUserTaskInstance) { - defaultUserTaskInstance.setActuaOwner(null); + defaultUserTaskInstance.setActualOwner(null); } return Optional.empty(); } diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index 7320c0f5827..5ca4779f844 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -1744,6 +1744,13 @@ ${project.version} sources + + org.jbpm + jbpm-addons-usertask-storage-jpa + ${project.version} + test-jar + test + org.jbpm jbpm-addons-quarkus-usertask-storage-jpa @@ -1933,17 +1940,6 @@ jbpm-usertask ${project.version} - - org.kie.kogito - jbpm-usertask-storage-jpa - ${project.version} - - - org.kie.kogito - jbpm-usertask-storage-jpa - ${project.version} - sources - org.kie.kogito jbpm-usertask-workitem diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml index 492e403c10d..e7808950852 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/pom.xml @@ -91,11 +91,6 @@ mockito-core test - - io.rest-assured - rest-assured - test - io.quarkus quarkus-junit5-mockito @@ -106,6 +101,12 @@ kogito-quarkus-test-utils test + + org.jbpm + jbpm-addons-usertask-storage-jpa + test-jar + test + diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java index e31e5220324..7a8e8018fc5 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java @@ -25,24 +25,18 @@ import java.util.function.Function; import org.assertj.core.api.Assertions; -import org.jbpm.usertask.jpa.model.AttachmentEntity; -import org.jbpm.usertask.jpa.model.CommentEntity; -import org.jbpm.usertask.jpa.model.TaskMetadataEntity; +import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.model.data.AbstractTaskDataEntity; -import org.jbpm.usertask.jpa.models.Person; import org.jbpm.usertask.jpa.repository.AttachmentRepository; import org.jbpm.usertask.jpa.repository.CommentRepository; import org.jbpm.usertask.jpa.repository.QuarkusUserTaskJPAContext; import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.kogito.auth.IdentityProvider; import org.kie.kogito.auth.IdentityProviders; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; -import org.kie.kogito.usertask.lifecycle.UserTaskState; import org.kie.kogito.usertask.model.Attachment; import org.kie.kogito.usertask.model.Comment; import org.mockito.Mockito; @@ -119,6 +113,8 @@ public void testCreateUserTask() { userTaskInstances.remove(instance); + verify(disconnect, times(1)).apply(any()); + Assertions.assertThat(attachmentRepository.findAll()) .isEmpty(); @@ -126,6 +122,64 @@ public void testCreateUserTask() { .isFalse(); } + @Test + public void testCreateExistingTask() { + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + Assertions.assertThatThrownBy(() -> userTaskInstances.create(instance)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Task Already exists."); + + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } + + @Test + public void testEditTaskInputOutputs() { + + UserTaskInstance instance = createUserTaskInstance(); + + userTaskInstances.create(instance); + + Optional entityOptional = userTaskInstanceRepository.findById(instance.getId()); + + Assertions.assertThat(entityOptional) + .isNotNull() + .isPresent(); + + UserTaskInstanceEntity entity = entityOptional.get(); + + Assertions.assertThat(entity.getInputs()) + .hasSize(instance.getInputs().size()); + + Assertions.assertThat(entity.getOutputs()) + .hasSize(instance.getOutputs().size()); + + instance.getInputs().clear(); + instance.setInput("new_input", "this is a new input"); + + instance.getOutputs().clear(); + instance.setOutput("new_output", "this is a new output"); + + userTaskInstances.update(instance); + + entity = userTaskInstanceRepository.findById(instance.getId()).get(); + + Assertions.assertThat(entity.getInputs()) + .hasSize(1); + + Assertions.assertThat(entity.getOutputs()) + .hasSize(1); + + TestUtils.assertUserTaskEntityInputs(entity, instance); + TestUtils.assertUserTaskEntityOutputs(entity, instance); + + } + @Test public void testFindByIdentityByActualOwner() { @@ -298,7 +352,7 @@ public void testAttachments() throws URISyntaxException { entityOptional = userTaskInstanceRepository.findById(instance.getId()); - assertTaskAttachments(entityOptional.get().getAttachments(), instance.getAttachments()); + TestUtils.assertUserTaskEntityAttachments(entityOptional.get().getAttachments(), instance.getAttachments()); Attachment attachment2 = new Attachment("2", "Admin"); attachment2.setName("attachment 2"); @@ -308,7 +362,7 @@ public void testAttachments() throws URISyntaxException { instance.addAttachment(attachment2); entityOptional = userTaskInstanceRepository.findById(instance.getId()); - assertTaskAttachments(entityOptional.get().getAttachments(), instance.getAttachments()); + TestUtils.assertUserTaskEntityAttachments(entityOptional.get().getAttachments(), instance.getAttachments()); instance.removeAttachment(attachment); instance.removeAttachment(attachment2); @@ -330,7 +384,7 @@ public void testAttachments() throws URISyntaxException { } @Test - public void testComments() throws URISyntaxException { + public void testComments() { UserTaskInstance instance = createUserTaskInstance(); userTaskInstances.create(instance); @@ -356,7 +410,7 @@ public void testComments() throws URISyntaxException { Assertions.assertThat(userTaskInstanceEntity.getComments()) .hasSize(1); - assertTaskComments(entityOptional.get().getComments(), instance.getComments()); + TestUtils.assertUserTaskEntityComments(entityOptional.get().getComments(), instance.getComments()); Comment comment2 = new Comment("2", "Admin"); comment2.setContent("This the comment 2"); @@ -371,7 +425,7 @@ public void testComments() throws URISyntaxException { Assertions.assertThat(userTaskInstanceEntity.getComments()) .hasSize(2); - assertTaskComments(userTaskInstanceEntity.getComments(), instance.getComments()); + TestUtils.assertUserTaskEntityComments(userTaskInstanceEntity.getComments(), instance.getComments()); instance.removeComment(comment); instance.removeComment(comment2); @@ -391,138 +445,25 @@ public void testComments() throws URISyntaxException { } private void assertEntityAndInstance(UserTaskInstanceEntity entity, UserTaskInstance instance) { - Assertions.assertThat(entity) - .hasFieldOrPropertyWithValue("id", instance.getId()) - .hasFieldOrPropertyWithValue("userTaskId", instance.getUserTaskId()) - .hasFieldOrPropertyWithValue("taskName", instance.getTaskName()) - .hasFieldOrPropertyWithValue("taskDescription", instance.getTaskDescription()) - .hasFieldOrPropertyWithValue("taskPriority", instance.getTaskPriority()) - .hasFieldOrPropertyWithValue("status", instance.getStatus().getName()) - .hasFieldOrPropertyWithValue("terminationType", instance.getStatus().getTerminate().toString()) - .hasFieldOrPropertyWithValue("externalReferenceId", instance.getExternalReferenceId()) - .hasFieldOrPropertyWithValue("actualOwner", instance.getActualOwner()); - - assertTaskUserAssignment(entity.getPotentialUsers(), instance.getPotentialUsers()); - assertTaskUserAssignment(entity.getPotentialGroups(), instance.getPotentialGroups()); - assertTaskUserAssignment(entity.getAdminUsers(), instance.getAdminUsers()); - assertTaskUserAssignment(entity.getAdminGroups(), instance.getAdminGroups()); - assertTaskUserAssignment(entity.getExcludedUsers(), instance.getExcludedUsers()); - - assertTaskDataAssignments(entity.getInputs(), instance.getInputs()); - assertTaskDataAssignments(entity.getOutputs(), instance.getOutputs()); - - assertTaskAttachments(entity.getAttachments(), instance.getAttachments()); - assertTaskComments(entity.getComments(), instance.getComments()); - assertTaskMetaData(entity.getMetadata(), instance.getMetadata()); - } + TestUtils.assertUserTaskEntityData(entity, instance); - private void assertTaskUserAssignment(Collection entityAssignments, Set instanceAssignments) { - Assertions.assertThat(entityAssignments) - .hasSize(instanceAssignments.size()) - .containsExactlyInAnyOrder(instanceAssignments.toArray(new String[0])); - } + TestUtils.assertUserTaskEntityPotentialUserAndGroups(entity, instance); + TestUtils.assertUserTaskEntityAdminUserAndGroups(entity, instance); + TestUtils.assertUserTaskEntityExcludedUsers(entity, instance); - private void assertTaskDataAssignments(Collection entityData, Map instanceData) { - Assertions.assertThat(entityData) - .hasSize(instanceData.size()) - .allMatch(data -> instanceData.containsKey(data.getName())) - .allMatch(data -> Objects.nonNull(data.getValue())); - } + TestUtils.assertUserTaskEntityInputs(entity, instance); + TestUtils.assertUserTaskEntityOutputs(entity, instance); - private void assertTaskMetaData(Collection metadata, Map instanceMetadata) { - Assertions.assertThat(metadata) - .hasSize(instanceMetadata.size()) - .allMatch(data -> instanceMetadata.containsKey(data.getName())) - .allMatch(data -> Objects.nonNull(data.getValue())) - .allMatch(data -> data.getJavaType().equals(instanceMetadata.get(data.getName()).getClass().getName())); - } - - private void assertTaskAttachments(Collection entityAttachments, Collection instanceAttachments) { - Assertions.assertThat(entityAttachments) - .hasSize(instanceAttachments.size()); - - entityAttachments.forEach(entityAttachment -> { - Optional optional = instanceAttachments.stream() - .filter(instanceAttachment -> instanceAttachment.getId().equals(entityAttachment.getId())) - .findFirst(); - - Assertions.assertThat(optional) - .isPresent(); - - Attachment instanceAttachment = optional.get(); - - Assertions.assertThat(entityAttachment) - .hasFieldOrPropertyWithValue("id", instanceAttachment.getId()) - .hasFieldOrPropertyWithValue("name", instanceAttachment.getName()) - .hasFieldOrPropertyWithValue("updatedBy", instanceAttachment.getUpdatedBy()) - .matches(entity -> entity.getUpdatedAt().getTime() == instanceAttachment.getUpdatedAt().getTime()) - .hasFieldOrPropertyWithValue("url", instanceAttachment.getContent().toString()); - }); - } - - private void assertTaskComments(Collection entityComments, Collection instanceComments) { - Assertions.assertThat(entityComments) - .hasSize(instanceComments.size()); - - entityComments.forEach(entityComment -> { - Optional optional = instanceComments.stream() - .filter(comment -> comment.getId().equals(entityComment.getId())) - .findFirst(); - - Assertions.assertThat(optional) - .isPresent(); - - Comment instanceComment = optional.get(); - - Assertions.assertThat(instanceComment) - .hasFieldOrPropertyWithValue("id", instanceComment.getId()) - .hasFieldOrPropertyWithValue("updatedBy", instanceComment.getUpdatedBy()) - .hasFieldOrPropertyWithValue("updatedAt", instanceComment.getUpdatedAt()) - .hasFieldOrPropertyWithValue("content", instanceComment.getContent()); - }); + TestUtils.assertUserTaskEntityAttachments(entity.getAttachments(), instance.getAttachments()); + TestUtils.assertUserTaskEntityComments(entity.getComments(), instance.getComments()); + TestUtils.assertUserTaskEntityMetadata(entity, instance); } private UserTaskInstance createUserTaskInstance() { - DefaultUserTaskInstance instance = new DefaultUserTaskInstance(); - instance.setId(UUID.randomUUID().toString()); - instance.setUserTaskId("user-task-id"); - instance.setTaskName("test-task"); - instance.setTaskDescription("this is a test task description"); - instance.setTaskPriority(1); - instance.setStatus(UserTaskState.of("Complete", UserTaskState.TerminationType.COMPLETED)); - - instance.setActuaOwner("Homer"); - instance.setPotentialUsers(Set.of("Bart")); - instance.setPotentialGroups(Set.of("Simpson", "Family")); - instance.setAdminUsers(Set.of("Seymour")); - instance.setAdminGroups(Set.of("Administrators", "Managers")); - instance.setExcludedUsers(Set.of("Ned")); - - instance.setExternalReferenceId("external-reference-id"); - - instance.setMetadata("ProcessId", "process-id"); - instance.setMetadata("ProcessType", "BPMN"); - instance.setMetadata("ProcessVersion", "1.0.0"); - instance.setMetadata("boolean", true); - instance.setMetadata("integer", 0); - - instance.setInput("string", "hello this is a string"); - instance.setInput("integer", 1); - instance.setInput("long", 1000L); - instance.setInput("float", 1.02f); - instance.setInput("boolean", true); - instance.setInput("date", new Date()); - instance.setInput("person", new Person("Ned", "Stark", 50)); - - instance.setOutput("person", new Person("Jon", "Snow", 17)); + DefaultUserTaskInstance instance = TestUtils.createUserTaskInstance(); instance.setInstances(userTaskInstances); return instance; } - - @AfterAll - public static void tearDown() { - System.out.println("down"); - } } From 6753c91d3149781785e9293dca76118f96f2d9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Mon, 21 Oct 2024 19:12:20 +0200 Subject: [PATCH 3/9] - springboot and it tests --- .../usertask/jpa/JPAUserTaskInstances.java | 2 +- .../jpa/mapper/AttachmentsEntityMapper.java | 7 +- .../jpa/mapper/CommentsEntityMapper.java | 7 +- .../jpa/mapper/TaskInputsEntityMapper.java | 2 +- .../jpa/mapper/TaskMetadataEntityMapper.java | 2 +- .../jpa/mapper/TaskOutputsEntityMapper.java | 2 +- .../usertask/jpa/model/TaskDataEntity.java | 24 +- .../usertask/jpa/model/TaskDataEntityPK.java | 76 +++++ .../usertask/jpa/model/TaskInputEntity.java | 35 +- .../jpa/model/TaskMetadataEntity.java | 15 +- .../usertask/jpa/model/TaskOutputEntity.java | 36 +-- .../repository/AttachmentRepository.java | 4 +- .../repository/BaseRepository.java | 6 +- .../repository/CommentRepository.java | 4 +- .../repository/TaskInputRepository.java | 5 +- .../repository/TaskMetadataRepository.java | 5 +- .../repository/TaskOutputRepository.java | 5 +- .../UserTaskInstanceRepository.java | 4 +- .../repository/UserTaskJPAContext.java | 2 +- .../jpa/JPAUserTaskInstancesTest.java | 12 +- .../mapper/AttachmentsEntityMapperTest.java | 2 +- .../jpa/mapper/CommentsEntityMapperTest.java | 2 +- .../mapper/TaskInputsEntityMapperTest.java | 2 +- .../mapper/TaskMetadataEntityMapperTest.java | 2 +- .../mapper/TaskOutputsEntityMapperTest.java | 2 +- .../UserTaskKogitoWorkItemHandler.java | 6 + ...kKogitoWorkItemHandlerProcessListener.java | 1 + .../impl/DefaultUserTaskInstance.java | 11 +- .../DefaultUserTaskTransitionToken.java | 3 +- kogito-bom/pom.xml | 35 +- ...MUserTaskStorageJPAExtensionProcessor.java | 2 +- .../jbpm/userTask/jpa/it/BaseUserTaskIT.java | 63 ++++ .../jpa/it/UserTaskAttachmentsIT.java | 208 ++++++++++++ .../userTask/jpa/it/UserTaskCommentsIT.java | 200 ++++++++++++ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 200 ++++++++++++ .../src/test/resources/application.properties | 2 + .../addons/jbpm-usertask-storage-jpa/pom.xml | 1 - .../QuarkusJPAUserTaskInstances.java | 5 +- .../QuarkusAttachmentsEntityMapper.java | 5 +- .../mapper/QuarkusCommentsEntityMapper.java | 5 +- .../mapper/QuarkusTaskInputsEntityMapper.java | 5 +- .../QuarkusTaskMetadataEntityMapper.java | 5 +- .../QuarkusTaskOutputsEntityMapper.java | 5 +- .../QuarkusUserTaskInstanceEntityMapper.java | 4 +- .../QuarkusAttachmentRepository.java | 2 +- .../repository/QuarkusCommentRepository.java | 2 +- .../QuarkusTaskInputEntityRepository.java | 2 +- .../QuarkusTaskMetadataEntityRepository.java | 2 +- .../QuarkusTaskOutputEntityRepository.java | 2 +- .../QuarkusUserTaskInstanceRepository.java | 2 +- .../repository/QuarkusUserTaskJPAContext.java | 2 +- .../BaseQuarkusJPAUserTaskInstancesTest.java | 13 +- .../H2QuarkusJPAUserTaskInstancesTest.java | 2 +- .../{ => quarkus}/H2QuarkusTestProfile.java | 2 +- ...greSQLQuarkusJPAUserTaskInstancesTest.java | 2 +- .../PostgreSQLQuarkusTestProfile.java | 2 +- .../pom.xml | 146 +++++++++ .../main/java/org/acme/travels/Address.java | 76 +++++ .../main/java/org/acme/travels/Traveller.java | 88 +++++ .../src/main/resources/application.properties | 24 ++ .../src/main/resources/approval.bpmn | 304 ++++++++++++++++++ .../jbpm/userTask/jpa/it/BaseUserTaskIT.java} | 46 +-- .../jpa/it/UserTaskAttachmentsIT.java | 207 ++++++++++++ .../userTask/jpa/it/UserTaskCommentsIT.java | 199 ++++++++++++ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 199 ++++++++++++ quarkus/integration-tests/pom.xml | 1 + .../addons/jbpm-usertask-storage-jpa/pom.xml | 35 ++ .../SpringBootJPAUserTaskInstances.java | 37 +++ .../SpringBootAttachmentsEntityMapper.java | 34 ++ .../SpringBootCommentsEntityMapper.java | 34 ++ .../SpringBootTaskInputsEntityMapper.java | 34 ++ .../SpringBootTaskMetadataEntityMapper.java | 34 ++ .../SpringBootTaskOutputsEntityMapper.java | 34 ++ ...pringBootUserTaskInstanceEntityMapper.java | 34 ++ .../SpringBootAttachmentRepository.java | 36 +++ .../SpringBootCommentRepository.java | 36 +++ .../SpringBootTaskInputEntityRepository.java | 35 ++ ...pringBootTaskMetadataEntityRepository.java | 35 ++ .../SpringBootTaskOutputEntityRepository.java | 35 ++ .../SpringBootUserTaskInstanceRepository.java | 36 +++ .../SpringBootUserTaskJPAContext.java | 40 +++ .../src/main/resources/META-INF/beans.xml | 0 springboot/addons/pom.xml | 1 + .../pom.xml | 153 +++++++++ .../main/java/org/acme/travels/Address.java | 76 +++++ .../main/java/org/acme/travels/Traveller.java | 88 +++++ .../it/KogitoSpringbootApplication.java | 30 ++ .../src/main/resources/application.properties | 23 ++ .../src/main/resources/approval.bpmn | 304 ++++++++++++++++++ .../jbpm/userTask/jpa/it/BaseUserTaskIT.java | 90 ++++++ .../jpa/it/UserTaskAttachmentsIT.java | 215 +++++++++++++ .../userTask/jpa/it/UserTaskCommentsIT.java | 207 ++++++++++++ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 195 +++++++++++ springboot/integration-tests/pom.xml | 1 + 94 files changed, 4066 insertions(+), 202 deletions(-) create mode 100644 addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntityPK.java rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/AttachmentRepository.java (94%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/BaseRepository.java (92%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/CommentRepository.java (94%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/TaskInputRepository.java (89%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/TaskMetadataRepository.java (89%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/TaskOutputRepository.java (89%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/UserTaskInstanceRepository.java (95%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/UserTaskJPAContext.java (94%) rename quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/{ => quarkus}/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java (96%) create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java create mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/QuarkusJPAUserTaskInstances.java (89%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/mapper/QuarkusAttachmentsEntityMapper.java (87%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/mapper/QuarkusCommentsEntityMapper.java (87%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/mapper/QuarkusTaskInputsEntityMapper.java (87%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/mapper/QuarkusTaskMetadataEntityMapper.java (86%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/mapper/QuarkusTaskOutputsEntityMapper.java (87%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/mapper/QuarkusUserTaskInstanceEntityMapper.java (94%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusAttachmentRepository.java (96%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusCommentRepository.java (96%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusTaskInputEntityRepository.java (95%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusTaskMetadataEntityRepository.java (95%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusTaskOutputEntityRepository.java (95%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusUserTaskInstanceRepository.java (96%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/{ => quarkus}/repository/QuarkusUserTaskJPAContext.java (96%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/{ => quarkus}/BaseQuarkusJPAUserTaskInstancesTest.java (98%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/{ => quarkus}/H2QuarkusJPAUserTaskInstancesTest.java (97%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/{ => quarkus}/H2QuarkusTestProfile.java (96%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/{ => quarkus}/PostgreSQLQuarkusJPAUserTaskInstancesTest.java (97%) rename quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/{ => quarkus}/PostgreSQLQuarkusTestProfile.java (96%) create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Address.java create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Traveller.java create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/application.properties create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/approval.bpmn rename quarkus/{addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java => integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java} (57%) create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/pom.xml create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootUserTaskInstanceEntityMapper.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java create mode 100644 springboot/addons/jbpm-usertask-storage-jpa/src/main/resources/META-INF/beans.xml create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/pom.xml create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/acme/travels/Address.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/acme/travels/Traveller.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/application.properties create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/approval.bpmn create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java index d2f6a5e4cbf..8be05f6f598 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java @@ -24,7 +24,7 @@ import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; import org.kie.kogito.auth.IdentityProvider; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.UserTaskInstances; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java index b22735db2eb..f4a896c68cd 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java @@ -20,16 +20,19 @@ package org.jbpm.usertask.jpa.mapper; import java.net.URI; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.jbpm.usertask.jpa.model.AttachmentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; import org.kie.kogito.usertask.model.Attachment; +import static java.util.stream.Collectors.toCollection; + public class AttachmentsEntityMapper { private final AttachmentRepository repository; @@ -71,7 +74,7 @@ public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, U attachment.setContent(URI.create(attachmentEntity.getUrl())); attachment.setUpdatedAt(attachmentEntity.getUpdatedAt()); return attachment; - }).toList(); + }).collect(toCollection(ArrayList::new)); ((DefaultUserTaskInstance) userTaskInstance).setAttachments(attachments); } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java index da767fdfadd..7d184480c6c 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java @@ -19,16 +19,19 @@ package org.jbpm.usertask.jpa.mapper; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.jbpm.usertask.jpa.model.CommentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; import org.kie.kogito.usertask.model.Comment; +import static java.util.stream.Collectors.toCollection; + public class CommentsEntityMapper { private final CommentRepository repository; @@ -68,7 +71,7 @@ public void mapEntityToInstance(UserTaskInstanceEntity userTaskInstanceEntity, U comment.setContent(commentEntity.getComment()); comment.setUpdatedAt(commentEntity.getUpdatedAt()); return comment; - }).toList(); + }).collect(toCollection(ArrayList::new)); ((DefaultUserTaskInstance) userTaskInstance).setComments(comments); } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java index 12a6c50f986..32e2c2cc535 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java @@ -28,7 +28,7 @@ import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; import org.jbpm.usertask.jpa.model.TaskInputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java index 999c7357496..be7bc43b5c7 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java @@ -27,7 +27,7 @@ import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; import org.jbpm.usertask.jpa.model.TaskMetadataEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java index 1fa7d4ae282..a2167789719 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java @@ -28,7 +28,7 @@ import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; import org.jbpm.usertask.jpa.model.TaskOutputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java index 163e45af01f..506f3bf925b 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntity.java @@ -27,8 +27,15 @@ public abstract class TaskDataEntity { @Id + @Column(name = "name") protected String name; + @Id + @ManyToOne(optional = false) + @JoinColumn(name = "task_id") + protected UserTaskInstanceEntity taskInstance; + + @Column(name = "value") protected T value; @Column(name = "java_type") @@ -42,6 +49,14 @@ public void setName(String name) { this.name = name; } + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } + public T getValue() { return value; } @@ -58,10 +73,6 @@ public void setJavaType(String javaType) { this.javaType = javaType; } - public abstract UserTaskInstanceEntity getTaskInstance(); - - public abstract void setTaskInstance(UserTaskInstanceEntity taskInstance); - @Override public boolean equals(Object o) { if (this == o) @@ -69,11 +80,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; TaskDataEntity that = (TaskDataEntity) o; - return Objects.equals(getName(), that.getName()) && Objects.equals(getValue(), that.getValue()) && Objects.equals(getJavaType(), that.getJavaType()); + return Objects.equals(getName(), that.getName()) && Objects.equals(getTaskInstance(), that.getTaskInstance()) && Objects.equals(getValue(), + that.getValue()) && Objects.equals(getJavaType(), that.getJavaType()); } @Override public int hashCode() { - return Objects.hash(getName(), getValue(), getJavaType()); + return Objects.hash(getName(), getTaskInstance(), getValue(), getJavaType()); } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntityPK.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntityPK.java new file mode 100644 index 00000000000..4d0f1fab9ed --- /dev/null +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskDataEntityPK.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.jbpm.usertask.jpa.model; + +import java.io.Serializable; +import java.util.Objects; + +public class TaskDataEntityPK implements Serializable { + + private String name; + private UserTaskInstanceEntity taskInstance; + + public TaskDataEntityPK() { + } + + public TaskDataEntityPK(String inputName, UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + this.name = inputName; + } + + public UserTaskInstanceEntity getTaskInstance() { + return taskInstance; + } + + public void setTaskInstance(UserTaskInstanceEntity taskInstance) { + this.taskInstance = taskInstance; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + TaskDataEntityPK that = (TaskDataEntityPK) o; + return Objects.equals(getName(), that.getName()) && Objects.equals(getTaskInstance(), that.getTaskInstance()); + } + + @Override + public int hashCode() { + return Objects.hash(getName(), getTaskInstance()); + } + + @Override + public String toString() { + return "TaskInputEntityId{" + + "taskInstance='" + taskInstance + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java index 3b1b54e92d7..9c4351cfd24 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskInputEntity.java @@ -19,8 +19,6 @@ package org.jbpm.usertask.jpa.model; -import java.util.Objects; - import jakarta.persistence.*; @Entity @@ -29,37 +27,8 @@ @AttributeOverride(name = "name", column = @Column(name = "input_name")), @AttributeOverride(name = "value", column = @Column(name = "input_value")) }) +@AssociationOverride(name = "taskInstance", foreignKey = @ForeignKey(name = "jbpm_user_tasks_inputs_tid")) +@IdClass(TaskDataEntityPK.class) public class TaskInputEntity extends TaskDataEntity { - @Id - @ManyToOne(optional = false) - @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_inputs_tid")) - private UserTaskInstanceEntity taskInstance; - - @Override - public UserTaskInstanceEntity getTaskInstance() { - return taskInstance; - } - - @Override - public void setTaskInstance(UserTaskInstanceEntity taskInstance) { - this.taskInstance = taskInstance; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - TaskInputEntity that = (TaskInputEntity) o; - return Objects.equals(getTaskInstance(), that.getTaskInstance()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getTaskInstance()); - } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java index 8d8a714997a..2729ee68716 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskMetadataEntity.java @@ -27,18 +27,9 @@ @AttributeOverride(name = "name", column = @Column(name = "metadata_name")), @AttributeOverride(name = "value", column = @Column(name = "metadata_value")) }) +@AssociationOverride(name = "taskInstance", + joinColumns = @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_metadata_tid"))) +@IdClass(TaskDataEntityPK.class) public class TaskMetadataEntity extends TaskDataEntity { - @ManyToOne(optional = false) - @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_metadata_tid")) - private UserTaskInstanceEntity taskInstance; - - public UserTaskInstanceEntity getTaskInstance() { - return taskInstance; - } - - public void setTaskInstance(UserTaskInstanceEntity taskInstance) { - this.taskInstance = taskInstance; - } - } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java index 6a67ea047f4..bd7098f2450 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/TaskOutputEntity.java @@ -19,8 +19,6 @@ package org.jbpm.usertask.jpa.model; -import java.util.Objects; - import jakarta.persistence.*; @Entity @@ -29,37 +27,9 @@ @AttributeOverride(name = "name", column = @Column(name = "output_name")), @AttributeOverride(name = "value", column = @Column(name = "output_value")) }) +@AssociationOverride(name = "taskInstance", + joinColumns = @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_outputs_tid"))) +@IdClass(TaskDataEntityPK.class) public class TaskOutputEntity extends TaskDataEntity { - @Id - @ManyToOne(optional = false) - @JoinColumn(name = "task_id", foreignKey = @ForeignKey(name = "jbpm_user_tasks_outputs_tid")) - private UserTaskInstanceEntity taskInstance; - - @Override - public UserTaskInstanceEntity getTaskInstance() { - return taskInstance; - } - - @Override - public void setTaskInstance(UserTaskInstanceEntity taskInstance) { - this.taskInstance = taskInstance; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - TaskOutputEntity that = (TaskOutputEntity) o; - return Objects.equals(getTaskInstance(), that.getTaskInstance()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getTaskInstance()); - } } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/AttachmentRepository.java similarity index 94% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/AttachmentRepository.java index 51fd669321e..d0b1ff5a827 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/AttachmentRepository.java @@ -17,11 +17,11 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import org.jbpm.usertask.jpa.model.AttachmentEntity; -public class AttachmentRepository extends BaseRepository { +public class AttachmentRepository extends BaseRepository { public AttachmentRepository(UserTaskJPAContext context) { super(context); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/BaseRepository.java similarity index 92% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/BaseRepository.java index d2672e7efef..08a405fb866 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/BaseRepository.java @@ -17,14 +17,14 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import java.util.List; import java.util.Optional; import jakarta.persistence.EntityManager; -public abstract class BaseRepository { +public abstract class BaseRepository { protected UserTaskJPAContext context; @@ -32,7 +32,7 @@ public BaseRepository(UserTaskJPAContext context) { this.context = context; } - public Optional findById(String id) { + public Optional findById(K id) { return Optional.ofNullable(getEntityManager().find(getEntityClass(), id)); } diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/CommentRepository.java similarity index 94% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/CommentRepository.java index a13d66e3ff0..a77cc4657d2 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/CommentRepository.java @@ -17,11 +17,11 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import org.jbpm.usertask.jpa.model.CommentEntity; -public class CommentRepository extends BaseRepository { +public class CommentRepository extends BaseRepository { public CommentRepository(UserTaskJPAContext context) { super(context); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskInputRepository.java similarity index 89% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskInputRepository.java index 9b7fdcc3c7b..94563bfa704 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskInputRepository.java @@ -17,11 +17,12 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.model.TaskDataEntityPK; import org.jbpm.usertask.jpa.model.TaskInputEntity; -public class TaskInputRepository extends BaseRepository { +public class TaskInputRepository extends BaseRepository { public TaskInputRepository(UserTaskJPAContext context) { super(context); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskMetadataRepository.java similarity index 89% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskMetadataRepository.java index 29dd469c85f..64269ee373a 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskMetadataRepository.java @@ -17,11 +17,12 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.model.TaskDataEntityPK; import org.jbpm.usertask.jpa.model.TaskMetadataEntity; -public class TaskMetadataRepository extends BaseRepository { +public class TaskMetadataRepository extends BaseRepository { public TaskMetadataRepository(UserTaskJPAContext context) { super(context); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskOutputRepository.java similarity index 89% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskOutputRepository.java index 0346f88fca2..98034328287 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskOutputRepository.java @@ -17,11 +17,12 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.model.TaskDataEntityPK; import org.jbpm.usertask.jpa.model.TaskOutputEntity; -public class TaskOutputRepository extends BaseRepository { +public class TaskOutputRepository extends BaseRepository { public TaskOutputRepository(UserTaskJPAContext context) { super(context); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskInstanceRepository.java similarity index 95% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskInstanceRepository.java index 89c91df765e..bd4c7107cf9 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskInstanceRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import java.util.List; @@ -28,7 +28,7 @@ import static org.jbpm.usertask.jpa.model.UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY; -public class UserTaskInstanceRepository extends BaseRepository { +public class UserTaskInstanceRepository extends BaseRepository { public UserTaskInstanceRepository(UserTaskJPAContext context) { super(context); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskJPAContext.java similarity index 94% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskJPAContext.java index 8606184dd58..18b4377d58f 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskJPAContext.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.persistence.EntityManager; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java index 4054ca12eb2..d5e5e13c38b 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java @@ -19,11 +19,15 @@ package org.jbpm.usertask.jpa; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + import org.assertj.core.api.Assertions; import org.jbpm.usertask.jpa.mapper.*; import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -32,10 +36,6 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; - import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -127,7 +127,7 @@ public void testSuccessfulFindByIdentity() { List instances = jpaUserTaskInstances.findByIdentity(IdentityProviders.of("user", "group")); Assertions.assertThat(instances) - .hasSize(2); + .hasSize(2); verify(userTaskInstanceEntityMapper, times(2)).mapTaskEntityToInstance(any()); verify(reconnectUserTaskInstance, times(2)).apply(any()); diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java index cafdb8e166b..9ce69ebb25e 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java @@ -26,7 +26,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.AttachmentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java index 62477c2d7ab..7ae5c2e9267 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.CommentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java index 1aaeed39d30..2b1a610f392 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.TaskInputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java index 1e6d18de1fd..2bdb1b61554 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java @@ -23,7 +23,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.TaskMetadataEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java index 52da167c9d1..dd716d79bf5 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.TaskOutputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java index a1b678e6a4c..42b7ff49e7a 100644 --- a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java +++ b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java @@ -118,6 +118,9 @@ public Optional activateWorkItemHandler(KogitoWorkItemManage @Override public Optional completeWorkItemHandler(KogitoWorkItemManager manager, KogitoWorkItemHandler handler, KogitoWorkItem workItem, WorkItemTransition transition) { + if (transition.data().containsKey("Notify")) { + return Optional.empty(); + } UserTasks userTasks = handler.getApplication().get(UserTasks.class); UserTask userTask = userTasks.userTaskById((String) workItem.getParameter(KogitoWorkItem.PARAMETER_UNIQUE_TASK_ID)); userTask.instances().findById(workItem.getExternalReferenceId()).ifPresent(ut -> { @@ -131,6 +134,9 @@ public Optional completeWorkItemHandler(KogitoWorkItemManage @Override public Optional abortWorkItemHandler(KogitoWorkItemManager manager, KogitoWorkItemHandler handler, KogitoWorkItem workItem, WorkItemTransition transition) { + if (transition.data().containsKey("Notify")) { + return Optional.empty(); + } UserTasks userTasks = handler.getApplication().get(UserTasks.class); UserTask userTask = userTasks.userTaskById((String) workItem.getParameter(KogitoWorkItem.PARAMETER_UNIQUE_TASK_ID)); userTask.instances().findById(workItem.getExternalReferenceId()).ifPresent(ut -> { diff --git a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java index 7d0bc70557a..116eb8716fd 100644 --- a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java +++ b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandlerProcessListener.java @@ -59,6 +59,7 @@ public void onUserTaskState(UserTaskStateEvent event) { processes.processById(processId).instances().findById(processInstanceId).ifPresent(pi -> { Map data = new HashMap<>(event.getUserTaskInstance().getOutputs()); data.put("ActorId", event.getUserTaskInstance().getActualOwner()); + data.put("Notify", false); pi.completeWorkItem(event.getUserTaskInstance().getExternalReferenceId(), data); }); diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java index 5aeba621c1d..c0efe0b069d 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java @@ -66,7 +66,7 @@ public class DefaultUserTaskInstance implements UserTaskInstance { @JsonIgnore private KogitoUserTaskEventSupport userTaskEventSupport; @JsonIgnore - private UserTaskLifeCycle setUserTaskLifeCycle; + private UserTaskLifeCycle userTaskLifeCycle; public DefaultUserTaskInstance() { this.inputs = new HashMap<>(); @@ -93,7 +93,7 @@ public void setUserTaskEventSupport(KogitoUserTaskEventSupport userTaskEventSupp } public void setUserTaskLifeCycle(UserTaskLifeCycle userTaskLifeCycle) { - this.setUserTaskLifeCycle = userTaskLifeCycle; + this.userTaskLifeCycle = userTaskLifeCycle; } public void setInstances(UserTaskInstances instances) { @@ -157,15 +157,14 @@ public void setExternalReferenceId(String externalReferenceId) { @Override public void transition(String transitionId, Map data, IdentityProvider identity) { - Optional next = Optional.of(this.setUserTaskLifeCycle.newTransitionToken(transitionId, this, data)); + Optional next = Optional.of(this.userTaskLifeCycle.newTransitionToken(transitionId, this, data)); while (next.isPresent()) { UserTaskTransitionToken transition = next.get(); - next = this.setUserTaskLifeCycle.transition(this, transition, identity); + next = this.userTaskLifeCycle.transition(this, transition, identity); this.status = transition.target(); - this.updatePersistenceOrRemove(); this.userTaskEventSupport.fireOneUserTaskStateChange(this, transition.source(), transition.target()); } - + this.updatePersistenceOrRemove(); } private void updatePersistence() { diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskTransitionToken.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskTransitionToken.java index f8cfd7733fc..56561c9ca51 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskTransitionToken.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskTransitionToken.java @@ -19,6 +19,7 @@ package org.kie.kogito.usertask.impl.lifecycle; import java.util.Map; +import java.util.Objects; import org.kie.kogito.usertask.lifecycle.UserTaskState; import org.kie.kogito.usertask.lifecycle.UserTaskTransitionToken; @@ -34,7 +35,7 @@ public DefaultUserTaskTransitionToken(String transition, UserTaskState source, U this.transition = transition; this.source = source; this.target = target; - this.data = data; + this.data = Objects.isNull(data) ? Map.of() : data; } @Override diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index 5ca4779f844..13acf8c5126 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -781,18 +781,6 @@ sources - - org.kie - kie-addons-springboot-flyway - ${project.version} - - - org.kie - kie-addons-springboot-flyway - ${project.version} - sources - - org.kie.kogito @@ -1773,6 +1761,17 @@ ${project.version} sources + + org.jbpm + jbpm-addons-springboot-usertask-storage-jpa + ${project.version} + + + org.jbpm + jbpm-addons-springboot-usertask-storage-jpa + ${project.version} + sources + @@ -1808,7 +1807,17 @@ ${project.version} sources - + + org.kie + kie-addons-springboot-flyway + ${project.version} + + + org.kie + kie-addons-springboot-flyway + ${project.version} + sources + diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java b/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/quarkus/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java rename to quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/quarkus/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java index d0fa34a4ad5..6d7087a4716 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/deployment/src/main/java/org/jbpm/usertask/storage/jpa/quarkus/deployment/JBPMUserTaskStorageJPAExtensionProcessor.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.storage.jpa.deployment; +package org.jbpm.usertask.storage.jpa.quarkus.deployment; import org.kie.kogito.quarkus.addons.common.deployment.KogitoCapability; import org.kie.kogito.quarkus.addons.common.deployment.RequireCapabilityKogitoAddOnProcessor; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java new file mode 100644 index 00000000000..dc87d96b5d9 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java @@ -0,0 +1,63 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import io.restassured.http.ContentType; +import org.acme.travels.Traveller; + +import java.util.Map; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.emptyOrNullString; + +public abstract class BaseUserTaskIT { + public static final String PROCESS_ID = "approvals"; + public static final String USER_TASKS_ENDPOINT = "/usertasks/instance"; + public static final String USER_TASKS_INSTANCE_ENDPOINT = USER_TASKS_ENDPOINT + "/{taskId}"; + + public String startProcessInstance(Traveller traveller) { + final String pid = given().contentType(ContentType.JSON) + .when() + .body(Map.of("traveller", traveller)) + .post("/{processId}", PROCESS_ID) + .then() + .statusCode(201) + .header("Location", not(emptyOrNullString())) + .body("id", not(emptyOrNullString())) + .extract() + .path("id"); + + given() + .accept(ContentType.JSON) + .when() + .get("/{processId}/{id}", PROCESS_ID, pid) + .then() + .statusCode(200) + .body("id", equalTo(pid)) + .body("traveller.firstName", equalTo(traveller.getFirstName())) + .body("traveller.lastName", equalTo(traveller.getLastName())) + .body("traveller.email", equalTo(traveller.getEmail())) + .body("traveller.nationality", equalTo(traveller.getNationality())); + + return pid; + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java new file mode 100644 index 00000000000..871060aa31c --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java @@ -0,0 +1,208 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.net.URI; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import org.kie.kogito.usertask.model.AttachmentInfo; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.filter.log.RequestLoggingFilter; +import io.restassured.filter.log.ResponseLoggingFilter; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.emptyOrNullString; + +@QuarkusIntegrationTest +@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) +public class UserTaskAttachmentsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/attachments"; + public static final String USER_TASKS_INSTANCE_ATTACHMENT = USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT + "/{attachmentId}"; + + static { + RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); + } + + @Test + public void testUserTaskAttachments() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + AttachmentInfo attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_1.txt"), "Attachment 1"); + + String attachment1Id = addAndVerifyAttachment(taskId, attachment1); + + AttachmentInfo attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_2.txt"), "Attachment 2"); + + String attachment2Id = addAndVerifyAttachment(taskId, attachment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)); + + + attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_1.txt"), "NEW Attachment 1"); + + updateAndVerifyAttachment(taskId, attachment1Id, attachment1); + + attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_2.txt"), "NEW Attachment 2"); + + updateAndVerifyAttachment(taskId, attachment2Id, attachment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", not(emptyOrNullString())) + .body("[0].content", equalTo(attachment1.getUri().toString())) + .body("[0].name", equalTo(attachment1.getName())) + .body("[0].updatedBy", not(emptyOrNullString())) + .body("[0].updatedAt", not(emptyOrNullString())) + .body("[1].id", not(emptyOrNullString())) + .body("[1].content", equalTo(attachment2.getUri().toString())) + .body("[1].name", equalTo(attachment2.getName())) + .body("[1].updatedBy", not(emptyOrNullString())) + .body("[1].updatedAt", not(emptyOrNullString())); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment1Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(1)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment2Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + } + + private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) { + String id = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(attachment) + .post(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, id) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + + return id; + } + + private void updateAndVerifyAttachment(String taskId, String attachmentId, AttachmentInfo attachment) { + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(attachment) + .put(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java new file mode 100644 index 00000000000..57de1f1d4fc --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java @@ -0,0 +1,200 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.filter.log.RequestLoggingFilter; +import io.restassured.filter.log.ResponseLoggingFilter; +import io.restassured.http.ContentType; +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import org.kie.kogito.usertask.model.CommentInfo; + + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.emptyOrNullString; + +@QuarkusIntegrationTest +@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) +public class UserTaskCommentsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_COMMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/comments"; + public static final String USER_TASKS_INSTANCE_COMMENT = USER_TASKS_INSTANCE_COMMENTS_ENDPOINT + "/{commentId}"; + + static { + RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); + } + + @Test + public void testUserTaskComments() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + CommentInfo comment1 = new CommentInfo("This is my second comment."); + + String comment1Id = addAndVerifyComment(taskId, comment1); + + CommentInfo comment2 = new CommentInfo("This is my second comment."); + + String comment2Id = addAndVerifyComment(taskId, comment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)); + + + comment1 = new CommentInfo("This is the first comment modified"); + + updateAndVerifyComment(taskId, comment1Id, comment1); + + comment2 = new CommentInfo("This is the second comment modified"); + + updateAndVerifyComment(taskId, comment2Id, comment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", not(emptyOrNullString())) + .body("[0].content", equalTo(comment1.getComment())) + .body("[0].updatedBy", not(emptyOrNullString())) + .body("[0].updatedAt", not(emptyOrNullString())) + .body("[1].id", not(emptyOrNullString())) + .body("[1].content", equalTo(comment2.getComment())) + .body("[1].updatedBy", not(emptyOrNullString())) + .body("[1].updatedAt", not(emptyOrNullString())); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment1Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(1)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment2Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + } + + private String addAndVerifyComment(String taskId, CommentInfo comment) { + String id = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(comment) + .post(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENT, taskId, id) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + + return id; + } + + private void updateAndVerifyComment(String taskId, String commentId, CommentInfo comment) { + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(comment) + .put(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java new file mode 100644 index 00000000000..ff142b09480 --- /dev/null +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -0,0 +1,200 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.filter.log.RequestLoggingFilter; +import io.restassured.filter.log.ResponseLoggingFilter; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.CoreMatchers.equalTo; + +@QuarkusIntegrationTest +@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) +public class UserTaskLifeCycleIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_TRANSITION_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/transition"; + + static { + RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); + } + + @Test + public void testUserTaskLifeCycle() { + + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .queryParam("transitionId", "complete") + .body(Map.of("approved", true)) + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Completed")) + .body("status.terminate", equalTo("COMPLETED")) + .body("outputs.approved", equalTo(true)); + + // Manager is excluded for the secondLineApproval Task, he shouldn't be allowed to see the task + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", not(taskId)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Ready")) + .body("taskName", equalTo("secondLineApproval")) + .body("excludedUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + // Manager is excluded for the secondLineApproval Task, he shouldn't be able to work on the task + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("transitionId", "claim") + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(500) + .body("id", equalTo(taskId)); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .queryParam("transitionId", "claim") + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .queryParam("transitionId", "complete") + .body(Map.of("approved", true)) + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Completed")) + .body("status.terminate", equalTo("COMPLETED")) + .body("outputs.approved", equalTo(true)); + + given() + .accept(ContentType.JSON) + .when() + .get("/{processId}/{id}", PROCESS_ID, pid) + .then() + .statusCode(404); + } +} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties index e69de29bb2d..96ec268f59e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties +++ b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties @@ -0,0 +1,2 @@ +#quarkus.test.arg-line=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 +quarkus.http.test-timeout=1h diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml index a6ce8cbcc97..1fc1709a355 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml +++ b/quarkus/addons/jbpm-usertask-storage-jpa/pom.xml @@ -40,7 +40,6 @@ deployment runtime - integration-tests \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java similarity index 89% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java index 55d5d585dfd..85de1b1b68e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/QuarkusJPAUserTaskInstances.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java @@ -17,10 +17,11 @@ * under the License. */ -package org.jbpm.usertask.jpa; +package org.jbpm.usertask.jpa.quarkus; +import org.jbpm.usertask.jpa.JPAUserTaskInstances; import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; -import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java similarity index 87% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java index 54ceedf98b7..367e65f4382 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusAttachmentsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java @@ -17,9 +17,10 @@ * under the License. */ -package org.jbpm.usertask.jpa.mapper; +package org.jbpm.usertask.jpa.quarkus.mapper; -import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.mapper.AttachmentsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java similarity index 87% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java index 445208d9622..7a320540221 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusCommentsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java @@ -17,9 +17,10 @@ * under the License. */ -package org.jbpm.usertask.jpa.mapper; +package org.jbpm.usertask.jpa.quarkus.mapper; -import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.jbpm.usertask.jpa.mapper.CommentsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java similarity index 87% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java index 5437555466b..7a305028487 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskInputsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java @@ -17,9 +17,10 @@ * under the License. */ -package org.jbpm.usertask.jpa.mapper; +package org.jbpm.usertask.jpa.quarkus.mapper; -import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.mapper.TaskInputsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java similarity index 86% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java index 6395fa25631..049ed2e802e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskMetadataEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java @@ -17,9 +17,10 @@ * under the License. */ -package org.jbpm.usertask.jpa.mapper; +package org.jbpm.usertask.jpa.quarkus.mapper; -import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.mapper.TaskMetadataEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java similarity index 87% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java index f3063948b60..77eabd59326 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusTaskOutputsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java @@ -17,9 +17,10 @@ * under the License. */ -package org.jbpm.usertask.jpa.mapper; +package org.jbpm.usertask.jpa.quarkus.mapper; -import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.mapper.TaskOutputsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusUserTaskInstanceEntityMapper.java similarity index 94% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusUserTaskInstanceEntityMapper.java index 7747573f056..e3f6c79e1ad 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/mapper/QuarkusUserTaskInstanceEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusUserTaskInstanceEntityMapper.java @@ -17,7 +17,9 @@ * under the License. */ -package org.jbpm.usertask.jpa.mapper; +package org.jbpm.usertask.jpa.quarkus.mapper; + +import org.jbpm.usertask.jpa.mapper.*; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java index 16273612e96..9687969600e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusAttachmentRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java index a52bca69eac..72b07095bd0 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusCommentRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java similarity index 95% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java index 2c27ac939c5..aaa8e25730d 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskInputEntityRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java similarity index 95% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java index 67946f07a06..51fffaa75a8 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskMetadataEntityRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java similarity index 95% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java index ae76b3d5e12..9d546e3497a 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusTaskOutputEntityRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java index 18e7e51d01e..a59db2df444 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskInstanceRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java index 9831caed3ee..b510fb4b6c3 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/repository/QuarkusUserTaskJPAContext.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.repository; +package org.jbpm.usertask.jpa.quarkus.repository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.persistence.EntityManager; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java similarity index 98% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java index 7a8e8018fc5..a7674ae35e2 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/BaseQuarkusJPAUserTaskInstancesTest.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa; +package org.jbpm.usertask.jpa.quarkus; import java.net.URI; import java.net.URISyntaxException; @@ -25,12 +25,10 @@ import java.util.function.Function; import org.assertj.core.api.Assertions; +import org.jbpm.usertask.jpa.JPAUserTaskInstances; import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.repository.AttachmentRepository; -import org.jbpm.usertask.jpa.repository.CommentRepository; -import org.jbpm.usertask.jpa.repository.QuarkusUserTaskJPAContext; -import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.quarkus.repository.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.kogito.auth.IdentityProvider; @@ -178,6 +176,11 @@ public void testEditTaskInputOutputs() { TestUtils.assertUserTaskEntityInputs(entity, instance); TestUtils.assertUserTaskEntityOutputs(entity, instance); + userTaskInstances.remove(instance); + + Assertions.assertThat(userTaskInstances.exists(instance.getId())) + .isFalse(); + } @Test diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/H2QuarkusJPAUserTaskInstancesTest.java similarity index 97% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/H2QuarkusJPAUserTaskInstancesTest.java index 6fd0b78218e..f314b629be5 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusJPAUserTaskInstancesTest.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/H2QuarkusJPAUserTaskInstancesTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa; +package org.jbpm.usertask.jpa.quarkus; import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/H2QuarkusTestProfile.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/H2QuarkusTestProfile.java index d02a789b903..4a1b05ffec8 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/H2QuarkusTestProfile.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/H2QuarkusTestProfile.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa; +package org.jbpm.usertask.jpa.quarkus; import io.quarkus.test.junit.QuarkusTestProfile; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/PostgreSQLQuarkusJPAUserTaskInstancesTest.java similarity index 97% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/PostgreSQLQuarkusJPAUserTaskInstancesTest.java index eec2099837c..7174ee048c3 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusJPAUserTaskInstancesTest.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/PostgreSQLQuarkusJPAUserTaskInstancesTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa; +package org.jbpm.usertask.jpa.quarkus; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/PostgreSQLQuarkusTestProfile.java similarity index 96% rename from quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java rename to quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/PostgreSQLQuarkusTestProfile.java index 8733f3ad29d..dda90d34319 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/PostgreSQLQuarkusTestProfile.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/PostgreSQLQuarkusTestProfile.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa; +package org.jbpm.usertask.jpa.quarkus; import io.quarkus.test.junit.QuarkusTestProfile; diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml b/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml new file mode 100644 index 00000000000..89b13650a59 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml @@ -0,0 +1,146 @@ + + + + + jbpm-addon-quarkus-usertask-storage-jpa-parent + org.jbpm + 999-SNAPSHOT + + 4.0.0 + integration-tests-quarkus-usertasks + Kogito :: Integration Tests :: Quarkus :: Processes :: Source Files + + + org.jbpm.usertask.storage.jpa.quarkus.it + + + + + + org.kie.kogito + kogito-quarkus-bom + ${project.version} + pom + import + + + + + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + org.jbpm + jbpm-quarkus + + + org.kie + kie-addons-quarkus-persistence-jdbc + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-agroal + + + io.quarkus + quarkus-jdbc-postgresql + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.assertj + assertj-core + test + + + org.kie.kogito + kogito-quarkus-test-utils + test + + + + + org.jbpm + jbpm-quarkus-deployment + ${project.version} + pom + test + + + * + * + + + + + org.jbpm + jbpm-addons-quarkus-usertask-storage-jpa-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + + \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Address.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Address.java new file mode 100644 index 00000000000..662dfa9b9f7 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/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/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Traveller.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Traveller.java new file mode 100644 index 00000000000..c24685803d2 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/java/org/acme/travels/Traveller.java @@ -0,0 +1,88 @@ +/* + * 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, 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/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/application.properties b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/application.properties new file mode 100644 index 00000000000..5458fa57f9c --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/application.properties @@ -0,0 +1,24 @@ +# +# 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. +# + +quarkus.datasource.db-kind=postgresql + +kogito.persistence.type=jdbc + +kie.flyway.enabled=true \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/approval.bpmn b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/approval.bpmn new file mode 100644 index 00000000000..275d148f7ac --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/main/resources/approval.bpmn @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 + _C13522F1-230A-4C26-B5A9-533A5D9FEE9D + + + + + + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + + + + traveller + _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX + approver + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX + firstLineApproval + + + + manager + + + + + + + + + + _C13522F1-230A-4C26-B5A9-533A5D9FEE9D + _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 + + + + + + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + + + + approver + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX + + + traveller + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX + secondLineApproval + + + + + + + + + _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 + + + + + + + + _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _F0jB8En5EeqlfsIhq1UCRQ + _F0jB8En5EeqlfsIhq1UCRQ + + diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java similarity index 57% rename from quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java rename to quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java index 0037fa3bd8a..21ae0338dc2 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/JBPMUserTaskJPAStorageIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java @@ -19,40 +19,23 @@ package org.jbpm.userTask.jpa.it; -import java.time.Duration; import java.util.Map; -import org.acme.travels.Address; import org.acme.travels.Traveller; -import org.junit.jupiter.api.Test; -import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.emptyOrNullString; -@QuarkusIntegrationTest -@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class JBPMUserTaskJPAStorageIT { - public static final Duration TIMEOUT = Duration.ofSeconds(10); +public abstract class BaseUserTaskIT { public static final String PROCESS_ID = "approvals"; - public static final String USERTASKS_ENDPOINT = "/usertasks/instance"; - - static { - RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); - } - - @Test - public void testFullProcess() { - - Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + public static final String USER_TASKS_ENDPOINT = "/usertasks/instance"; + public static final String USER_TASKS_INSTANCE_ENDPOINT = USER_TASKS_ENDPOINT + "/{taskId}"; + public String startProcessInstance(Traveller traveller) { final String pid = given().contentType(ContentType.JSON) .when() .body(Map.of("traveller", traveller)) @@ -64,19 +47,18 @@ public void testFullProcess() { .extract() .path("id"); - System.out.println(pid); - - final String taskId = given().contentType(ContentType.JSON) + given() + .accept(ContentType.JSON) .when() - .queryParam("user", "manager") - .get(USERTASKS_ENDPOINT) + .get("/{processId}/{id}", PROCESS_ID, pid) .then() .statusCode(200) - .body("$.size()", is(1)) - .extract() - .path("[0].id"); - - System.out.println(taskId); + .body("id", equalTo(pid)) + .body("traveller.firstName", equalTo(traveller.getFirstName())) + .body("traveller.lastName", equalTo(traveller.getLastName())) + .body("traveller.email", equalTo(traveller.getEmail())) + .body("traveller.nationality", equalTo(traveller.getNationality())); + return pid; } } diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java new file mode 100644 index 00000000000..7bb7e22080f --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java @@ -0,0 +1,207 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.net.URI; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import org.kie.kogito.usertask.model.AttachmentInfo; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.filter.log.RequestLoggingFilter; +import io.restassured.filter.log.ResponseLoggingFilter; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.emptyOrNullString; + +@QuarkusIntegrationTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +public class UserTaskAttachmentsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/attachments"; + public static final String USER_TASKS_INSTANCE_ATTACHMENT = USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT + "/{attachmentId}"; + + static { + RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); + } + + @Test + public void testUserTaskAttachments() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + AttachmentInfo attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_1.txt"), "Attachment 1"); + + String attachment1Id = addAndVerifyAttachment(taskId, attachment1); + + AttachmentInfo attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_2.txt"), "Attachment 2"); + + String attachment2Id = addAndVerifyAttachment(taskId, attachment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)); + + attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_1.txt"), "NEW Attachment 1"); + + updateAndVerifyAttachment(taskId, attachment1Id, attachment1); + + attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_2.txt"), "NEW Attachment 2"); + + updateAndVerifyAttachment(taskId, attachment2Id, attachment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", not(emptyOrNullString())) + .body("[0].content", equalTo(attachment1.getUri().toString())) + .body("[0].name", equalTo(attachment1.getName())) + .body("[0].updatedBy", not(emptyOrNullString())) + .body("[0].updatedAt", not(emptyOrNullString())) + .body("[1].id", not(emptyOrNullString())) + .body("[1].content", equalTo(attachment2.getUri().toString())) + .body("[1].name", equalTo(attachment2.getName())) + .body("[1].updatedBy", not(emptyOrNullString())) + .body("[1].updatedAt", not(emptyOrNullString())); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment1Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(1)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment2Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + } + + private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) { + String id = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(attachment) + .post(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, id) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + + return id; + } + + private void updateAndVerifyAttachment(String taskId, String attachmentId, AttachmentInfo attachment) { + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(attachment) + .put(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + } +} diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java new file mode 100644 index 00000000000..b9ac6640eb1 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java @@ -0,0 +1,199 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import org.kie.kogito.usertask.model.CommentInfo; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.filter.log.RequestLoggingFilter; +import io.restassured.filter.log.ResponseLoggingFilter; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.emptyOrNullString; + +@QuarkusIntegrationTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +public class UserTaskCommentsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_COMMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/comments"; + public static final String USER_TASKS_INSTANCE_COMMENT = USER_TASKS_INSTANCE_COMMENTS_ENDPOINT + "/{commentId}"; + + static { + RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); + } + + @Test + public void testUserTaskComments() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + CommentInfo comment1 = new CommentInfo("This is my second comment."); + + String comment1Id = addAndVerifyComment(taskId, comment1); + + CommentInfo comment2 = new CommentInfo("This is my second comment."); + + String comment2Id = addAndVerifyComment(taskId, comment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)); + + comment1 = new CommentInfo("This is the first comment modified"); + + updateAndVerifyComment(taskId, comment1Id, comment1); + + comment2 = new CommentInfo("This is the second comment modified"); + + updateAndVerifyComment(taskId, comment2Id, comment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", not(emptyOrNullString())) + .body("[0].content", equalTo(comment1.getComment())) + .body("[0].updatedBy", not(emptyOrNullString())) + .body("[0].updatedAt", not(emptyOrNullString())) + .body("[1].id", not(emptyOrNullString())) + .body("[1].content", equalTo(comment2.getComment())) + .body("[1].updatedBy", not(emptyOrNullString())) + .body("[1].updatedAt", not(emptyOrNullString())); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment1Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(1)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment2Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + } + + private String addAndVerifyComment(String taskId, CommentInfo comment) { + String id = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(comment) + .post(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENT, taskId, id) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + + return id; + } + + private void updateAndVerifyComment(String taskId, String commentId, CommentInfo comment) { + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .body(comment) + .put(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + } +} diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java new file mode 100644 index 00000000000..b85c3cdad61 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -0,0 +1,199 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.filter.log.RequestLoggingFilter; +import io.restassured.filter.log.ResponseLoggingFilter; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.CoreMatchers.equalTo; + +@QuarkusIntegrationTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +public class UserTaskLifeCycleIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_TRANSITION_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/transition"; + + static { + RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); + } + + @Test + public void testUserTaskLifeCycle() { + + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .queryParam("transitionId", "complete") + .body(Map.of("approved", true)) + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Completed")) + .body("status.terminate", equalTo("COMPLETED")) + .body("outputs.approved", equalTo(true)); + + // Manager is excluded for the secondLineApproval Task, he shouldn't be allowed to see the task + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", not(taskId)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Ready")) + .body("taskName", equalTo("secondLineApproval")) + .body("excludedUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + // Manager is excluded for the secondLineApproval Task, he shouldn't be able to work on the task + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("transitionId", "claim") + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(500); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .queryParam("transitionId", "claim") + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .queryParam("transitionId", "complete") + .body(Map.of("approved", true)) + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Completed")) + .body("status.terminate", equalTo("COMPLETED")) + .body("outputs.approved", equalTo(true)); + + given() + .accept(ContentType.JSON) + .when() + .get("/{processId}/{id}", PROCESS_ID, pid) + .then() + .statusCode(404); + } +} diff --git a/quarkus/integration-tests/pom.xml b/quarkus/integration-tests/pom.xml index 1fb26d5ec8d..48ba322a8bd 100644 --- a/quarkus/integration-tests/pom.xml +++ b/quarkus/integration-tests/pom.xml @@ -48,6 +48,7 @@ integration-tests-quarkus-processes integration-tests-quarkus-processes-reactive integration-tests-quarkus-processes-persistence + integration-tests-quarkus-usertasks integration-tests-quarkus-source-files integration-tests-quarkus-gradle diff --git a/springboot/addons/jbpm-usertask-storage-jpa/pom.xml b/springboot/addons/jbpm-usertask-storage-jpa/pom.xml new file mode 100644 index 00000000000..36bed41e5cc --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/pom.xml @@ -0,0 +1,35 @@ + + + + kogito-addons-springboot-parent + org.kie + 999-SNAPSHOT + + 4.0.0 + + org.jbpm + jbpm-addons-springboot-usertask-storage-jpa + jBPM :: Add-Ons :: Spring Boot :: User Task Storage JPA + jBPM Add-On Spring Boot User Task Storage JPA + + + UTF-8 + org.jbpm.usertask.storage.jpa.springboot + + + + + org.springframework.boot + spring-boot-starter-web + + + org.jbpm + jbpm-addons-usertask-storage-jpa + + + org.kie + kie-addons-springboot-flyway + + + diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java new file mode 100644 index 00000000000..a6eaa9dfb07 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.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.jbpm.usertask.jpa.springboot; + +import org.jbpm.usertask.jpa.JPAUserTaskInstances; +import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +@Component +public class SpringBootJPAUserTaskInstances extends JPAUserTaskInstances { + + @Autowired + public SpringBootJPAUserTaskInstances(UserTaskInstanceRepository userTaskInstanceRepository, UserTaskInstanceEntityMapper userTaskInstanceEntityMapper) { + super(userTaskInstanceRepository, userTaskInstanceEntityMapper); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java new file mode 100644 index 00000000000..596b1e4870b --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.springboot.mapper; + +import org.jbpm.usertask.jpa.mapper.AttachmentsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootAttachmentsEntityMapper extends AttachmentsEntityMapper { + + @Autowired + public SpringBootAttachmentsEntityMapper(AttachmentRepository attachmentRepository) { + super(attachmentRepository); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java new file mode 100644 index 00000000000..d45051c1dc6 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.springboot.mapper; + +import org.jbpm.usertask.jpa.mapper.CommentsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootCommentsEntityMapper extends CommentsEntityMapper { + + @Autowired + public SpringBootCommentsEntityMapper(CommentRepository commentRepository) { + super(commentRepository); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java new file mode 100644 index 00000000000..82bc7f12a1b --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.springboot.mapper; + +import org.jbpm.usertask.jpa.mapper.TaskInputsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootTaskInputsEntityMapper extends TaskInputsEntityMapper { + + @Autowired + public SpringBootTaskInputsEntityMapper(TaskInputRepository repository) { + super(repository); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java new file mode 100644 index 00000000000..76ef4c231b3 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.springboot.mapper; + +import org.jbpm.usertask.jpa.mapper.TaskMetadataEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootTaskMetadataEntityMapper extends TaskMetadataEntityMapper { + + @Autowired + public SpringBootTaskMetadataEntityMapper(TaskMetadataRepository repository) { + super(repository); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java new file mode 100644 index 00000000000..da46632d292 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.springboot.mapper; + +import org.jbpm.usertask.jpa.mapper.TaskOutputsEntityMapper; +import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootTaskOutputsEntityMapper extends TaskOutputsEntityMapper { + + @Autowired + public SpringBootTaskOutputsEntityMapper(TaskOutputRepository repository) { + super(repository); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootUserTaskInstanceEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootUserTaskInstanceEntityMapper.java new file mode 100644 index 00000000000..6c753b1b6a0 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootUserTaskInstanceEntityMapper.java @@ -0,0 +1,34 @@ +/* + * 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.jbpm.usertask.jpa.springboot.mapper; + +import org.jbpm.usertask.jpa.mapper.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootUserTaskInstanceEntityMapper extends UserTaskInstanceEntityMapper { + + @Autowired + public SpringBootUserTaskInstanceEntityMapper(AttachmentsEntityMapper attachmentsMapper, CommentsEntityMapper commentsMapper, TaskMetadataEntityMapper taskMetadataEntityMapper, + TaskInputsEntityMapper taskInputsEntityMapper, TaskOutputsEntityMapper taskOutputsEntityMapper) { + super(attachmentsMapper, commentsMapper, taskMetadataEntityMapper, taskInputsEntityMapper, taskOutputsEntityMapper); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java new file mode 100644 index 00000000000..45c9fd78b18 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java @@ -0,0 +1,36 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@Transactional +public class SpringBootAttachmentRepository extends AttachmentRepository { + + @Autowired + public SpringBootAttachmentRepository(UserTaskJPAContext context) { + super(context); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java new file mode 100644 index 00000000000..c9aecd4e2ef --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java @@ -0,0 +1,36 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@Transactional +public class SpringBootCommentRepository extends CommentRepository { + + @Autowired + public SpringBootCommentRepository(UserTaskJPAContext context) { + super(context); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java new file mode 100644 index 00000000000..1005cf3ad7b --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java @@ -0,0 +1,35 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootTaskInputEntityRepository extends TaskInputRepository { + + @Autowired + public SpringBootTaskInputEntityRepository(UserTaskJPAContext context) { + super(context); + } + +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java new file mode 100644 index 00000000000..6ad081acbfc --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java @@ -0,0 +1,35 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootTaskMetadataEntityRepository extends TaskMetadataRepository { + + @Autowired + public SpringBootTaskMetadataEntityRepository(UserTaskJPAContext context) { + super(context); + } + +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java new file mode 100644 index 00000000000..225629375b3 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java @@ -0,0 +1,35 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SpringBootTaskOutputEntityRepository extends TaskOutputRepository { + + @Autowired + public SpringBootTaskOutputEntityRepository(UserTaskJPAContext context) { + super(context); + } + +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java new file mode 100644 index 00000000000..ab735d33b97 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java @@ -0,0 +1,36 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@Transactional +public class SpringBootUserTaskInstanceRepository extends UserTaskInstanceRepository { + + @Autowired + public SpringBootUserTaskInstanceRepository(UserTaskJPAContext context) { + super(context); + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java new file mode 100644 index 00000000000..9b65e19e809 --- /dev/null +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java @@ -0,0 +1,40 @@ +/* + * 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.jbpm.usertask.jpa.springboot.repository; + +import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; + +@Component +@Transactional +public class SpringBootUserTaskJPAContext implements UserTaskJPAContext { + + @PersistenceContext + private EntityManager em; + + @Override + public EntityManager getEntityManager() { + return em; + } +} diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/resources/META-INF/beans.xml b/springboot/addons/jbpm-usertask-storage-jpa/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/springboot/addons/pom.xml b/springboot/addons/pom.xml index d6221ca7a6b..3aee177ac61 100644 --- a/springboot/addons/pom.xml +++ b/springboot/addons/pom.xml @@ -51,6 +51,7 @@ kubernetes flyway persistence + jbpm-usertask-storage-jpa diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/pom.xml b/springboot/integration-tests/integration-tests-springboot-usertasks-it/pom.xml new file mode 100644 index 00000000000..d3a7645e5f9 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/pom.xml @@ -0,0 +1,153 @@ + + + + org.kie.kogito + kogito-spring-boot-integration-tests + 999-SNAPSHOT + + + 4.0.0 + + integration-tests-springboot-usertasks-it + Kogito :: Integration Tests :: Spring Boot :: UserTasks + + + integration.tests.springboot.userTasks.it + false + + + + + + org.kie.kogito + kogito-spring-boot-bom + ${project.version} + pom + import + + + + + + + org.jbpm + jbpm-spring-boot-starter + + + org.kie + kie-addons-springboot-persistence-jdbc + + + org.jbpm + jbpm-addons-springboot-usertask-storage-jpa + + + + + org.postgresql + postgresql + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.kie + kie-addons-springboot-process-management + + + org.springframework.boot + spring-boot-starter-test + test + + + io.rest-assured + json-schema-validator + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + io.rest-assured + rest-assured + test + + + org.kie.kogito + kogito-spring-boot-test-utils + test + + + org.awaitility + awaitility + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + maven-compiler-plugin + ${version.compiler.plugin} + + ${maven.compiler.release} + + + + pre-kogito-generate-model + process-resources + + compile + + + + + + org.kie.kogito + kogito-maven-plugin + ${project.version} + + + kogito-generate-model + process-resources + + generateModel + + + + kogito-process-model-classes + process-classes + + process-model-classes + + + + + + + \ No newline at end of file diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/acme/travels/Address.java b/springboot/integration-tests/integration-tests-springboot-usertasks-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-usertasks-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-usertasks-it/src/main/java/org/acme/travels/Traveller.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/acme/travels/Traveller.java new file mode 100644 index 00000000000..c24685803d2 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/acme/travels/Traveller.java @@ -0,0 +1,88 @@ +/* + * 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, 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/integration-tests-springboot-usertasks-it/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java new file mode 100644 index 00000000000..8cc2437b71d --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/java/org/kie/kogito/it/KogitoSpringbootApplication.java @@ -0,0 +1,30 @@ +/* + * 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.it; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication(scanBasePackages = { "org.kie.kogito.**", "org.acme.travels.**" }) +public class KogitoSpringbootApplication { + + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/application.properties b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/application.properties new file mode 100644 index 00000000000..0e459353843 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/application.properties @@ -0,0 +1,23 @@ +# +# 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. +# + +kogito.persistence.type=jdbc + +kie.flyway.enabled=true +spring.flyway.enabled=false \ No newline at end of file diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/approval.bpmn b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/approval.bpmn new file mode 100644 index 00000000000..275d148f7ac --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/main/resources/approval.bpmn @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 + _C13522F1-230A-4C26-B5A9-533A5D9FEE9D + + + + + + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX + _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX + + + + traveller + _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX + + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX + approver + + + _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX + firstLineApproval + + + + manager + + + + + + + + + + _C13522F1-230A-4C26-B5A9-533A5D9FEE9D + _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 + + + + + + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX + + + + approver + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX + + + traveller + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX + + + + _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX + secondLineApproval + + + + + + + + + _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 + + + + + + + + _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _F0jB8En5EeqlfsIhq1UCRQ + _F0jB8En5EeqlfsIhq1UCRQ + + diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java new file mode 100644 index 00000000000..3d8f3075882 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java @@ -0,0 +1,90 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Traveller; +import org.junit.jupiter.api.BeforeEach; +import org.springframework.boot.test.web.server.LocalServerPort; + +import io.restassured.RestAssured; +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.Matchers.emptyOrNullString; + +public abstract class BaseUserTaskIT { + public static final String PROCESS_ID = "approvals"; + public static final String PROCESS_INSTANCE = "approvals/{id}"; + public static final String USER_TASKS_ENDPOINT = "usertasks/instance"; + public static final String USER_TASKS_INSTANCE_ENDPOINT = USER_TASKS_ENDPOINT + "/{taskId}"; + + @LocalServerPort + int httpPort; + + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + + @BeforeEach + void setPort() { + RestAssured.port = httpPort; + } + + public String startProcessInstance(Traveller traveller) { + final String pid = given().contentType(ContentType.JSON) + .when() + .body(Map.of("traveller", traveller)) + .post("/{processId}", PROCESS_ID) + .then() + .statusCode(201) + .header("Location", not(emptyOrNullString())) + .body("id", not(emptyOrNullString())) + .extract() + .path("id"); + + given() + .accept(ContentType.JSON) + .when() + .get("/{processId}/{id}", PROCESS_ID, pid) + .then() + .statusCode(200) + .body("id", equalTo(pid)) + .body("traveller.firstName", equalTo(traveller.getFirstName())) + .body("traveller.lastName", equalTo(traveller.getLastName())) + .body("traveller.email", equalTo(traveller.getEmail())) + .body("traveller.nationality", equalTo(traveller.getNationality())); + + return pid; + } + + public void abortProcessInstance(String pid) { + given().contentType(ContentType.JSON) + .when() + .body(Map.of()) + .delete(PROCESS_INSTANCE, pid) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())); + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java new file mode 100644 index 00000000000..1d0c9f0f297 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java @@ -0,0 +1,215 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.net.URI; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.it.KogitoSpringbootApplication; +import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource; +import org.kie.kogito.usertask.model.AttachmentInfo; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.emptyOrNullString; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) +@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class) +public class UserTaskAttachmentsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/attachments"; + public static final String USER_TASKS_INSTANCE_ATTACHMENT = USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT + "/{attachmentId}"; + + @Test + public void testUserTaskAttachments() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + AttachmentInfo attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_1.txt"), "Attachment 1"); + + String attachment1Id = addAndVerifyAttachment(taskId, attachment1); + + AttachmentInfo attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_2.txt"), "Attachment 2"); + + String attachment2Id = addAndVerifyAttachment(taskId, attachment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)); + + attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_1.txt"), "NEW Attachment 1"); + + updateAndVerifyAttachment(taskId, attachment1Id, attachment1); + + attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_2.txt"), "NEW Attachment 2"); + + updateAndVerifyAttachment(taskId, attachment2Id, attachment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", not(emptyOrNullString())) + .body("[0].content", equalTo(attachment1.getUri().toString())) + .body("[0].name", equalTo(attachment1.getName())) + .body("[0].updatedBy", not(emptyOrNullString())) + .body("[0].updatedAt", not(emptyOrNullString())) + .body("[1].id", not(emptyOrNullString())) + .body("[1].content", equalTo(attachment2.getUri().toString())) + .body("[1].name", equalTo(attachment2.getName())) + .body("[1].updatedBy", not(emptyOrNullString())) + .body("[1].updatedAt", not(emptyOrNullString())); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment1Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(1)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment2Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + abortProcessInstance(pid); + } + + private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) { + String id = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .body(attachment) + .post(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, id) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + + return id; + } + + private void updateAndVerifyAttachment(String taskId, String attachmentId, AttachmentInfo attachment) { + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .body(attachment) + .put(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(attachment.getUri().toString())) + .body("name", equalTo(attachment.getName())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java new file mode 100644 index 00000000000..7027198c75f --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java @@ -0,0 +1,207 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.it.KogitoSpringbootApplication; +import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource; +import org.kie.kogito.usertask.model.CommentInfo; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.emptyOrNullString; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) +@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class) +public class UserTaskCommentsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_COMMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/comments"; + public static final String USER_TASKS_INSTANCE_COMMENT = USER_TASKS_INSTANCE_COMMENTS_ENDPOINT + "/{commentId}"; + + @Test + public void testUserTaskComments() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + CommentInfo comment1 = new CommentInfo("This is my second comment."); + + String comment1Id = addAndVerifyComment(taskId, comment1); + + CommentInfo comment2 = new CommentInfo("This is my second comment."); + + String comment2Id = addAndVerifyComment(taskId, comment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)); + + comment1 = new CommentInfo("This is the first comment modified"); + + updateAndVerifyComment(taskId, comment1Id, comment1); + + comment2 = new CommentInfo("This is the second comment modified"); + + updateAndVerifyComment(taskId, comment2Id, comment2); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", not(emptyOrNullString())) + .body("[0].content", equalTo(comment1.getComment())) + .body("[0].updatedBy", not(emptyOrNullString())) + .body("[0].updatedAt", not(emptyOrNullString())) + .body("[1].id", not(emptyOrNullString())) + .body("[1].content", equalTo(comment2.getComment())) + .body("[1].updatedBy", not(emptyOrNullString())) + .body("[1].updatedAt", not(emptyOrNullString())); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment1Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(1)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment2Id) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + abortProcessInstance(pid); + } + + private String addAndVerifyComment(String taskId, CommentInfo comment) { + String id = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .body(comment) + .post(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENT, taskId, id) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + + return id; + } + + private void updateAndVerifyComment(String taskId, String commentId, CommentInfo comment) { + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .body(comment) + .put(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())) + .extract() + .path("id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) + .then() + .statusCode(200) + .body("id", not(emptyOrNullString())) + .body("content", equalTo(comment.getComment())) + .body("updatedBy", not(emptyOrNullString())) + .body("updatedAt", not(emptyOrNullString())); + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java new file mode 100644 index 00000000000..9acd0030c2d --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -0,0 +1,195 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.it.KogitoSpringbootApplication; +import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.CoreMatchers.equalTo; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) +@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class) +public class UserTaskLifeCycleIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_TRANSITION_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/transition"; + + @Test + public void testUserTaskLifeCycle() { + + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + final String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .queryParam("transitionId", "complete") + .body(Map.of("approved", true)) + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Completed")) + .body("status.terminate", equalTo("COMPLETED")) + .body("outputs.approved", equalTo(true)); + + // Manager is excluded for the secondLineApproval Task, he shouldn't be allowed to see the task + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(0)); + + taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", not(taskId)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Ready")) + .body("taskName", equalTo("secondLineApproval")) + .body("excludedUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + // Manager is excluded for the secondLineApproval Task, he shouldn't be able to work on the task + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("transitionId", "claim") + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(500); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .queryParam("transitionId", "claim") + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")); + + given() + .contentType(ContentType.JSON) + .when() + .queryParam("user", "john") + .queryParam("group", "managers") + .queryParam("transitionId", "complete") + .body(Map.of("approved", true)) + .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Completed")) + .body("status.terminate", equalTo("COMPLETED")) + .body("outputs.approved", equalTo(true)); + + given() + .accept(ContentType.JSON) + .when() + .get("/{processId}/{id}", PROCESS_ID, pid) + .then() + .statusCode(404); + } +} diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index 4bf6bb95a02..4e76b109677 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -41,6 +41,7 @@ integration-tests-springboot-norest-it integration-tests-springboot-processes-it integration-tests-springboot-processes-persistence-it + integration-tests-springboot-usertasks-it From daad04c4e96967a38c3af6495824590652ae6083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Mon, 21 Oct 2024 19:59:09 +0200 Subject: [PATCH 4/9] - springboot and it tests --- .../jpa/it/UserTaskAttachmentsIT.java | 12 ++++++++++ .../userTask/jpa/it/UserTaskCommentsIT.java | 11 +++++++++ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 6 +++-- .../jpa/it/UserTaskAttachmentsIT.java | 24 +++++++++---------- .../userTask/jpa/it/UserTaskCommentsIT.java | 24 +++++++++---------- .../userTask/jpa/it/UserTaskLifeCycleIT.java | 11 +++++---- 6 files changed, 58 insertions(+), 30 deletions(-) diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java index 7bb7e22080f..f9be26b8912 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java @@ -57,6 +57,7 @@ public void testUserTaskAttachments() { String taskId = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -67,6 +68,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -83,6 +85,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -99,6 +102,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -117,6 +121,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment1Id) .then() .statusCode(200); @@ -124,6 +129,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -132,6 +138,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment2Id) .then() .statusCode(200); @@ -139,6 +146,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -149,6 +157,7 @@ private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) String id = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .body(attachment) .post(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() @@ -164,6 +173,7 @@ private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, id) .then() .statusCode(200) @@ -180,6 +190,7 @@ private void updateAndVerifyAttachment(String taskId, String attachmentId, Attac given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .body(attachment) .put(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) .then() @@ -195,6 +206,7 @@ private void updateAndVerifyAttachment(String taskId, String attachmentId, Attac given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) .then() .statusCode(200) diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java index b9ac6640eb1..4e3b8f4a2f3 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java @@ -55,6 +55,7 @@ public void testUserTaskComments() { String taskId = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -65,6 +66,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -97,6 +99,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -113,6 +116,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment1Id) .then() .statusCode(200); @@ -120,6 +124,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -128,6 +133,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment2Id) .then() .statusCode(200); @@ -135,6 +141,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -145,6 +152,7 @@ private String addAndVerifyComment(String taskId, CommentInfo comment) { String id = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .body(comment) .post(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() @@ -159,6 +167,7 @@ private String addAndVerifyComment(String taskId, CommentInfo comment) { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENT, taskId, id) .then() .statusCode(200) @@ -174,6 +183,7 @@ private void updateAndVerifyComment(String taskId, String commentId, CommentInfo given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .body(comment) .put(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) .then() @@ -188,6 +198,7 @@ private void updateAndVerifyComment(String taskId, String commentId, CommentInfo given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) .then() .statusCode(200) diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java index b85c3cdad61..c3187377d60 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -56,6 +56,7 @@ public void testUserTaskLifeCycle() { String taskId = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -66,6 +67,7 @@ public void testUserTaskLifeCycle() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) .then() .statusCode(200) @@ -88,7 +90,7 @@ public void testUserTaskLifeCycle() { .contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .queryParam("transitionId", "complete") .body(Map.of("approved", true)) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) @@ -103,7 +105,7 @@ public void testUserTaskLifeCycle() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java index 1d0c9f0f297..60887b11ffb 100644 --- a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java @@ -51,7 +51,7 @@ public void testUserTaskAttachments() { String taskId = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -62,7 +62,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -79,7 +79,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -96,7 +96,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -115,7 +115,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment1Id) .then() .statusCode(200); @@ -123,7 +123,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -132,7 +132,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment2Id) .then() .statusCode(200); @@ -140,7 +140,7 @@ public void testUserTaskAttachments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -153,7 +153,7 @@ private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) String id = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .body(attachment) .post(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) .then() @@ -169,7 +169,7 @@ private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, id) .then() .statusCode(200) @@ -186,7 +186,7 @@ private void updateAndVerifyAttachment(String taskId, String attachmentId, Attac given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .body(attachment) .put(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) .then() @@ -202,7 +202,7 @@ private void updateAndVerifyAttachment(String taskId, String attachmentId, Attac given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) .then() .statusCode(200) diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java index 7027198c75f..07f7f91c4ac 100644 --- a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java @@ -49,7 +49,7 @@ public void testUserTaskComments() { String taskId = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -60,7 +60,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -77,7 +77,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -94,7 +94,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -111,7 +111,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment1Id) .then() .statusCode(200); @@ -119,7 +119,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -128,7 +128,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment2Id) .then() .statusCode(200); @@ -136,7 +136,7 @@ public void testUserTaskComments() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() .statusCode(200) @@ -149,7 +149,7 @@ private String addAndVerifyComment(String taskId, CommentInfo comment) { String id = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .body(comment) .post(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) .then() @@ -164,7 +164,7 @@ private String addAndVerifyComment(String taskId, CommentInfo comment) { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENT, taskId, id) .then() .statusCode(200) @@ -180,7 +180,7 @@ private void updateAndVerifyComment(String taskId, String commentId, CommentInfo given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .body(comment) .put(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) .then() @@ -195,7 +195,7 @@ private void updateAndVerifyComment(String taskId, String commentId, CommentInfo given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) .then() .statusCode(200) diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java index 9acd0030c2d..1b30691ba9a 100644 --- a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -50,7 +50,7 @@ public void testUserTaskLifeCycle() { String taskId = given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -61,7 +61,7 @@ public void testUserTaskLifeCycle() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) .then() .statusCode(200) @@ -84,7 +84,7 @@ public void testUserTaskLifeCycle() { .contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .queryParam("transitionId", "complete") .body(Map.of("approved", true)) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) @@ -99,7 +99,7 @@ public void testUserTaskLifeCycle() { given().contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("group", "managers") + .queryParam("group", "department-managers") .get(USER_TASKS_ENDPOINT) .then() .statusCode(200) @@ -143,7 +143,9 @@ public void testUserTaskLifeCycle() { given() .contentType(ContentType.JSON) .when() + .body(Map.of()) .queryParam("user", "manager") + .queryParam("group", "department-managers") .queryParam("transitionId", "claim") .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() @@ -152,6 +154,7 @@ public void testUserTaskLifeCycle() { given() .contentType(ContentType.JSON) .when() + .body(Map.of()) .queryParam("user", "john") .queryParam("group", "managers") .queryParam("transitionId", "claim") From 80d7dcc00c848a339af50a61265d3c9d2fc79a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Tue, 22 Oct 2024 10:58:47 +0200 Subject: [PATCH 5/9] - cleanup --- .../integration-tests/pom.xml | 149 --------- .../main/java/org/acme/travels/Address.java | 76 ----- .../main/java/org/acme/travels/Traveller.java | 88 ----- .../src/main/resources/application.properties | 24 -- .../src/main/resources/approval.bpmn | 304 ------------------ .../jbpm/userTask/jpa/it/BaseUserTaskIT.java | 63 ---- .../jpa/it/UserTaskAttachmentsIT.java | 208 ------------ .../userTask/jpa/it/UserTaskCommentsIT.java | 200 ------------ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 200 ------------ .../src/test/resources/application.properties | 2 - .../pom.xml | 4 +- 11 files changed, 2 insertions(+), 1316 deletions(-) delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Address.java delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java delete mode 100644 quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml deleted file mode 100644 index a49c94f7e9a..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/pom.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - jbpm-addon-quarkus-usertask-storage-jpa-parent - org.jbpm - 999-SNAPSHOT - - 4.0.0 - - jbpm-addons-quarkus-usertask-storage-jpa-integration-tests - jBPM :: Add-Ons :: Quarkus :: User Task Storage JPA :: Integration Tests - jBPM Add-On Quarkus User Task Storage JPA Integration Tests - - - org.jbpm.usertask.storage.jpa.quarkus.test - - - - - io.quarkus - quarkus-resteasy - - - io.quarkus - quarkus-resteasy-jackson - - - org.jbpm - jbpm-quarkus - - - org.kie - kie-addons-quarkus-persistence-jdbc - - - org.jbpm - jbpm-addons-quarkus-usertask-storage-jpa - - - io.quarkus - quarkus-arc - - - io.quarkus - quarkus-agroal - - - io.quarkus - quarkus-jdbc-postgresql - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - org.assertj - assertj-core - test - - - org.kie.kogito - kogito-quarkus-test-utils - test - - - - - org.jbpm - jbpm-quarkus-deployment - ${project.version} - pom - test - - - * - * - - - - - org.jbpm - jbpm-addons-quarkus-usertask-storage-jpa-deployment - ${project.version} - pom - test - - - * - * - - - - - - - - maven-compiler-plugin - - - io.quarkus - quarkus-maven-plugin - - - - build - - - - - - maven-failsafe-plugin - - - - integration-test - verify - - - - - - - \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Address.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Address.java deleted file mode 100644 index 662dfa9b9f7..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/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/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java deleted file mode 100644 index c24685803d2..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/java/org/acme/travels/Traveller.java +++ /dev/null @@ -1,88 +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, 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/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties deleted file mode 100644 index 5458fa57f9c..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/application.properties +++ /dev/null @@ -1,24 +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. -# - -quarkus.datasource.db-kind=postgresql - -kogito.persistence.type=jdbc - -kie.flyway.enabled=true \ No newline at end of file diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn deleted file mode 100644 index 275d148f7ac..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/main/resources/approval.bpmn +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 - _C13522F1-230A-4C26-B5A9-533A5D9FEE9D - - - - - - - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX - _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX - _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX - _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX - _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX - - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_TaskNameInputX - - - - traveller - _8B62D3CA-5D03-4B2B-832B-126469288BB4_travellerInputX - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_SkippableInputX - - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_GroupIdInputX - - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_ActorIdOutputX - approver - - - _8B62D3CA-5D03-4B2B-832B-126469288BB4_approvedOutputX - firstLineApproval - - - - manager - - - - - - - - - - _C13522F1-230A-4C26-B5A9-533A5D9FEE9D - _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 - - - - - - - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX - - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_TaskNameInputX - - - - approver - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_ExcludedOwnerIdInputX - - - traveller - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_travellerInputX - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_SkippableInputX - - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_GroupIdInputX - - - - _0DBFABE8-92B0-46E6-B52E-A9593AFA4371_approvedOutputX - secondLineApproval - - - - - - - - - _9EAFE6C1-69B4-4908-B764-EF3C4A55BEE3 - - - - - - - - _078F46FB-B7A1-4DBB-BE9A-75C7CB0CCD03 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _F0jB8En5EeqlfsIhq1UCRQ - _F0jB8En5EeqlfsIhq1UCRQ - - diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java deleted file mode 100644 index dc87d96b5d9..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java +++ /dev/null @@ -1,63 +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.jbpm.userTask.jpa.it; - -import io.restassured.http.ContentType; -import org.acme.travels.Traveller; - -import java.util.Map; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.Matchers.emptyOrNullString; - -public abstract class BaseUserTaskIT { - public static final String PROCESS_ID = "approvals"; - public static final String USER_TASKS_ENDPOINT = "/usertasks/instance"; - public static final String USER_TASKS_INSTANCE_ENDPOINT = USER_TASKS_ENDPOINT + "/{taskId}"; - - public String startProcessInstance(Traveller traveller) { - final String pid = given().contentType(ContentType.JSON) - .when() - .body(Map.of("traveller", traveller)) - .post("/{processId}", PROCESS_ID) - .then() - .statusCode(201) - .header("Location", not(emptyOrNullString())) - .body("id", not(emptyOrNullString())) - .extract() - .path("id"); - - given() - .accept(ContentType.JSON) - .when() - .get("/{processId}/{id}", PROCESS_ID, pid) - .then() - .statusCode(200) - .body("id", equalTo(pid)) - .body("traveller.firstName", equalTo(traveller.getFirstName())) - .body("traveller.lastName", equalTo(traveller.getLastName())) - .body("traveller.email", equalTo(traveller.getEmail())) - .body("traveller.nationality", equalTo(traveller.getNationality())); - - return pid; - } -} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java deleted file mode 100644 index 871060aa31c..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java +++ /dev/null @@ -1,208 +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.jbpm.userTask.jpa.it; - -import java.net.URI; - -import org.acme.travels.Address; -import org.acme.travels.Traveller; -import org.junit.jupiter.api.Test; -import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; -import org.kie.kogito.usertask.model.AttachmentInfo; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; -import io.restassured.http.ContentType; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.Matchers.emptyOrNullString; - -@QuarkusIntegrationTest -@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class UserTaskAttachmentsIT extends BaseUserTaskIT { - public static final String USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/attachments"; - public static final String USER_TASKS_INSTANCE_ATTACHMENT = USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT + "/{attachmentId}"; - - static { - RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); - } - - @Test - public void testUserTaskAttachments() { - Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); - - final String pid = startProcessInstance(traveller); - - String taskId = given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_ENDPOINT) - .then() - .statusCode(200) - .body("$.size()", is(1)) - .extract() - .path("[0].id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(0)); - - AttachmentInfo attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_1.txt"), "Attachment 1"); - - String attachment1Id = addAndVerifyAttachment(taskId, attachment1); - - AttachmentInfo attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/attachment_2.txt"), "Attachment 2"); - - String attachment2Id = addAndVerifyAttachment(taskId, attachment2); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(2)); - - - attachment1 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_1.txt"), "NEW Attachment 1"); - - updateAndVerifyAttachment(taskId, attachment1Id, attachment1); - - attachment2 = new AttachmentInfo(URI.create("http://localhost:8080/new_attachment_2.txt"), "NEW Attachment 2"); - - updateAndVerifyAttachment(taskId, attachment2Id, attachment2); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(2)) - .body("[0].id", not(emptyOrNullString())) - .body("[0].content", equalTo(attachment1.getUri().toString())) - .body("[0].name", equalTo(attachment1.getName())) - .body("[0].updatedBy", not(emptyOrNullString())) - .body("[0].updatedAt", not(emptyOrNullString())) - .body("[1].id", not(emptyOrNullString())) - .body("[1].content", equalTo(attachment2.getUri().toString())) - .body("[1].name", equalTo(attachment2.getName())) - .body("[1].updatedBy", not(emptyOrNullString())) - .body("[1].updatedAt", not(emptyOrNullString())); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment1Id) - .then() - .statusCode(200); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(1)); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .delete(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachment2Id) - .then() - .statusCode(200); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(0)); - } - - private String addAndVerifyAttachment(String taskId, AttachmentInfo attachment) { - String id = given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .body(attachment) - .post(USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(attachment.getUri().toString())) - .body("name", equalTo(attachment.getName())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())) - .extract() - .path("id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, id) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(attachment.getUri().toString())) - .body("name", equalTo(attachment.getName())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())); - - return id; - } - - private void updateAndVerifyAttachment(String taskId, String attachmentId, AttachmentInfo attachment) { - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .body(attachment) - .put(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(attachment.getUri().toString())) - .body("name", equalTo(attachment.getName())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())) - .extract() - .path("id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ATTACHMENT, taskId, attachmentId) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(attachment.getUri().toString())) - .body("name", equalTo(attachment.getName())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())); - } -} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java deleted file mode 100644 index 57de1f1d4fc..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java +++ /dev/null @@ -1,200 +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.jbpm.userTask.jpa.it; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; -import io.restassured.http.ContentType; -import org.acme.travels.Address; -import org.acme.travels.Traveller; -import org.junit.jupiter.api.Test; -import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; -import org.kie.kogito.usertask.model.CommentInfo; - - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.Matchers.emptyOrNullString; - -@QuarkusIntegrationTest -@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class UserTaskCommentsIT extends BaseUserTaskIT { - public static final String USER_TASKS_INSTANCE_COMMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/comments"; - public static final String USER_TASKS_INSTANCE_COMMENT = USER_TASKS_INSTANCE_COMMENTS_ENDPOINT + "/{commentId}"; - - static { - RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); - } - - @Test - public void testUserTaskComments() { - Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); - - final String pid = startProcessInstance(traveller); - - String taskId = given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_ENDPOINT) - .then() - .statusCode(200) - .body("$.size()", is(1)) - .extract() - .path("[0].id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(0)); - - CommentInfo comment1 = new CommentInfo("This is my second comment."); - - String comment1Id = addAndVerifyComment(taskId, comment1); - - CommentInfo comment2 = new CommentInfo("This is my second comment."); - - String comment2Id = addAndVerifyComment(taskId, comment2); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(2)); - - - comment1 = new CommentInfo("This is the first comment modified"); - - updateAndVerifyComment(taskId, comment1Id, comment1); - - comment2 = new CommentInfo("This is the second comment modified"); - - updateAndVerifyComment(taskId, comment2Id, comment2); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(2)) - .body("[0].id", not(emptyOrNullString())) - .body("[0].content", equalTo(comment1.getComment())) - .body("[0].updatedBy", not(emptyOrNullString())) - .body("[0].updatedAt", not(emptyOrNullString())) - .body("[1].id", not(emptyOrNullString())) - .body("[1].content", equalTo(comment2.getComment())) - .body("[1].updatedBy", not(emptyOrNullString())) - .body("[1].updatedAt", not(emptyOrNullString())); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment1Id) - .then() - .statusCode(200); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(1)); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .delete(USER_TASKS_INSTANCE_COMMENT, taskId, comment2Id) - .then() - .statusCode(200); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("$.size()", is(0)); - } - - private String addAndVerifyComment(String taskId, CommentInfo comment) { - String id = given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .body(comment) - .post(USER_TASKS_INSTANCE_COMMENTS_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(comment.getComment())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())) - .extract() - .path("id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENT, taskId, id) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(comment.getComment())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())); - - return id; - } - - private void updateAndVerifyComment(String taskId, String commentId, CommentInfo comment) { - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .body(comment) - .put(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(comment.getComment())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())) - .extract() - .path("id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_COMMENT, taskId, commentId) - .then() - .statusCode(200) - .body("id", not(emptyOrNullString())) - .body("content", equalTo(comment.getComment())) - .body("updatedBy", not(emptyOrNullString())) - .body("updatedAt", not(emptyOrNullString())); - } -} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java deleted file mode 100644 index ff142b09480..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java +++ /dev/null @@ -1,200 +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.jbpm.userTask.jpa.it; - -import java.util.Map; - -import org.acme.travels.Address; -import org.acme.travels.Traveller; -import org.junit.jupiter.api.Test; -import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; -import io.restassured.http.ContentType; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.CoreMatchers.equalTo; - -@QuarkusIntegrationTest -@QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class UserTaskLifeCycleIT extends BaseUserTaskIT { - public static final String USER_TASKS_INSTANCE_TRANSITION_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/transition"; - - static { - RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); - } - - @Test - public void testUserTaskLifeCycle() { - - Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); - - final String pid = startProcessInstance(traveller); - - String taskId = given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_ENDPOINT) - .then() - .statusCode(200) - .body("$.size()", is(1)) - .extract() - .path("[0].id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", equalTo(taskId)) - .body("status.name", equalTo("Reserved")) - .body("taskName", equalTo("firstLineApproval")) - .body("potentialUsers", hasItem("manager")) - .body("potentialGroups", hasItem("managers")) - .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) - .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) - .body("inputs.traveller.email", equalTo(traveller.getEmail())) - .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) - .body("metadata.ProcessType", equalTo("BPMN")) - .body("metadata.ProcessVersion", equalTo("1.0")) - .body("metadata.ProcessId", equalTo(PROCESS_ID)) - .body("metadata.ProcessInstanceId", equalTo(pid)) - .body("metadata.ProcessInstanceState", equalTo(1)); - - given() - .contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .queryParam("group", "managers") - .queryParam("transitionId", "complete") - .body(Map.of("approved", true)) - .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", equalTo(taskId)) - .body("status.name", equalTo("Completed")) - .body("status.terminate", equalTo("COMPLETED")) - .body("outputs.approved", equalTo(true)); - - // Manager is excluded for the secondLineApproval Task, he shouldn't be allowed to see the task - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .queryParam("group", "managers") - .get(USER_TASKS_ENDPOINT) - .then() - .statusCode(200) - .body("$.size()", is(0)); - - taskId = given().contentType(ContentType.JSON) - .when() - .queryParam("user", "john") - .queryParam("group", "managers") - .get(USER_TASKS_ENDPOINT) - .then() - .statusCode(200) - .body("$.size()", is(1)) - .body("[0].id", not(taskId)) - .extract() - .path("[0].id"); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "john") - .queryParam("group", "managers") - .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", equalTo(taskId)) - .body("status.name", equalTo("Ready")) - .body("taskName", equalTo("secondLineApproval")) - .body("excludedUsers", hasItem("manager")) - .body("potentialGroups", hasItem("managers")) - .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) - .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) - .body("inputs.traveller.email", equalTo(traveller.getEmail())) - .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) - .body("metadata.ProcessType", equalTo("BPMN")) - .body("metadata.ProcessVersion", equalTo("1.0")) - .body("metadata.ProcessId", equalTo(PROCESS_ID)) - .body("metadata.ProcessInstanceId", equalTo(pid)) - .body("metadata.ProcessInstanceState", equalTo(1)); - - // Manager is excluded for the secondLineApproval Task, he shouldn't be able to work on the task - given() - .contentType(ContentType.JSON) - .when() - .queryParam("user", "manager") - .queryParam("transitionId", "claim") - .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) - .then() - .statusCode(500) - .body("id", equalTo(taskId)); - - given() - .contentType(ContentType.JSON) - .when() - .queryParam("user", "john") - .queryParam("group", "managers") - .queryParam("transitionId", "claim") - .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", equalTo(taskId)); - - given().contentType(ContentType.JSON) - .when() - .queryParam("user", "john") - .queryParam("group", "managers") - .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", equalTo(taskId)) - .body("status.name", equalTo("Reserved")); - - given() - .contentType(ContentType.JSON) - .when() - .queryParam("user", "john") - .queryParam("group", "managers") - .queryParam("transitionId", "complete") - .body(Map.of("approved", true)) - .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) - .then() - .statusCode(200) - .body("id", equalTo(taskId)) - .body("status.name", equalTo("Completed")) - .body("status.terminate", equalTo("COMPLETED")) - .body("outputs.approved", equalTo(true)); - - given() - .accept(ContentType.JSON) - .when() - .get("/{processId}/{id}", PROCESS_ID, pid) - .then() - .statusCode(404); - } -} diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties b/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties deleted file mode 100644 index 96ec268f59e..00000000000 --- a/quarkus/addons/jbpm-usertask-storage-jpa/integration-tests/src/test/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -#quarkus.test.arg-line=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -quarkus.http.test-timeout=1h diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml b/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml index 89b13650a59..e648118be0c 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/pom.xml @@ -21,8 +21,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - jbpm-addon-quarkus-usertask-storage-jpa-parent - org.jbpm + org.kie.kogito + kogito-quarkus-integration-tests 999-SNAPSHOT 4.0.0 From 8066e2e82a54ed7f41a6a4384ee4d93f0a0f578f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Tue, 22 Oct 2024 15:54:38 +0200 Subject: [PATCH 6/9] - fix query - fix packages --- .../usertask/jpa/JPAUserTaskInstances.java | 2 +- .../jpa/mapper/AttachmentsEntityMapper.java | 2 +- .../jpa/mapper/CommentsEntityMapper.java | 2 +- .../jpa/mapper/TaskInputsEntityMapper.java | 2 +- .../jpa/mapper/TaskMetadataEntityMapper.java | 2 +- .../jpa/mapper/TaskOutputsEntityMapper.java | 2 +- .../jpa/model/UserTaskInstanceEntity.java | 12 ++--- .../repository/AttachmentRepository.java | 2 +- .../repository/BaseRepository.java | 2 +- .../repository/CommentRepository.java | 2 +- .../repository/TaskInputRepository.java | 2 +- .../repository/TaskMetadataRepository.java | 2 +- .../repository/TaskOutputRepository.java | 2 +- .../UserTaskInstanceRepository.java | 2 +- .../repository/UserTaskJPAContext.java | 2 +- .../jpa/JPAUserTaskInstancesTest.java | 2 +- .../mapper/AttachmentsEntityMapperTest.java | 2 +- .../jpa/mapper/CommentsEntityMapperTest.java | 2 +- .../mapper/TaskInputsEntityMapperTest.java | 2 +- .../mapper/TaskMetadataEntityMapperTest.java | 2 +- .../mapper/TaskOutputsEntityMapperTest.java | 2 +- .../usertask/jpa/mapper/utils/TestUtils.java | 4 +- .../quarkus/QuarkusJPAUserTaskInstances.java | 2 +- .../QuarkusAttachmentsEntityMapper.java | 2 +- .../mapper/QuarkusCommentsEntityMapper.java | 2 +- .../mapper/QuarkusTaskInputsEntityMapper.java | 2 +- .../QuarkusTaskMetadataEntityMapper.java | 2 +- .../QuarkusTaskOutputsEntityMapper.java | 2 +- .../QuarkusAttachmentRepository.java | 3 ++ .../repository/QuarkusCommentRepository.java | 3 ++ .../QuarkusTaskInputEntityRepository.java | 3 ++ .../QuarkusTaskMetadataEntityRepository.java | 3 ++ .../QuarkusTaskOutputEntityRepository.java | 3 ++ .../QuarkusUserTaskInstanceRepository.java | 3 ++ .../repository/QuarkusUserTaskJPAContext.java | 2 + .../BaseQuarkusJPAUserTaskInstancesTest.java | 54 ++++++++----------- .../SpringBootJPAUserTaskInstances.java | 2 +- .../SpringBootAttachmentsEntityMapper.java | 2 +- .../SpringBootCommentsEntityMapper.java | 2 +- .../SpringBootTaskInputsEntityMapper.java | 2 +- .../SpringBootTaskMetadataEntityMapper.java | 2 +- .../SpringBootTaskOutputsEntityMapper.java | 2 +- .../SpringBootAttachmentRepository.java | 4 +- .../SpringBootCommentRepository.java | 4 +- .../SpringBootTaskInputEntityRepository.java | 4 +- ...pringBootTaskMetadataEntityRepository.java | 4 +- .../SpringBootTaskOutputEntityRepository.java | 4 +- .../SpringBootUserTaskInstanceRepository.java | 4 +- .../SpringBootUserTaskJPAContext.java | 2 +- 49 files changed, 95 insertions(+), 85 deletions(-) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/AttachmentRepository.java (95%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/BaseRepository.java (97%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/CommentRepository.java (95%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/TaskInputRepository.java (96%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/TaskMetadataRepository.java (96%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/TaskOutputRepository.java (96%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/UserTaskInstanceRepository.java (97%) rename addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/{quarkus => }/repository/UserTaskJPAContext.java (94%) diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java index 8be05f6f598..d2f6a5e4cbf 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java @@ -24,7 +24,7 @@ import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; import org.kie.kogito.auth.IdentityProvider; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.UserTaskInstances; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java index f4a896c68cd..210553ed853 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapper.java @@ -26,7 +26,7 @@ import org.jbpm.usertask.jpa.model.AttachmentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; import org.kie.kogito.usertask.model.Attachment; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java index 7d184480c6c..b854ec3510a 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapper.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.model.CommentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.CommentRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; import org.kie.kogito.usertask.model.Comment; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java index 32e2c2cc535..12a6c50f986 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapper.java @@ -28,7 +28,7 @@ import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; import org.jbpm.usertask.jpa.model.TaskInputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java index be7bc43b5c7..999c7357496 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapper.java @@ -27,7 +27,7 @@ import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; import org.jbpm.usertask.jpa.model.TaskMetadataEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java index a2167789719..1fa7d4ae282 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapper.java @@ -28,7 +28,7 @@ import org.jbpm.usertask.jpa.mapper.json.utils.JSONUtils; import org.jbpm.usertask.jpa.model.TaskOutputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java index 365d0c75bec..9a3ef87a01f 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java @@ -26,13 +26,13 @@ @Entity @NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY, query = "select userTask from UserTaskInstanceEntity userTask " + - "left join userTask.adminGroups ag " + - "left join userTask.potentialGroups pg " + - "where :userId not member of userTask.excludedUsers and (" + - "userTask.actualOwner = :userId or " + - "ag in (:roles) or pg in (:roles)" + + "left join userTask.adminGroups adminGroups " + + "left join userTask.potentialGroups potentialGroups " + + "where userTask.actualOwner = :userId " + "or :userId member of userTask.adminUsers " + - "or :userId member of userTask.potentialUsers)") + "or adminGroups in (:roles) " + + "or (:userId member of userTask.potentialUsers and :userId not member of userTask.excludedUsers) " + + "or potentialGroups in (:roles)") @Table(name = "jbpm_user_tasks") public class UserTaskInstanceEntity { public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity"; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/AttachmentRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java similarity index 95% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/AttachmentRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java index d0b1ff5a827..92bf5f5a81f 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/AttachmentRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/AttachmentRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import org.jbpm.usertask.jpa.model.AttachmentEntity; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/BaseRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java similarity index 97% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/BaseRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java index 08a405fb866..ed144ddbc04 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/BaseRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/BaseRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import java.util.List; import java.util.Optional; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/CommentRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java similarity index 95% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/CommentRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java index a77cc4657d2..98b85d6a991 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/CommentRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/CommentRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import org.jbpm.usertask.jpa.model.CommentEntity; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskInputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java similarity index 96% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskInputRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java index 94563bfa704..6e85081ff76 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskInputRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskInputRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import org.jbpm.usertask.jpa.model.TaskDataEntityPK; import org.jbpm.usertask.jpa.model.TaskInputEntity; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskMetadataRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java similarity index 96% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskMetadataRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java index 64269ee373a..26796bb38aa 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskMetadataRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskMetadataRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import org.jbpm.usertask.jpa.model.TaskDataEntityPK; import org.jbpm.usertask.jpa.model.TaskMetadataEntity; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskOutputRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java similarity index 96% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskOutputRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java index 98034328287..2b39b8f1bb0 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/TaskOutputRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/TaskOutputRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import org.jbpm.usertask.jpa.model.TaskDataEntityPK; import org.jbpm.usertask.jpa.model.TaskOutputEntity; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskInstanceRepository.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java similarity index 97% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskInstanceRepository.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java index bd4c7107cf9..1be6a4aec71 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskInstanceRepository.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import java.util.List; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskJPAContext.java b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java similarity index 94% rename from addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskJPAContext.java rename to addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java index 18b4377d58f..8606184dd58 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/UserTaskJPAContext.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskJPAContext.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jbpm.usertask.jpa.quarkus.repository; +package org.jbpm.usertask.jpa.repository; import jakarta.persistence.EntityManager; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java index d5e5e13c38b..d0ca49f1143 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesTest.java @@ -27,7 +27,7 @@ import org.jbpm.usertask.jpa.mapper.*; import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java index 9ce69ebb25e..cafdb8e166b 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/AttachmentsEntityMapperTest.java @@ -26,7 +26,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.AttachmentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java index 7ae5c2e9267..62477c2d7ab 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/CommentsEntityMapperTest.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.CommentEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.CommentRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java index 2b1a610f392..1aaeed39d30 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskInputsEntityMapperTest.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.TaskInputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java index 2bdb1b61554..1e6d18de1fd 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskMetadataEntityMapperTest.java @@ -23,7 +23,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.TaskMetadataEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java index dd716d79bf5..52da167c9d1 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/TaskOutputsEntityMapperTest.java @@ -25,7 +25,7 @@ import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.TaskOutputEntity; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java index bfc70f5624b..0204d56a17a 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java +++ b/addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/mapper/utils/TestUtils.java @@ -256,11 +256,11 @@ public static DefaultUserTaskInstance createUserTaskInstance() { instance.setStatus(UserTaskState.of("Complete", UserTaskState.TerminationType.COMPLETED)); instance.setActualOwner("Homer"); - instance.setPotentialUsers(Set.of("Bart")); + instance.setPotentialUsers(Set.of("Bart", "Liza")); instance.setPotentialGroups(Set.of("Simpson", "Family")); instance.setAdminUsers(Set.of("Seymour")); instance.setAdminGroups(Set.of("Administrators", "Managers")); - instance.setExcludedUsers(Set.of("Ned")); + instance.setExcludedUsers(Set.of("Ned", "Bart")); instance.setExternalReferenceId("external-reference-id"); diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java index 85de1b1b68e..d1cdbef5eb4 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/QuarkusJPAUserTaskInstances.java @@ -21,7 +21,7 @@ import org.jbpm.usertask.jpa.JPAUserTaskInstances; import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java index 367e65f4382..cb642a4334c 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusAttachmentsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.quarkus.mapper; import org.jbpm.usertask.jpa.mapper.AttachmentsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java index 7a320540221..0024b10a31e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusCommentsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.quarkus.mapper; import org.jbpm.usertask.jpa.mapper.CommentsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.CommentRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java index 7a305028487..1304468655e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskInputsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.quarkus.mapper; import org.jbpm.usertask.jpa.mapper.TaskInputsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java index 049ed2e802e..fdc5b94360a 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskMetadataEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.quarkus.mapper; import org.jbpm.usertask.jpa.mapper.TaskMetadataEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java index 77eabd59326..0d80b25e24b 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/mapper/QuarkusTaskOutputsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.quarkus.mapper; import org.jbpm.usertask.jpa.mapper.TaskOutputsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java index 9687969600e..04a551660d5 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusAttachmentRepository.java @@ -19,6 +19,9 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.transaction.Transactional; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java index 72b07095bd0..7bfecdb4c2e 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusCommentRepository.java @@ -19,6 +19,9 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.transaction.Transactional; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java index aaa8e25730d..41818d7e0c7 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskInputEntityRepository.java @@ -19,6 +19,9 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java index 51fffaa75a8..6ff95bdf79c 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskMetadataEntityRepository.java @@ -19,6 +19,9 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java index 9d546e3497a..7810b987848 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusTaskOutputEntityRepository.java @@ -19,6 +19,9 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java index a59db2df444..2a487fb8bfb 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskInstanceRepository.java @@ -19,6 +19,9 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.transaction.Transactional; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java index b510fb4b6c3..bcbfb1e366b 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/main/java/org/jbpm/usertask/jpa/quarkus/repository/QuarkusUserTaskJPAContext.java @@ -19,6 +19,8 @@ package org.jbpm.usertask.jpa.quarkus.repository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; + import jakarta.enterprise.context.ApplicationScoped; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; diff --git a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java index a7674ae35e2..1bfcc273af6 100644 --- a/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java +++ b/quarkus/addons/jbpm-usertask-storage-jpa/runtime/src/test/java/org/jbpm/usertask/jpa/quarkus/BaseQuarkusJPAUserTaskInstancesTest.java @@ -28,10 +28,10 @@ import org.jbpm.usertask.jpa.JPAUserTaskInstances; import org.jbpm.usertask.jpa.mapper.utils.TestUtils; import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity; -import org.jbpm.usertask.jpa.quarkus.repository.*; +import org.jbpm.usertask.jpa.quarkus.repository.QuarkusUserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.kogito.auth.IdentityProvider; import org.kie.kogito.auth.IdentityProviders; import org.kie.kogito.usertask.UserTaskInstance; import org.kie.kogito.usertask.impl.DefaultUserTaskInstance; @@ -108,16 +108,6 @@ public void testCreateUserTask() { .isPresent(); assertEntityAndInstance(entity, persistedInstanceOptional.get()); - - userTaskInstances.remove(instance); - - verify(disconnect, times(1)).apply(any()); - - Assertions.assertThat(attachmentRepository.findAll()) - .isEmpty(); - - Assertions.assertThat(userTaskInstances.exists(instance.getId())) - .isFalse(); } @Test @@ -190,9 +180,7 @@ public void testFindByIdentityByActualOwner() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Homer", "Group"); - - List result = userTaskInstances.findByIdentity(identityProvider); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Homer", "Group")); Assertions.assertThat(result) .hasSize(1); @@ -211,15 +199,20 @@ public void testFindByIdentityByPotentialOwners() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Bart", "Group"); - - List result = userTaskInstances.findByIdentity(identityProvider); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Liza", "Group")); Assertions.assertThat(result) .hasSize(1); verify(connect, times(2)).apply(any(UserTaskInstance.class)); + List result2 = userTaskInstances.findByIdentity(IdentityProviders.of("Bart", "Simpson")); + + Assertions.assertThat(result2) + .hasSize(1); + + verify(connect, times(3)).apply(any(UserTaskInstance.class)); + userTaskInstances.remove(instance); Assertions.assertThat(userTaskInstances.exists(instance.getId())) @@ -232,9 +225,7 @@ public void testFindByIdentityByPotentialGroups() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Abraham", "Admin", "Simpson"); - - List result = userTaskInstances.findByIdentity(identityProvider); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Abraham", "Admin", "Simpson")); Assertions.assertThat(result) .hasSize(1); @@ -254,9 +245,7 @@ public void testFindByIdentityByAdminUsers() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Seymour", "Group"); - - List result = userTaskInstances.findByIdentity(identityProvider); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Seymour", "Group")); Assertions.assertThat(result) .hasSize(1); @@ -275,9 +264,7 @@ public void testFindByIdentityByAdminGroups() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Abraham", "Administrator", "Managers"); - - List result = userTaskInstances.findByIdentity(identityProvider); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Abraham", "Administrator", "Managers")); Assertions.assertThat(result) .hasSize(1); @@ -296,9 +283,14 @@ public void testFindByIdentityByExcludedUser() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Ned", "Simpson", "Family", "Administrators", "Managers"); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Ned")); - List result = userTaskInstances.findByIdentity(identityProvider); + Assertions.assertThat(result) + .hasSize(0); + + verify(connect, times(1)).apply(any(UserTaskInstance.class)); + + result = userTaskInstances.findByIdentity(IdentityProviders.of("Bart")); Assertions.assertThat(result) .hasSize(0); @@ -317,9 +309,7 @@ public void testFindByIdentityByUnknownUser() { userTaskInstances.create(instance); - IdentityProvider identityProvider = IdentityProviders.of("Someone", "Group"); - - List result = userTaskInstances.findByIdentity(identityProvider); + List result = userTaskInstances.findByIdentity(IdentityProviders.of("Someone", "Group")); Assertions.assertThat(result) .hasSize(0); diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java index a6eaa9dfb07..aadef95e407 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/SpringBootJPAUserTaskInstances.java @@ -21,7 +21,7 @@ import org.jbpm.usertask.jpa.JPAUserTaskInstances; import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java index 596b1e4870b..6375f27ec8e 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootAttachmentsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.springboot.mapper; import org.jbpm.usertask.jpa.mapper.AttachmentsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java index d45051c1dc6..2a8c4cb8215 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootCommentsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.springboot.mapper; import org.jbpm.usertask.jpa.mapper.CommentsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.CommentRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java index 82bc7f12a1b..c0520b805b3 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskInputsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.springboot.mapper; import org.jbpm.usertask.jpa.mapper.TaskInputsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java index 76ef4c231b3..9d52d325084 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskMetadataEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.springboot.mapper; import org.jbpm.usertask.jpa.mapper.TaskMetadataEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java index da46632d292..83f9634990a 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/mapper/SpringBootTaskOutputsEntityMapper.java @@ -20,7 +20,7 @@ package org.jbpm.usertask.jpa.springboot.mapper; import org.jbpm.usertask.jpa.mapper.TaskOutputsEntityMapper; -import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java index 45c9fd78b18..d9fad245177 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootAttachmentRepository.java @@ -19,8 +19,8 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.AttachmentRepository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.AttachmentRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java index c9aecd4e2ef..6181e505e7e 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootCommentRepository.java @@ -19,8 +19,8 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.CommentRepository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.CommentRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java index 1005cf3ad7b..468301e813f 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskInputEntityRepository.java @@ -19,8 +19,8 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.TaskInputRepository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.TaskInputRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java index 6ad081acbfc..c5064422a82 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskMetadataEntityRepository.java @@ -19,8 +19,8 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.TaskMetadataRepository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.TaskMetadataRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java index 225629375b3..3eefcd20778 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootTaskOutputEntityRepository.java @@ -19,8 +19,8 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.TaskOutputRepository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.TaskOutputRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java index ab735d33b97..b84df9dad37 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskInstanceRepository.java @@ -19,8 +19,8 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskInstanceRepository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java index 9b65e19e809..a208f7ece9c 100644 --- a/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java +++ b/springboot/addons/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/springboot/repository/SpringBootUserTaskJPAContext.java @@ -19,7 +19,7 @@ package org.jbpm.usertask.jpa.springboot.repository; -import org.jbpm.usertask.jpa.quarkus.repository.UserTaskJPAContext; +import org.jbpm.usertask.jpa.repository.UserTaskJPAContext; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; From e6d23329962f95a321e380af0db14cf9e215e3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Tue, 22 Oct 2024 17:25:20 +0200 Subject: [PATCH 7/9] - CI LOGS --- .../kogito/usertask/impl/DefaultUserTaskInstance.java | 3 +++ .../impl/lifecycle/DefaultUserTaskLifeCycle.java | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java index c0efe0b069d..a235f96a215 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java @@ -157,6 +157,9 @@ public void setExternalReferenceId(String externalReferenceId) { @Override public void transition(String transitionId, Map data, IdentityProvider identity) { + System.out.println("######################################################################"); + System.out.println("#################### DefaultUserTaskInstance ##################"); + System.out.println("newTransitionToken(" + transitionId + ", " + this.status.getName() + " " + identity.getName() + " " + identity.getRoles() + ")"); Optional next = Optional.of(this.userTaskLifeCycle.newTransitionToken(transitionId, this, data)); while (next.isPresent()) { UserTaskTransitionToken transition = next.get(); diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java index 6af8a612fcf..d1e33292c33 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java @@ -111,7 +111,15 @@ public UserTaskTransitionToken newTransitionToken(String transitionId, UserTaskI } public UserTaskTransitionToken newTransitionToken(String transitionId, UserTaskState state, Map data) { - UserTaskTransition transition = transitions.stream().filter(e -> e.source().equals(state) && e.id().equals(transitionId)).findAny() + System.out.println("######################################################################"); + System.out.println("#################### DefaultUserTaskLifeCycle ##################"); + System.out.println("newTransitionToken(" + transitionId + ", " + state + ")"); + UserTaskTransition transition = transitions.stream().filter(e -> { + + boolean result = e.source().equals(state) && e.id().equals(transitionId); + System.out.println("Transition to check: " + e.source().getName() + " ->" + e.source().isTerminate() + " -> " + result); + return result; + }).findAny() .orElseThrow(() -> new RuntimeException("Invalid transition " + transitionId + " from " + state)); return new DefaultUserTaskTransitionToken(transition.id(), transition.source(), transition.target(), data); } From 2001ad189278443eb8d379d721643552505f328a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Tue, 22 Oct 2024 21:26:21 +0200 Subject: [PATCH 8/9] - revert CI Logs - fix it tests endpoints --- .../impl/DefaultUserTaskInstance.java | 3 - .../lifecycle/DefaultUserTaskLifeCycle.java | 10 +- .../jbpm/userTask/jpa/it/BaseUserTaskIT.java | 5 + .../jpa/it/UserTaskAttachmentsIT.java | 9 +- .../userTask/jpa/it/UserTaskCommentsIT.java | 9 +- .../jbpm/userTask/jpa/it/UserTaskInputs.java | 107 +++++++++++++++++ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 19 +-- .../userTask/jpa/it/UserTaskOutputsIT.java | 109 +++++++++++++++++ .../jbpm/userTask/jpa/it/UserTaskInputs.java | 110 +++++++++++++++++ .../userTask/jpa/it/UserTaskLifeCycleIT.java | 12 +- .../userTask/jpa/it/UserTaskOutputsIT.java | 112 ++++++++++++++++++ 11 files changed, 456 insertions(+), 49 deletions(-) create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java create mode 100644 quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java create mode 100644 springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java index a235f96a215..c0efe0b069d 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java @@ -157,9 +157,6 @@ public void setExternalReferenceId(String externalReferenceId) { @Override public void transition(String transitionId, Map data, IdentityProvider identity) { - System.out.println("######################################################################"); - System.out.println("#################### DefaultUserTaskInstance ##################"); - System.out.println("newTransitionToken(" + transitionId + ", " + this.status.getName() + " " + identity.getName() + " " + identity.getRoles() + ")"); Optional next = Optional.of(this.userTaskLifeCycle.newTransitionToken(transitionId, this, data)); while (next.isPresent()) { UserTaskTransitionToken transition = next.get(); diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java index d1e33292c33..6af8a612fcf 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/lifecycle/DefaultUserTaskLifeCycle.java @@ -111,15 +111,7 @@ public UserTaskTransitionToken newTransitionToken(String transitionId, UserTaskI } public UserTaskTransitionToken newTransitionToken(String transitionId, UserTaskState state, Map data) { - System.out.println("######################################################################"); - System.out.println("#################### DefaultUserTaskLifeCycle ##################"); - System.out.println("newTransitionToken(" + transitionId + ", " + state + ")"); - UserTaskTransition transition = transitions.stream().filter(e -> { - - boolean result = e.source().equals(state) && e.id().equals(transitionId); - System.out.println("Transition to check: " + e.source().getName() + " ->" + e.source().isTerminate() + " -> " + result); - return result; - }).findAny() + UserTaskTransition transition = transitions.stream().filter(e -> e.source().equals(state) && e.id().equals(transitionId)).findAny() .orElseThrow(() -> new RuntimeException("Invalid transition " + transitionId + " from " + state)); return new DefaultUserTaskTransitionToken(transition.id(), transition.source(), transition.target(), data); } diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java index 21ae0338dc2..1d75f4c0c5a 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/BaseUserTaskIT.java @@ -23,6 +23,7 @@ import org.acme.travels.Traveller; +import io.restassured.RestAssured; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; @@ -35,6 +36,10 @@ public abstract class BaseUserTaskIT { public static final String USER_TASKS_ENDPOINT = "/usertasks/instance"; public static final String USER_TASKS_INSTANCE_ENDPOINT = USER_TASKS_ENDPOINT + "/{taskId}"; + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + public String startProcessInstance(Traveller traveller) { final String pid = given().contentType(ContentType.JSON) .when() diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java index f9be26b8912..630e207040b 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskAttachmentsIT.java @@ -29,9 +29,6 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; @@ -44,15 +41,11 @@ public class UserTaskAttachmentsIT extends BaseUserTaskIT { public static final String USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/attachments"; public static final String USER_TASKS_INSTANCE_ATTACHMENT = USER_TASKS_INSTANCE_ATTACHMENTS_ENDPOINT + "/{attachmentId}"; - static { - RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); - } - @Test public void testUserTaskAttachments() { Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); - final String pid = startProcessInstance(traveller); + startProcessInstance(traveller); String taskId = given().contentType(ContentType.JSON) .when() diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java index 4e3b8f4a2f3..638c7e30266 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskCommentsIT.java @@ -27,9 +27,6 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; @@ -42,15 +39,11 @@ public class UserTaskCommentsIT extends BaseUserTaskIT { public static final String USER_TASKS_INSTANCE_COMMENTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/comments"; public static final String USER_TASKS_INSTANCE_COMMENT = USER_TASKS_INSTANCE_COMMENTS_ENDPOINT + "/{commentId}"; - static { - RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); - } - @Test public void testUserTaskComments() { Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); - final String pid = startProcessInstance(traveller); + startProcessInstance(traveller); String taskId = given().contentType(ContentType.JSON) .when() diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java new file mode 100644 index 00000000000..13084ed8399 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java @@ -0,0 +1,107 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; + +@QuarkusIntegrationTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +public class UserTaskInputs extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_INPUTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/inputs"; + + @Test + public void testUserTaskInputs() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + Traveller newTraveller = new Traveller("Ned", "Stark", "n.stark@winterfell.com", "Northern", new Address("main street", "Winterfell", "10005", "WF")); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .body(Map.of("traveller", newTraveller)) + .put(USER_TASKS_INSTANCE_INPUTS_ENDPOINT, taskId) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("inputs.traveller.firstName", equalTo(newTraveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(newTraveller.getLastName())) + .body("inputs.traveller.email", equalTo(newTraveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(newTraveller.getNationality())) + .body("inputs.traveller.address.street", equalTo(newTraveller.getAddress().getStreet())) + .body("inputs.traveller.address.city", equalTo(newTraveller.getAddress().getCity())) + .body("inputs.traveller.address.zipCode", equalTo(newTraveller.getAddress().getZipCode())) + .body("inputs.traveller.address.country", equalTo(newTraveller.getAddress().getCountry())); + } +} diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java index c3187377d60..b2c7b29e11d 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -25,27 +25,20 @@ import org.acme.travels.Traveller; import org.junit.jupiter.api.Test; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import org.kie.kogito.usertask.model.TransitionInfo; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; import io.restassured.http.ContentType; import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.CoreMatchers.equalTo; @QuarkusIntegrationTest @QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) public class UserTaskLifeCycleIT extends BaseUserTaskIT { public static final String USER_TASKS_INSTANCE_TRANSITION_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/transition"; - static { - RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); - } - @Test public void testUserTaskLifeCycle() { @@ -91,8 +84,7 @@ public void testUserTaskLifeCycle() { .when() .queryParam("user", "manager") .queryParam("group", "department-managers") - .queryParam("transitionId", "complete") - .body(Map.of("approved", true)) + .body(new TransitionInfo("complete", Map.of("approved", true))) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(200) @@ -150,7 +142,7 @@ public void testUserTaskLifeCycle() { .contentType(ContentType.JSON) .when() .queryParam("user", "manager") - .queryParam("transitionId", "claim") + .body(new TransitionInfo("claim")) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(500); @@ -160,7 +152,7 @@ public void testUserTaskLifeCycle() { .when() .queryParam("user", "john") .queryParam("group", "managers") - .queryParam("transitionId", "claim") + .body(new TransitionInfo("claim")) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(200) @@ -181,8 +173,7 @@ public void testUserTaskLifeCycle() { .when() .queryParam("user", "john") .queryParam("group", "managers") - .queryParam("transitionId", "complete") - .body(Map.of("approved", true)) + .body(new TransitionInfo("complete", Map.of("approved", true))) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(200) diff --git a/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java new file mode 100644 index 00000000000..1192545ac61 --- /dev/null +++ b/quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; + +@QuarkusIntegrationTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +public class UserTaskOutputsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_OUTPUTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/outputs"; + + @Test + public void testUserTaskOutputs() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + Traveller newTraveller = new Traveller("Ned", "Stark", "n.stark@winterfell.com", "Northern", new Address("main street", "Winterfell", "10005", "WF")); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .body(Map.of("traveller", newTraveller, "approved", true)) + .put(USER_TASKS_INSTANCE_OUTPUTS_ENDPOINT, taskId) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("outputs.approved", is(true)) + .body("outputs.traveller.firstName", equalTo(newTraveller.getFirstName())) + .body("outputs.traveller.lastName", equalTo(newTraveller.getLastName())) + .body("outputs.traveller.email", equalTo(newTraveller.getEmail())) + .body("outputs.traveller.nationality", equalTo(newTraveller.getNationality())) + .body("outputs.traveller.address.street", equalTo(newTraveller.getAddress().getStreet())) + .body("outputs.traveller.address.city", equalTo(newTraveller.getAddress().getCity())) + .body("outputs.traveller.address.zipCode", equalTo(newTraveller.getAddress().getZipCode())) + .body("outputs.traveller.address.country", equalTo(newTraveller.getAddress().getCountry())); + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java new file mode 100644 index 00000000000..0357f040233 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskInputs.java @@ -0,0 +1,110 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.it.KogitoSpringbootApplication; +import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) +@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class) +public class UserTaskInputs extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_INPUTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/inputs"; + + @Test + public void testUserTaskInputs() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + Traveller newTraveller = new Traveller("Ned", "Stark", "n.stark@winterfell.com", "Northern", new Address("main street", "Winterfell", "10005", "WF")); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .body(Map.of("traveller", newTraveller)) + .put(USER_TASKS_INSTANCE_INPUTS_ENDPOINT, taskId) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("inputs.traveller.firstName", equalTo(newTraveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(newTraveller.getLastName())) + .body("inputs.traveller.email", equalTo(newTraveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(newTraveller.getNationality())) + .body("inputs.traveller.address.street", equalTo(newTraveller.getAddress().getStreet())) + .body("inputs.traveller.address.city", equalTo(newTraveller.getAddress().getCity())) + .body("inputs.traveller.address.zipCode", equalTo(newTraveller.getAddress().getZipCode())) + .body("inputs.traveller.address.country", equalTo(newTraveller.getAddress().getCountry())); + + abortProcessInstance(pid); + } +} diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java index 1b30691ba9a..0f04acf9565 100644 --- a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskLifeCycleIT.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.kie.kogito.it.KogitoSpringbootApplication; import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource; +import org.kie.kogito.usertask.model.TransitionInfo; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; @@ -33,7 +34,6 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.CoreMatchers.equalTo; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) @ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class) @@ -85,8 +85,7 @@ public void testUserTaskLifeCycle() { .when() .queryParam("user", "manager") .queryParam("group", "department-managers") - .queryParam("transitionId", "complete") - .body(Map.of("approved", true)) + .body(new TransitionInfo("complete", Map.of("approved", true))) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(200) @@ -146,7 +145,7 @@ public void testUserTaskLifeCycle() { .body(Map.of()) .queryParam("user", "manager") .queryParam("group", "department-managers") - .queryParam("transitionId", "claim") + .body(new TransitionInfo("claim")) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(500); @@ -157,7 +156,7 @@ public void testUserTaskLifeCycle() { .body(Map.of()) .queryParam("user", "john") .queryParam("group", "managers") - .queryParam("transitionId", "claim") + .body(new TransitionInfo("claim")) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(200) @@ -178,8 +177,7 @@ public void testUserTaskLifeCycle() { .when() .queryParam("user", "john") .queryParam("group", "managers") - .queryParam("transitionId", "complete") - .body(Map.of("approved", true)) + .body(new TransitionInfo("complete", Map.of("approved", true))) .post(USER_TASKS_INSTANCE_TRANSITION_ENDPOINT, taskId) .then() .statusCode(200) diff --git a/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java new file mode 100644 index 00000000000..b89e19989a1 --- /dev/null +++ b/springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskOutputsIT.java @@ -0,0 +1,112 @@ +/* + * 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.jbpm.userTask.jpa.it; + +import java.util.Map; + +import org.acme.travels.Address; +import org.acme.travels.Traveller; +import org.junit.jupiter.api.Test; +import org.kie.kogito.it.KogitoSpringbootApplication; +import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.*; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) +@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class) +public class UserTaskOutputsIT extends BaseUserTaskIT { + public static final String USER_TASKS_INSTANCE_OUTPUTS_ENDPOINT = USER_TASKS_INSTANCE_ENDPOINT + "/outputs"; + + @Test + public void testUserTaskOutputs() { + Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American", new Address("main street", "Boston", "10005", "US")); + + String pid = startProcessInstance(traveller); + + String taskId = given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_ENDPOINT) + .then() + .statusCode(200) + .body("$.size()", is(1)) + .extract() + .path("[0].id"); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("status.name", equalTo("Reserved")) + .body("taskName", equalTo("firstLineApproval")) + .body("potentialUsers", hasItem("manager")) + .body("potentialGroups", hasItem("managers")) + .body("inputs.traveller.firstName", equalTo(traveller.getFirstName())) + .body("inputs.traveller.lastName", equalTo(traveller.getLastName())) + .body("inputs.traveller.email", equalTo(traveller.getEmail())) + .body("inputs.traveller.nationality", equalTo(traveller.getNationality())) + .body("metadata.ProcessType", equalTo("BPMN")) + .body("metadata.ProcessVersion", equalTo("1.0")) + .body("metadata.ProcessId", equalTo(PROCESS_ID)) + .body("metadata.ProcessInstanceId", equalTo(pid)) + .body("metadata.ProcessInstanceState", equalTo(1)); + + Traveller newTraveller = new Traveller("Ned", "Stark", "n.stark@winterfell.com", "Northern", new Address("main street", "Winterfell", "10005", "WF")); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .body(Map.of("traveller", newTraveller, "approved", true)) + .put(USER_TASKS_INSTANCE_OUTPUTS_ENDPOINT, taskId) + .then() + .statusCode(200); + + given().contentType(ContentType.JSON) + .when() + .queryParam("user", "manager") + .queryParam("group", "department-managers") + .get(USER_TASKS_INSTANCE_ENDPOINT, taskId) + .then() + .statusCode(200) + .body("id", equalTo(taskId)) + .body("outputs.approved", is(true)) + .body("outputs.traveller.firstName", equalTo(newTraveller.getFirstName())) + .body("outputs.traveller.lastName", equalTo(newTraveller.getLastName())) + .body("outputs.traveller.email", equalTo(newTraveller.getEmail())) + .body("outputs.traveller.nationality", equalTo(newTraveller.getNationality())) + .body("outputs.traveller.address.street", equalTo(newTraveller.getAddress().getStreet())) + .body("outputs.traveller.address.city", equalTo(newTraveller.getAddress().getCity())) + .body("outputs.traveller.address.zipCode", equalTo(newTraveller.getAddress().getZipCode())) + .body("outputs.traveller.address.country", equalTo(newTraveller.getAddress().getCountry())); + + abortProcessInstance(pid); + } +} From e1877ac3e616db08072db0e675d6e14187078b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Tue, 22 Oct 2024 23:52:18 +0200 Subject: [PATCH 9/9] - increase priority --- .../db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql | 2 +- .../db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql index 7b22fc373c7..058f3599d3b 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/h2/V1.0.0__jBPM_user_task_create.sql @@ -20,7 +20,7 @@ create table jbpm_user_tasks ( id varchar(50) not null, user_task_id varchar(255), - task_priority varchar(10), + task_priority varchar(50), actual_owner varchar(255), task_description varchar(255), status varchar(255), diff --git a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql index 3805d926c5d..8daa0437216 100644 --- a/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql +++ b/addons/common/jbpm-usertask-storage-jpa/src/main/resources/kie-flyway/db/user-tasks/postgresql/V1.0.0__jBPM_user_task_create.sql @@ -20,7 +20,7 @@ create table jbpm_user_tasks ( id varchar(50) not null, user_task_id varchar(255), - task_priority varchar(10), + task_priority varchar(50), actual_owner varchar(255), task_description varchar(255), status varchar(255),