Skip to content

Commit

Permalink
Use truncated time to seconds in tests to avoid SQL Server truncation…
Browse files Browse the repository at this point in the history
… failures
  • Loading branch information
filiphr committed Aug 14, 2024
1 parent 996056a commit 791d14f
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

import java.util.Calendar;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -64,12 +66,12 @@ public class HistoricTaskInstanceResourceTest extends BaseSpringRestTestCase {
@CmmnDeployment(resources = { "org/flowable/cmmn/rest/service/api/repository/oneHumanTaskCase.cmmn" })
public void testGetCaseTask() throws Exception {
if (cmmnEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
Calendar now = Calendar.getInstance();
cmmnEngineConfiguration.getClock().setCurrentTime(now.getTime());
Instant now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
cmmnEngineConfiguration.getClock().setCurrentTime(Date.from(now));

CaseInstance caseInstance = runtimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start();
Task task = taskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
taskService.setDueDate(task.getId(), now.getTime());
taskService.setDueDate(task.getId(), Date.from(now));
taskService.setOwner(task.getId(), "owner");
task = taskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
assertThat(task).isNotNull();
Expand Down Expand Up @@ -109,8 +111,8 @@ public void testGetTaskAdhoc() throws Exception {
if (cmmnEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
try {

Calendar now = Calendar.getInstance();
cmmnEngineConfiguration.getClock().setCurrentTime(now.getTime());
Instant now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
cmmnEngineConfiguration.getClock().setCurrentTime(Date.from(now));

Task parentTask = taskService.newTask();
taskService.saveTask(parentTask);
Expand All @@ -122,7 +124,7 @@ public void testGetTaskAdhoc() throws Exception {
task.setAssignee("kermit");
task.setDelegationState(DelegationState.RESOLVED);
task.setDescription("Description");
task.setDueDate(now.getTime());
task.setDueDate(Date.from(now));
task.setOwner("owner");
task.setPriority(20);
taskService.saveTask(task);
Expand Down

0 comments on commit 791d14f

Please sign in to comment.