Skip to content

Commit 5f5f5ba

Browse files
committed
Oracle and SQL Server test adjustments
* Split event registry DeploymentCollectionResourceTest to test sorting and querying separately * Use truncated time for CMMN TaskResourceTest to avoid the differences that SQL server has in the milliseconds * Make sure that surefire reports are uploaded when tests fail
1 parent a289991 commit 5f5f5ba

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

.github/workflows/oracle.yml

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
distribution: 'zulu'
5151
java-version: 17
5252
- name: Test
53+
id: test
5354
# use oracle for the host here because we have specified a container for the job.
5455
# If we were running the job on the VM this would be localhost
5556
# '>-' is a special YAML syntax and means that new lines would be replaced with spaces
@@ -71,6 +72,7 @@ jobs:
7172
-Dmaven.test.redirectTestOutputToFile=false
7273
- name: Upload test artifacts
7374
uses: actions/upload-artifact@v4
75+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
7476
with:
7577
name: surefire-test-reports
7678
path: '**/target/surefire-reports/*'

.github/workflows/sql-server.yml

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
distribution: 'zulu'
5050
java-version: 17
5151
- name: Test
52+
id: test
5253
# use localhost for the host here because we have specified a vm for the job.
5354
# If we were running the job on a container this would be mssql
5455
# '>-' is a special YAML syntax and means that new lines would be replaced with spaces
@@ -68,6 +69,7 @@ jobs:
6869
-Dmaven.test.redirectTestOutputToFile=false
6970
- name: Upload test artifacts
7071
uses: actions/upload-artifact@v4
72+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
7173
with:
7274
name: surefire-test-reports
7375
path: '**/target/surefire-reports/*'

modules/flowable-cmmn-rest/src/test/java/org/flowable/cmmn/rest/service/api/runtime/TaskResourceTest.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import static org.assertj.core.api.Assertions.tuple;
2020
import static org.mockito.Mockito.when;
2121

22-
import java.util.Calendar;
22+
import java.time.Instant;
23+
import java.time.temporal.ChronoUnit;
2324
import java.util.Collections;
25+
import java.util.Date;
2426
import java.util.List;
2527
import java.util.Map;
2628

@@ -77,12 +79,12 @@ public class TaskResourceTest extends BaseSpringRestTestCase {
7779
*/
7880
@CmmnDeployment(resources = { "org/flowable/cmmn/rest/service/api/repository/oneHumanTaskCase.cmmn" })
7981
public void testGetCaseTask() throws Exception {
80-
Calendar now = Calendar.getInstance();
81-
cmmnEngineConfiguration.getClock().setCurrentTime(now.getTime());
82+
Instant now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
83+
cmmnEngineConfiguration.getClock().setCurrentTime(Date.from(now));
8284

8385
CaseInstance caseInstance = runtimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start();
8486
Task task = taskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
85-
taskService.setDueDate(task.getId(), now.getTime());
87+
taskService.setDueDate(task.getId(), Date.from(now));
8688
taskService.setOwner(task.getId(), "owner");
8789
task = taskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
8890
assertThat(task).isNotNull();
@@ -120,8 +122,8 @@ public void testGetCaseTask() throws Exception {
120122
public void testGetProcessAdhoc() throws Exception {
121123
try {
122124

123-
Calendar now = Calendar.getInstance();
124-
cmmnEngineConfiguration.getClock().setCurrentTime(now.getTime());
125+
Instant now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
126+
cmmnEngineConfiguration.getClock().setCurrentTime(Date.from(now));
125127

126128
Task parentTask = taskService.newTask();
127129
taskService.saveTask(parentTask);
@@ -133,7 +135,7 @@ public void testGetProcessAdhoc() throws Exception {
133135
task.setAssignee("kermit");
134136
task.setDelegationState(DelegationState.RESOLVED);
135137
task.setDescription("Description");
136-
task.setDueDate(now.getTime());
138+
task.setDueDate(Date.from(now));
137139
task.setOwner("owner");
138140
task.setPriority(20);
139141
taskService.saveTask(task);
@@ -177,7 +179,7 @@ public void testGetProcessAdhoc() throws Exception {
177179
*/
178180
public void testUpdateTaskNoOverrides() throws Exception {
179181
try {
180-
Calendar now = Calendar.getInstance();
182+
Instant now = Instant.now();
181183
Task parentTask = taskService.newTask();
182184
taskService.saveTask(parentTask);
183185

@@ -188,7 +190,7 @@ public void testUpdateTaskNoOverrides() throws Exception {
188190
task.setAssignee("kermit");
189191
task.setDelegationState(DelegationState.RESOLVED);
190192
task.setDescription("Description");
191-
task.setDueDate(now.getTime());
193+
task.setDueDate(Date.from(now));
192194
task.setOwner("owner");
193195
task.setPriority(20);
194196
taskService.saveTask(task);
@@ -207,7 +209,7 @@ public void testUpdateTaskNoOverrides() throws Exception {
207209
assertThat(task.getOwner()).isEqualTo("owner");
208210
assertThat(task.getPriority()).isEqualTo(20);
209211
assertThat(task.getDelegationState()).isEqualTo(DelegationState.RESOLVED);
210-
assertThat(task.getDueDate()).isEqualTo(now.getTime());
212+
assertThat(task.getDueDate()).isEqualTo(now);
211213
assertThat(task.getParentTaskId()).isEqualTo(parentTask.getId());
212214

213215
} finally {
@@ -232,8 +234,8 @@ public void testUpdateTask() throws Exception {
232234

233235
ObjectNode requestNode = objectMapper.createObjectNode();
234236

235-
Calendar dueDate = Calendar.getInstance();
236-
String dueDateString = getISODateString(dueDate.getTime());
237+
Instant dueDate = Instant.now();
238+
String dueDateString = getISODateString(Date.from(dueDate));
237239

238240
requestNode.put("name", "New task name");
239241
requestNode.put("description", "New task description");

modules/flowable-event-registry-rest/src/test/java/org/flowable/eventregistry/rest/service/api/repository/DeploymentCollectionResourceTest.java

+31
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,37 @@ public void testGetDeployments() throws Exception {
8989
url = baseUrl + "?withoutTenantId=true";
9090
assertResultsPresentInDataResponse(url, firstDeployment.getId());
9191

92+
} finally {
93+
// Always cleanup any created deployments, even if the test failed
94+
List<EventDeployment> deployments = repositoryService.createDeploymentQuery().list();
95+
for (EventDeployment deployment : deployments) {
96+
repositoryService.deleteDeployment(deployment.getId());
97+
}
98+
}
99+
}
100+
101+
public void testGetDeploymentsSorting() throws Exception {
102+
103+
try {
104+
// Alter time to ensure different deployTimes
105+
Calendar yesterday = Calendar.getInstance();
106+
yesterday.add(Calendar.DAY_OF_MONTH, -1);
107+
eventRegistryEngineConfiguration.getClock().setCurrentTime(yesterday.getTime());
108+
109+
EventDeployment firstDeployment = repositoryService.createDeployment().name("Deployment 1").category("DEF")
110+
.addClasspathResource("org/flowable/eventregistry/rest/service/api/repository/simpleEvent.event")
111+
.tenantId("acme")
112+
.deploy();
113+
114+
eventRegistryEngineConfiguration.getClock().setCurrentTime(Calendar.getInstance().getTime());
115+
EventDeployment secondDeployment = repositoryService.createDeployment().name("Deployment 2").category("ABC")
116+
.addClasspathResource("org/flowable/eventregistry/rest/service/api/repository/simpleEvent.event")
117+
.tenantId("myTenant")
118+
.deploy();
119+
120+
String baseUrl = EventRestUrls.createRelativeResourceUrl(EventRestUrls.URL_DEPLOYMENT_COLLECTION);
121+
assertResultsPresentInDataResponse(baseUrl, firstDeployment.getId(), secondDeployment.getId());
122+
92123
// Check ordering by name
93124
CloseableHttpResponse response = executeRequest(
94125
new HttpGet(SERVER_URL_PREFIX + EventRestUrls.createRelativeResourceUrl(EventRestUrls.URL_DEPLOYMENT_COLLECTION) + "?sort=name&order=asc"),

0 commit comments

Comments
 (0)