Skip to content

Commit

Permalink
refactor(engine): Rename CREATION_DATE to CreateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
psavidis committed Nov 7, 2023
1 parent 75fc444 commit e278542
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface ExternalTask {
* @return the absolute time at which the task was created
* @return
*/
Date getCreationDate();
Date getCreateTime();

/**
* @return the id of the process instance the task exists in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ protected HistoricExternalTaskLogEntity initHistoricExternalTaskLog(ExternalTask
}

protected Date getTimestamp(ExternalTaskEntity entity, ExternalTaskState state) {
return state == ExternalTaskState.CREATED ? entity.getCreationDate() : ClockUtil.getCurrentTime();
return state == ExternalTaskState.CREATED ? entity.getCreateTime() : ClockUtil.getCurrentTime();
}

protected boolean isRootProcessInstance(HistoricProcessInstanceEventEntity evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class ExternalTaskEntity implements ExternalTask, DbEntity,
protected String topicName;
protected String workerId;
protected Date lockExpirationTime;
protected Date creationDate;
protected Date createTime;
protected Integer retries;
protected String errorMessage;

Expand Down Expand Up @@ -130,12 +130,12 @@ public void setLockExpirationTime(Date lockExpirationTime) {
}

@Override
public Date getCreationDate() {
return creationDate;
public Date getCreateTime() {
return createTime;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

@Override
Expand Down Expand Up @@ -576,7 +576,7 @@ public static ExternalTaskEntity createAndInsert(ExecutionEntity execution, Stri
externalTask.setActivityInstanceId(execution.getActivityInstanceId());
externalTask.setTenantId(execution.getTenantId());
externalTask.setPriority(priority);
externalTask.setCreationDate(ClockUtil.getCurrentTime());
externalTask.setCreateTime(ClockUtil.getCurrentTime());

ProcessDefinitionEntity processDefinition = execution.getProcessDefinition();
externalTask.setProcessDefinitionKey(processDefinition.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<result property="errorDetailsByteArrayId" column="ERROR_DETAILS_ID_" jdbcType="VARCHAR" />

<result property="lockExpirationTime" column="LOCK_EXP_TIME_" jdbcType="TIMESTAMP"/>
<result property="creationDate" column="CREATION_DATE_" jdbcType="TIMESTAMP"/>
<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP"/>
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER" />
<result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
Expand All @@ -58,7 +58,7 @@
WORKER_ID_,
TOPIC_NAME_,
LOCK_EXP_TIME_,
CREATION_DATE_,
CREATE_TIME_,
RETRIES_,
ERROR_MSG_,
ERROR_DETAILS_ID_,
Expand All @@ -78,7 +78,7 @@
#{workerId, jdbcType=VARCHAR},
#{topicName, jdbcType=VARCHAR},
#{lockExpirationTime, jdbcType=TIMESTAMP},
#{creationDate, jdbcType=TIMESTAMP},
#{createTime, jdbcType=TIMESTAMP},
#{retries, jdbcType=INTEGER},
#{errorMessage, jdbcType=VARCHAR},
#{errorDetailsByteArrayId, jdbcType=VARCHAR},
Expand Down Expand Up @@ -445,7 +445,7 @@
RES.TOPIC_NAME_,
RES.WORKER_ID_,
RES.LOCK_EXP_TIME_,
RES.CREATION_DATE_,
RES.CREATE_TIME_,
RES.RETRIES_,
RES.ERROR_MSG_,
RES.ERROR_DETAILS_ID_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.junit.rules.RuleChain;

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public class ExternalTaskQueryByCreationDateTest {
public class ExternalTaskQueryByCreateTimeTest {

public ProcessEngineRule engineRule = new ProvidedProcessEngineRule();
public ProcessEngineTestRule testHelper = new ProcessEngineTestRule(engineRule);
Expand Down Expand Up @@ -74,7 +74,7 @@ public void init() {
}

@Test
public void shouldHaveNonNullCreationDate() {
public void shouldHaveNonNullCreateTime() {
// given
runtimeService.startProcessInstanceByKey("process1");

Expand All @@ -85,11 +85,11 @@ public void shouldHaveNonNullCreationDate() {

// then
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0).getCreationDate()).isNotNull();
assertThat(result.get(0).getCreateTime()).isNotNull();
}

@Test
public void shouldProduceEventWithCreationDateValue() {
public void shouldProduceEventWithCreateTimeValue() {
// given
runtimeService.startProcessInstanceByKey("process1");

Expand All @@ -105,7 +105,7 @@ public void shouldProduceEventWithCreationDateValue() {
var historyEventTimestamp = result.get(0).getTimestamp();

// then
assertThat(extTask.getCreationDate()).isEqualTo(historyEventTimestamp);
assertThat(extTask.getCreateTime()).isEqualTo(historyEventTimestamp);
}

@Test
Expand All @@ -117,7 +117,7 @@ public void shouldReturnTasksInDescOrder() {
var result = engineRule.getExternalTaskService()
.createExternalTaskQuery()
// when
.orderByCreationDate().desc()
.orderByCreateTime().desc()
.list();

assertThat(result.size()).isEqualTo(2);
Expand All @@ -126,8 +126,8 @@ public void shouldReturnTasksInDescOrder() {
var extTask2 = result.get(1);

// then
assertThat(extTask2.getCreationDate())
.isBefore(extTask1.getCreationDate());
assertThat(extTask2.getCreateTime())
.isBefore(extTask1.getCreateTime());
}

@Test
Expand All @@ -139,7 +139,7 @@ public void shouldReturnTasksInAscOrder() {
var result = engineRule.getExternalTaskService()
.createExternalTaskQuery()
// when
.orderByCreationDate().asc()
.orderByCreateTime().asc()
.list();

assertThat(result.size()).isEqualTo(2);
Expand All @@ -148,14 +148,14 @@ public void shouldReturnTasksInAscOrder() {
var extTask2 = result.get(1);

// then
assertThat(extTask1.getCreationDate())
.isBefore(extTask2.getCreationDate());
assertThat(extTask1.getCreateTime())
.isBefore(extTask2.getCreateTime());
}

// Multi-Level Sorting with CreationDate & Priority
// Multi-Level Sorting with CreateTime & Priority

@Test
public void shouldReturnTasksInCreationDateAscOrderOnPriorityEquality() {
public void shouldReturnTasksInCreateTimeAscOrderOnPriorityEquality() {
// given
startProcessInstanceAfter("process1", 1);
startProcessInstanceAfter("process2", 1);
Expand All @@ -166,7 +166,7 @@ public void shouldReturnTasksInCreationDateAscOrderOnPriorityEquality() {
.createExternalTaskQuery()
// when
.orderByPriority().desc()
.orderByCreationDate().asc()
.orderByCreateTime().asc()

.list();

Expand All @@ -180,7 +180,7 @@ public void shouldReturnTasksInCreationDateAscOrderOnPriorityEquality() {
}

@Test
public void shouldReturnTasksInCreationDateDescOrderOnPriorityEquality() {
public void shouldReturnTasksInCreateTimeDescOrderOnPriorityEquality() {
// given
startProcessInstanceAfter("process1", 1);
startProcessInstanceAfter("process2", 1);
Expand All @@ -191,7 +191,7 @@ public void shouldReturnTasksInCreationDateDescOrderOnPriorityEquality() {
.createExternalTaskQuery()
// when
.orderByPriority().desc()
.orderByCreationDate().desc()
.orderByCreateTime().desc()

.list();

Expand All @@ -200,12 +200,12 @@ public void shouldReturnTasksInCreationDateDescOrderOnPriorityEquality() {
// then
assertThat(result.get(0).getActivityId()).isEqualTo("task1"); // due to priority DESC
assertThat(result.get(1).getActivityId()).isEqualTo("task2");
assertThat(result.get(2).getActivityId()).isEqualTo("task4"); // due to creationDate DESC
assertThat(result.get(2).getActivityId()).isEqualTo("task4"); // due to CreateTime DESC
assertThat(result.get(3).getActivityId()).isEqualTo("task3");
}

@Test
public void shouldReturnTasksInPriorityAscOnCreationDateEquality() {
public void shouldReturnTasksInPriorityAscOnCreateTimeEquality() {
var now = ClockTestUtil.setClockToDateWithoutMilliseconds();

// given
Expand All @@ -218,23 +218,23 @@ public void shouldReturnTasksInPriorityAscOnCreationDateEquality() {
var result = engineRule.getExternalTaskService()
.createExternalTaskQuery()
// when
.orderByCreationDate().asc()
.orderByCreateTime().asc()
.orderByPriority().asc()

.list();

assertThat(result.size()).isEqualTo(4);

// then
assertThat(result.get(0).getActivityId()).isEqualTo("task2"); // due to creationDate Equality, priority ASC
assertThat(result.get(0).getActivityId()).isEqualTo("task2"); // due to CreateTime Equality, priority ASC
assertThat(result.get(1).getActivityId()).isEqualTo("task1");

assertThat(result.get(2).getActivityId()).isEqualTo("task3");
assertThat(result.get(3).getActivityId()).isEqualTo("task4");
}

@Test
public void shouldReturnTasksInPriorityDescOnCreationDateEquality() {
public void shouldReturnTasksInPriorityDescOnCreateTimeEquality() {
var now = ClockTestUtil.setClockToDateWithoutMilliseconds();

// given
Expand All @@ -247,15 +247,15 @@ public void shouldReturnTasksInPriorityDescOnCreationDateEquality() {
var result = engineRule.getExternalTaskService()
.createExternalTaskQuery()
// when
.orderByCreationDate().asc()
.orderByCreateTime().asc()
.orderByPriority().desc()

.list();

assertThat(result.size()).isEqualTo(4);

// then
assertThat(result.get(0).getActivityId()).isEqualTo("task1"); // due to creationDate equality, priority DESC
assertThat(result.get(0).getActivityId()).isEqualTo("task1"); // due to CreateTime equality, priority DESC
assertThat(result.get(1).getActivityId()).isEqualTo("task2");

assertThat(result.get(2).getActivityId()).isEqualTo("task3");
Expand Down

0 comments on commit e278542

Please sign in to comment.