19
19
import static org .assertj .core .api .Assertions .tuple ;
20
20
import static org .mockito .Mockito .when ;
21
21
22
- import java .util .Calendar ;
22
+ import java .time .Instant ;
23
+ import java .time .temporal .ChronoUnit ;
23
24
import java .util .Collections ;
25
+ import java .util .Date ;
24
26
import java .util .List ;
25
27
import java .util .Map ;
26
28
@@ -77,12 +79,12 @@ public class TaskResourceTest extends BaseSpringRestTestCase {
77
79
*/
78
80
@ CmmnDeployment (resources = { "org/flowable/cmmn/rest/service/api/repository/oneHumanTaskCase.cmmn" })
79
81
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 ));
82
84
83
85
CaseInstance caseInstance = runtimeService .createCaseInstanceBuilder ().caseDefinitionKey ("oneHumanTaskCase" ).start ();
84
86
Task task = taskService .createTaskQuery ().caseInstanceId (caseInstance .getId ()).singleResult ();
85
- taskService .setDueDate (task .getId (), now . getTime ( ));
87
+ taskService .setDueDate (task .getId (), Date . from ( now ));
86
88
taskService .setOwner (task .getId (), "owner" );
87
89
task = taskService .createTaskQuery ().caseInstanceId (caseInstance .getId ()).singleResult ();
88
90
assertThat (task ).isNotNull ();
@@ -120,8 +122,8 @@ public void testGetCaseTask() throws Exception {
120
122
public void testGetProcessAdhoc () throws Exception {
121
123
try {
122
124
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 ));
125
127
126
128
Task parentTask = taskService .newTask ();
127
129
taskService .saveTask (parentTask );
@@ -133,7 +135,7 @@ public void testGetProcessAdhoc() throws Exception {
133
135
task .setAssignee ("kermit" );
134
136
task .setDelegationState (DelegationState .RESOLVED );
135
137
task .setDescription ("Description" );
136
- task .setDueDate (now . getTime ( ));
138
+ task .setDueDate (Date . from ( now ));
137
139
task .setOwner ("owner" );
138
140
task .setPriority (20 );
139
141
taskService .saveTask (task );
@@ -177,7 +179,7 @@ public void testGetProcessAdhoc() throws Exception {
177
179
*/
178
180
public void testUpdateTaskNoOverrides () throws Exception {
179
181
try {
180
- Calendar now = Calendar . getInstance ();
182
+ Instant now = Instant . now ();
181
183
Task parentTask = taskService .newTask ();
182
184
taskService .saveTask (parentTask );
183
185
@@ -188,7 +190,7 @@ public void testUpdateTaskNoOverrides() throws Exception {
188
190
task .setAssignee ("kermit" );
189
191
task .setDelegationState (DelegationState .RESOLVED );
190
192
task .setDescription ("Description" );
191
- task .setDueDate (now . getTime ( ));
193
+ task .setDueDate (Date . from ( now ));
192
194
task .setOwner ("owner" );
193
195
task .setPriority (20 );
194
196
taskService .saveTask (task );
@@ -207,7 +209,7 @@ public void testUpdateTaskNoOverrides() throws Exception {
207
209
assertThat (task .getOwner ()).isEqualTo ("owner" );
208
210
assertThat (task .getPriority ()).isEqualTo (20 );
209
211
assertThat (task .getDelegationState ()).isEqualTo (DelegationState .RESOLVED );
210
- assertThat (task .getDueDate ()).isEqualTo (now . getTime () );
212
+ assertThat (task .getDueDate ()).isEqualTo (now );
211
213
assertThat (task .getParentTaskId ()).isEqualTo (parentTask .getId ());
212
214
213
215
} finally {
@@ -232,8 +234,8 @@ public void testUpdateTask() throws Exception {
232
234
233
235
ObjectNode requestNode = objectMapper .createObjectNode ();
234
236
235
- Calendar dueDate = Calendar . getInstance ();
236
- String dueDateString = getISODateString (dueDate . getTime ( ));
237
+ Instant dueDate = Instant . now ();
238
+ String dueDateString = getISODateString (Date . from ( dueDate ));
237
239
238
240
requestNode .put ("name" , "New task name" );
239
241
requestNode .put ("description" , "New task description" );
0 commit comments