From a4c68b64226ff014511c4163e002616882b40a5f Mon Sep 17 00:00:00 2001 From: shsahahyland Date: Mon, 2 Dec 2024 15:56:16 +0000 Subject: [PATCH] Apply automatic changes --- ...stomizedProcessInstanceRepositoryImpl.java | 2 - ...izedProcessInstanceRepositoryImplTest.java | 35 ++++++++++++------ .../utils/ProcessInstanceHelper.java | 4 +- ...omizedProcessInstanceRepositoryImplIT.java | 37 +++++++++++-------- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImpl.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImpl.java index c1aea71521..13a2c6b993 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImpl.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImpl.java @@ -18,13 +18,11 @@ import com.querydsl.jpa.JPQLQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.persistence.EntityManager; - import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; - import org.activiti.cloud.api.process.model.QueryCloudSubprocessInstance; import org.activiti.cloud.services.query.model.ProcessInstanceEntity; import org.activiti.cloud.services.query.model.QProcessInstanceEntity; diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImplTest.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImplTest.java index a7f29de721..f829d2465a 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImplTest.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/CustomizedProcessInstanceRepositoryImplTest.java @@ -18,12 +18,11 @@ import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; -import java.util.*; - import com.querydsl.jpa.JPQLQuery; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.persistence.EntityManager; +import java.util.*; import org.activiti.cloud.api.process.model.QueryCloudSubprocessInstance; import org.activiti.cloud.services.query.app.repository.utils.ProcessInstanceHelper; import org.activiti.cloud.services.query.model.ProcessInstanceEntity; @@ -43,12 +42,16 @@ class CustomizedProcessInstanceRepositoryImplTest { @Mock private EntityManager entityManager; + @Mock private JPAQueryFactory queryFactory; + @Mock private JPAQuery jpaQuery; + @Mock private JPQLQuery jpqlQuery; + @Mock private Querydsl querydsl; @@ -64,7 +67,8 @@ void setUp() { @Test void testGetQueryCloudSubprocessInstance() { - ProcessInstanceEntity subprocess = new ProcessInstanceHelper().createProcessInstance(UUID.randomUUID().toString()); + ProcessInstanceEntity subprocess = new ProcessInstanceHelper() + .createProcessInstance(UUID.randomUUID().toString()); QueryCloudSubprocessInstance result = repository.getQueryCloudSubprocessInstance(subprocess); assertNotNull(result); @@ -88,7 +92,8 @@ void testGroupSubprocesses() { List processInstancesList = new ProcessInstanceHelper().createParentProcessInstances(4); String parentIdOne = processInstancesList.getFirst().getId(); String parentIdTwo = processInstancesList.getLast().getId(); - List subprocessesList = new ProcessInstanceHelper().createSubprocessInstances(2, parentIdOne); + List subprocessesList = new ProcessInstanceHelper() + .createSubprocessInstances(2, parentIdOne); subprocessesList.addAll(new ProcessInstanceHelper().createSubprocessInstances(3, parentIdTwo)); Page subprocesses = new PageImpl<>(subprocessesList); @@ -106,7 +111,8 @@ void testGroupSubprocesses() { @Test void testFindSubprocessesByParentId() { String parentId = UUID.randomUUID().toString(); - List expectedSubprocesses = new ProcessInstanceHelper().createSubprocessInstances(2, parentId); + List expectedSubprocesses = new ProcessInstanceHelper() + .createSubprocessInstances(2, parentId); QProcessInstanceEntity processInstanceEntity = QProcessInstanceEntity.processInstanceEntity; @@ -131,7 +137,8 @@ void testFindSubprocessesByParentIds() { List parentIds = Arrays.asList("parent1", "parent2"); Pageable pageable = PageRequest.of(0, 10); - List expectedSubprocesses = new ProcessInstanceHelper().createSubprocessInstances(2, "parent1"); + List expectedSubprocesses = new ProcessInstanceHelper() + .createSubprocessInstances(2, "parent1"); expectedSubprocesses.addAll(new ProcessInstanceHelper().createSubprocessInstances(3, "parent2")); QProcessInstanceEntity processInstanceEntity = QProcessInstanceEntity.processInstanceEntity; @@ -157,13 +164,18 @@ void testFindSubprocessesByParentIds() { @Test void testMapSubprocesses() { List processInstancesList = new ProcessInstanceHelper().createParentProcessInstances(2); - List parentIds = Arrays.asList(processInstancesList.getFirst().getId(),processInstancesList.getLast().getId()); + List parentIds = Arrays.asList( + processInstancesList.getFirst().getId(), + processInstancesList.getLast().getId() + ); Page processInstances = new PageImpl<>(processInstancesList); Pageable pageable = PageRequest.of(0, 10); - List subprocessesList = new ProcessInstanceHelper().createSubprocessInstances(2, - processInstancesList.get(0).getId()); - subprocessesList.addAll(new ProcessInstanceHelper().createSubprocessInstances(3, processInstancesList.get(1).getId())); + List subprocessesList = new ProcessInstanceHelper() + .createSubprocessInstances(2, processInstancesList.get(0).getId()); + subprocessesList.addAll( + new ProcessInstanceHelper().createSubprocessInstances(3, processInstancesList.get(1).getId()) + ); QProcessInstanceEntity processInstanceEntity = QProcessInstanceEntity.processInstanceEntity; @@ -185,7 +197,8 @@ void testMapSubprocesses() { void testMapSubprocessesForProcessInstance() { ProcessInstanceEntity entity = new ProcessInstanceHelper().createProcessInstance("1"); String parentId = entity.getId(); - List expectedSubprocesses = new ProcessInstanceHelper().createSubprocessInstances(2, parentId); + List expectedSubprocesses = new ProcessInstanceHelper() + .createSubprocessInstances(2, parentId); QProcessInstanceEntity processInstanceEntity = QProcessInstanceEntity.processInstanceEntity; diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/utils/ProcessInstanceHelper.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/utils/ProcessInstanceHelper.java index dbdd6d84c5..55f63ef320 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/utils/ProcessInstanceHelper.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/test/java/org/activiti/cloud/services/query/app/repository/utils/ProcessInstanceHelper.java @@ -15,13 +15,13 @@ */ package org.activiti.cloud.services.query.app.repository.utils; -import org.activiti.cloud.services.query.model.ProcessInstanceEntity; - import java.util.ArrayList; import java.util.List; import java.util.UUID; +import org.activiti.cloud.services.query.model.ProcessInstanceEntity; public class ProcessInstanceHelper { + public ProcessInstanceEntity createProcessInstance(String parentId) { ProcessInstanceEntity entity = new ProcessInstanceEntity(); entity.setId(UUID.randomUUID().toString()); diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/repos/CustomizedProcessInstanceRepositoryImplIT.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/repos/CustomizedProcessInstanceRepositoryImplIT.java index 6f1ca04357..a9670ce2a5 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/repos/CustomizedProcessInstanceRepositoryImplIT.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/repos/CustomizedProcessInstanceRepositoryImplIT.java @@ -16,7 +16,11 @@ package org.activiti.cloud.repos; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.persistence.EntityManager; +import java.util.ArrayList; +import java.util.List; import org.activiti.QueryRestTestApplication; import org.activiti.cloud.services.query.app.repository.CustomizedProcessInstanceRepositoryImpl; import org.activiti.cloud.services.query.app.repository.ProcessInstanceRepository; @@ -37,11 +41,6 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - @SpringBootTest( classes = { QueryRestTestApplication.class }, properties = { @@ -54,6 +53,7 @@ @Testcontainers @Transactional class CustomizedProcessInstanceRepositoryImplIT { + @Container @ServiceConnection static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:15-alpine"); @@ -78,34 +78,41 @@ void testMapSubprocessesForPage() { List processInstancesList = buildDefaultProcessInstances(3); String parentId1 = processInstancesList.getFirst().getId(); List subprocesses1 = buildDefaultProcessInstances(2); - setSubprocesses(subprocesses1,parentId1); + setSubprocesses(subprocesses1, parentId1); String parentId2 = processInstancesList.getLast().getId(); List subprocesses2 = buildDefaultProcessInstances(3); - setSubprocesses(subprocesses2,parentId2); + setSubprocesses(subprocesses2, parentId2); entityManager.flush(); - Page processInstances = new PageImpl<>(processInstancesList, pageable, processInstancesList.size()); + Page processInstances = new PageImpl<>( + processInstancesList, + pageable, + processInstancesList.size() + ); Page result = repository.mapSubprocesses(processInstances, pageable); assertNotNull(result); assertEquals(3, result.getTotalElements()); - ProcessInstanceEntity parentInstance1 = result.getContent().stream() + ProcessInstanceEntity parentInstance1 = result + .getContent() + .stream() .filter(instance -> instance.getId().equals(parentId1)) .findFirst() .orElse(null); assertNotNull(parentInstance1); assertEquals(2, parentInstance1.getSubprocesses().size()); - ProcessInstanceEntity parentInstance2 = result.getContent().stream() + ProcessInstanceEntity parentInstance2 = result + .getContent() + .stream() .filter(instance -> instance.getId().equals(parentId2)) .findFirst() .orElse(null); assertNotNull(parentInstance2); assertEquals(3, parentInstance2.getSubprocesses().size()); - } @Test @@ -114,7 +121,7 @@ void testMapSubprocessesForProcessInstance() { List subprocesses = buildDefaultProcessInstances(2); ProcessInstanceEntity entity = processInstances.getFirst(); String parentId = entity.getId(); - setSubprocesses(subprocesses,parentId); + setSubprocesses(subprocesses, parentId); ProcessInstanceEntity result = repository.mapSubprocesses(entity); @@ -124,15 +131,15 @@ void testMapSubprocessesForProcessInstance() { private List buildDefaultProcessInstances(int count) { List entities = new ArrayList<>(); - for(int i=1;i<=count;i++ ){ + for (int i = 1; i <= count; i++) { entities.add(new ProcessInstanceTestUtils().buildProcessInstanceEntity()); } processInstanceRepository.saveAll(entities); return entities; } - private void setSubprocesses(List subprocesses,String parentId){ - for(ProcessInstanceEntity subprocess:subprocesses){ + private void setSubprocesses(List subprocesses, String parentId) { + for (ProcessInstanceEntity subprocess : subprocesses) { subprocess.setParentId(parentId); processInstanceRepository.save(subprocess); }