Skip to content

Commit 6a536f2

Browse files
committed
Merge upstream/main and preserve excluded paths
2 parents 7ae4b75 + 4cae8ad commit 6a536f2

File tree

55 files changed

+623
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+623
-150
lines changed

apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-common/src/test/java/org/kie/kogito/index/AbstractProcessDataIndexIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
import static org.hamcrest.CoreMatchers.notNullValue;
5353
import static org.hamcrest.CoreMatchers.nullValue;
5454
import static org.hamcrest.Matchers.greaterThan;
55-
import static org.junit.Assert.assertEquals;
56-
import static org.junit.Assert.assertTrue;
55+
import static org.junit.jupiter.api.Assertions.assertEquals;
56+
import static org.junit.jupiter.api.Assertions.assertTrue;
5757

5858
public abstract class AbstractProcessDataIndexIT {
5959

apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</dependency>
5454
<dependency>
5555
<groupId>org.testcontainers</groupId>
56-
<artifactId>kafka</artifactId>
56+
<artifactId>testcontainers-kafka</artifactId>
5757
<version>${version.org.testcontainers}</version>
5858
<scope>compile</scope>
5959
</dependency>

data-index/data-index-common-addons/src/main/java/org/kie/kogito/index/addon/api/KogitoAddonRuntimeClient.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,29 @@ public CompletableFuture<List<Node>> getProcessDefinitionNodes(String serviceURL
202202

203203
@Override
204204
public CompletableFuture<List<Timer>> getProcessInstanceTimers(String serviceUrl, ProcessInstance processInstance) {
205-
return CompletableFuture.completedFuture(executeOnProcessInstance(processInstance.getProcessId(), processInstance.getId(), pInstance -> {
205+
206+
Process<?> process = processes != null ? processes.processById(processInstance.getProcessId()) : null;
207+
208+
if (process == null) {
209+
throw new DataIndexServiceException(
210+
String.format("Cannot get timers for process instance '%s': process with id '%s' cannot be found", processInstance.getId(), processInstance.getProcessId()));
211+
}
212+
213+
Optional<? extends org.kie.kogito.process.ProcessInstance<?>> foundProcessInstanceOptional = process.instances().findById(processInstance.getId());
214+
if (foundProcessInstanceOptional.isPresent()) {
215+
org.kie.kogito.process.ProcessInstance<?> foundProcessInstance = foundProcessInstanceOptional.get();
206216
try {
207-
return pInstance.timers().stream()
217+
List<Timer> timers = foundProcessInstance.timers().stream()
208218
.map(Timer::from)
209219
.toList();
220+
return CompletableFuture.completedFuture(timers);
210221
} catch (Exception ex) {
211-
throw new DataIndexServiceException("Failure getting timers for process instance " + pInstance.id(), ex);
222+
throw new DataIndexServiceException(String.format("Failure getting timers for process instance '%s'", processInstance.getId()), ex);
212223
}
213-
}));
224+
} else {
225+
throw new DataIndexServiceException(
226+
String.format("Cannot get timers for process instance '%s': instance cannot be found in process '%s'", processInstance.getId(), processInstance.getProcessId()));
227+
}
214228
}
215229

216230
private static Map<String, String> mapMetadata(org.kie.api.definition.process.Node n) {

data-index/data-index-graphql/src/main/resources/graphql/basic.schema.graphqls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ type Attachment {
386386

387387
type UserTaskInstance {
388388
id: String!
389+
userTaskId: String
389390
description: String
390391
name: String
391392
priority: String
@@ -437,6 +438,10 @@ input UserTaskInstanceArgument {
437438
comments: CommentArgument
438439
attachments: AttachmentArgument
439440
slaDueDate: DateArgument
441+
rootProcessInstanceId: StringArgument
442+
rootProcessId: StringArgument
443+
externalReferenceId: StringArgument
444+
endpoint: StringArgument
440445
}
441446

442447
input CommentArgument {

data-index/data-index-quarkus/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@
101101
<version>${version.io.quarkus}</version>
102102
</path>
103103
</annotationProcessorPaths>
104-
<compilerArgs>
105-
<arg>-AlegacyConfigRoot=true</arg>
106-
</compilerArgs>
107104
</configuration>
108105
</plugin>
109106
</plugins>

data-index/data-index-quarkus/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/test/java/org/kie/kogito/index/addon/api/KogitoAddonRuntimeClientImplTest.java

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,25 @@
1919
package org.kie.kogito.index.addon.api;
2020

2121
import java.nio.Buffer;
22-
import java.util.List;
23-
import java.util.Map;
24-
import java.util.Optional;
22+
import java.util.*;
2523
import java.util.concurrent.CompletableFuture;
2624

2725
import org.eclipse.microprofile.context.ManagedExecutor;
26+
import org.jbpm.workflow.instance.WorkflowProcessInstance;
2827
import org.junit.jupiter.api.BeforeEach;
2928
import org.junit.jupiter.api.Test;
3029
import org.junit.jupiter.api.extension.ExtendWith;
3130
import org.kie.kogito.Application;
3231
import org.kie.kogito.index.addon.api.models.TestModel;
3332
import org.kie.kogito.index.api.ExecuteArgs;
3433
import org.kie.kogito.index.model.*;
34+
import org.kie.kogito.index.model.Timer;
3535
import org.kie.kogito.index.service.DataIndexServiceException;
3636
import org.kie.kogito.index.service.KogitoRuntimeCommonClient;
3737
import org.kie.kogito.index.service.auth.DataIndexAuthTokenReader;
3838
import org.kie.kogito.index.test.TestUtils;
3939
import org.kie.kogito.jackson.utils.ObjectMapperFactory;
40+
import org.kie.kogito.jobs.TimerDescription;
4041
import org.kie.kogito.process.ProcessError;
4142
import org.kie.kogito.process.ProcessInstanceExecutionException;
4243
import org.kie.kogito.process.ProcessInstances;
@@ -166,6 +167,88 @@ private ProcessError mockProcessInstanceStatusActiveOnError() {
166167
}).when(error);
167168
}
168169

170+
@Test
171+
public void testGetProcessInstanceTimers() throws Exception {
172+
ProcessInstance pI = createProcessInstance(PROCESS_INSTANCE_ID, ACTIVE);
173+
174+
WorkflowProcessInstance workflowProcessInstance = mock(WorkflowProcessInstance.class);
175+
when(workflowProcessInstance.getProcessId()).thenReturn(pI.getProcessId());
176+
when(workflowProcessInstance.getId()).thenReturn(pI.getId());
177+
178+
List<TimerDescription> timers = new ArrayList<>();
179+
timers.add(TimerDescription.Builder
180+
.ofProcessInstance(workflowProcessInstance)
181+
.timerId("timerId")
182+
.timerDescription("SLA")
183+
.build());
184+
185+
when(processInstance.timers()).thenReturn(timers);
186+
187+
CompletableFuture<List<Timer>> result = client.getProcessInstanceTimers(SERVICE_URL, pI);
188+
189+
verify(processes, times(1)).processById(anyString());
190+
verify(instances, times(1)).findById(anyString());
191+
verify(processInstance, times(1)).timers();
192+
193+
assertThat(result).isNotNull()
194+
.isDone();
195+
196+
assertThat(result.get())
197+
.hasSize(1)
198+
.element(0)
199+
.hasFieldOrPropertyWithValue("processId", pI.getProcessId())
200+
.hasFieldOrPropertyWithValue("processInstanceId", pI.getId())
201+
.hasFieldOrPropertyWithValue("timerId", "timerId")
202+
.hasFieldOrPropertyWithValue("description", "SLA");
203+
}
204+
205+
@Test
206+
public void testGetProcessInstanceTimersErrorWithWrongProcessId() {
207+
ProcessInstance pI = createProcessInstance(PROCESS_INSTANCE_ID, ACTIVE);
208+
209+
when(processes.processById(anyString())).thenReturn(null);
210+
211+
assertThatThrownBy(() -> client.getProcessInstanceTimers(SERVICE_URL, pI))
212+
.isInstanceOf(DataIndexServiceException.class)
213+
.hasMessage("Cannot get timers for process instance 'pId': process with id 'travels' cannot be found");
214+
215+
verify(processes, times(1)).processById(anyString());
216+
verify(instances, never()).findById(anyString());
217+
verify(processInstance, never()).timers();
218+
}
219+
220+
@Test
221+
public void testGetProcessInstanceTimersErrorWithWrongProcessInstanceId() {
222+
ProcessInstance pI = createProcessInstance(PROCESS_INSTANCE_ID, ACTIVE);
223+
224+
when(instances.findById(anyString())).thenReturn(Optional.empty());
225+
226+
assertThatThrownBy(() -> client.getProcessInstanceTimers(SERVICE_URL, pI))
227+
.isInstanceOf(DataIndexServiceException.class)
228+
.hasMessage("Cannot get timers for process instance 'pId': instance cannot be found in process 'travels'");
229+
230+
verify(processes, times(1)).processById(anyString());
231+
verify(instances, times(1)).findById(anyString());
232+
verify(processInstance, never()).timers();
233+
}
234+
235+
@Test
236+
public void testGetProcessInstanceTimersErrorWithUnexpectedErrorGettingTimers() {
237+
ProcessInstance pI = createProcessInstance(PROCESS_INSTANCE_ID, ACTIVE);
238+
239+
when(processInstance.timers()).thenThrow(new RuntimeException("Something went wrong"));
240+
241+
assertThatThrownBy(() -> client.getProcessInstanceTimers(SERVICE_URL, pI))
242+
.isInstanceOf(DataIndexServiceException.class)
243+
.hasMessage("Failure getting timers for process instance 'pId'")
244+
.hasRootCauseInstanceOf(RuntimeException.class)
245+
.hasRootCauseMessage("Something went wrong");
246+
247+
verify(processes, times(1)).processById(anyString());
248+
verify(instances, times(1)).findById(anyString());
249+
verify(processInstance, times(1)).timers();
250+
}
251+
169252
@Test
170253
void testExecuteAfterSuccess() {
171254
ProcessDefinition definition = new ProcessDefinition();

data-index/data-index-quarkus/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
<version>${version.io.quarkus}</version>
6060
</path>
6161
</annotationProcessorPaths>
62-
<compilerArgs>
63-
<arg>-AlegacyConfigRoot=true</arg>
64-
</compilerArgs>
6562
</configuration>
6663
</plugin>
6764
</plugins>

data-index/data-index-quarkus/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@
7878
<version>${version.io.quarkus}</version>
7979
</path>
8080
</annotationProcessorPaths>
81-
<compilerArgs>
82-
<arg>-AlegacyConfigRoot=true</arg>
83-
</compilerArgs>
8481
</configuration>
8582
</plugin>
8683
</plugins>

data-index/data-index-quarkus/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-mongodb/deployment/pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
<dependency>
4242
<groupId>io.quarkus</groupId>
4343
<artifactId>quarkus-mongodb-client-deployment</artifactId>
44+
<exclusions>
45+
<exclusion>
46+
<groupId>org.testcontainers</groupId>
47+
<artifactId>mongodb</artifactId>
48+
</exclusion>
49+
</exclusions>
50+
</dependency>
51+
<!-- This brings in the 2.x version of testcontainers mongodb module. -->
52+
<dependency>
53+
<groupId>org.testcontainers</groupId>
54+
<artifactId>testcontainers-mongodb</artifactId>
4455
</dependency>
4556
</dependencies>
4657
<build>
@@ -55,9 +66,6 @@
5566
<version>${version.io.quarkus}</version>
5667
</path>
5768
</annotationProcessorPaths>
58-
<compilerArgs>
59-
<arg>-AlegacyConfigRoot=true</arg>
60-
</compilerArgs>
6169
</configuration>
6270
</plugin>
6371
</plugins>

data-index/data-index-quarkus/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-mongodb/runtime/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
<version>${version.io.quarkus}</version>
7575
</path>
7676
</annotationProcessorPaths>
77-
<compilerArgs>
78-
<arg>-AlegacyConfigRoot=true</arg>
79-
</compilerArgs>
8077
</configuration>
8178
</plugin>
8279
</plugins>

0 commit comments

Comments
 (0)