18
18
import static org .assertj .core .api .Assertions .tuple ;
19
19
import static org .mockito .Mockito .when ;
20
20
21
+ import java .time .Instant ;
22
+ import java .time .temporal .ChronoUnit ;
21
23
import java .util .Calendar ;
22
24
import java .util .Collections ;
25
+ import java .util .Date ;
23
26
import java .util .List ;
24
27
import java .util .Map ;
25
28
@@ -98,12 +101,12 @@ public void resetMocks() {
98
101
@ Test
99
102
@ Deployment
100
103
public void testGetProcessTask () throws Exception {
101
- Calendar now = Calendar . getInstance ( );
102
- processEngineConfiguration .getClock ().setCurrentTime (now . getTime ( ));
104
+ Instant now = Instant . now (). truncatedTo ( ChronoUnit . SECONDS );
105
+ processEngineConfiguration .getClock ().setCurrentTime (Date . from ( now ));
103
106
104
107
ProcessInstance processInstance = runtimeService .startProcessInstanceByKey ("oneTaskProcess" );
105
108
Task task = taskService .createTaskQuery ().processInstanceId (processInstance .getId ()).singleResult ();
106
- taskService .setDueDate (task .getId (), now . getTime ( ));
109
+ taskService .setDueDate (task .getId (), Date . from ( now ));
107
110
taskService .setOwner (task .getId (), "owner" );
108
111
task = taskService .createTaskQuery ().processInstanceId (processInstance .getId ()).singleResult ();
109
112
assertThat (task ).isNotNull ();
@@ -152,8 +155,8 @@ public void testGetProcessTask() throws Exception {
152
155
public void testGetProcessAdhoc () throws Exception {
153
156
try {
154
157
155
- Calendar now = Calendar . getInstance ( );
156
- processEngineConfiguration .getClock ().setCurrentTime (now . getTime ( ));
158
+ Instant now = Instant . now (). truncatedTo ( ChronoUnit . SECONDS );
159
+ processEngineConfiguration .getClock ().setCurrentTime (Date . from ( now ));
157
160
158
161
Task parentTask = taskService .newTask ();
159
162
taskService .saveTask (parentTask );
@@ -165,7 +168,7 @@ public void testGetProcessAdhoc() throws Exception {
165
168
task .setAssignee ("kermit" );
166
169
task .setDelegationState (DelegationState .RESOLVED );
167
170
task .setDescription ("Description" );
168
- task .setDueDate (now . getTime ( ));
171
+ task .setDueDate (Date . from ( now ));
169
172
task .setOwner ("owner" );
170
173
task .setPriority (20 );
171
174
taskService .saveTask (task );
@@ -211,7 +214,7 @@ public void testGetProcessAdhoc() throws Exception {
211
214
@ Test
212
215
public void testUpdateTaskNoOverrides () throws Exception {
213
216
try {
214
- Calendar now = Calendar . getInstance ( );
217
+ Instant now = Instant . now (). truncatedTo ( ChronoUnit . SECONDS );
215
218
Task parentTask = taskService .newTask ();
216
219
taskService .saveTask (parentTask );
217
220
@@ -222,7 +225,7 @@ public void testUpdateTaskNoOverrides() throws Exception {
222
225
task .setAssignee ("kermit" );
223
226
task .setDelegationState (DelegationState .RESOLVED );
224
227
task .setDescription ("Description" );
225
- task .setDueDate (now . getTime ( ));
228
+ task .setDueDate (Date . from ( now ));
226
229
task .setOwner ("owner" );
227
230
task .setPriority (20 );
228
231
taskService .saveTask (task );
@@ -241,7 +244,7 @@ public void testUpdateTaskNoOverrides() throws Exception {
241
244
assertThat (task .getOwner ()).isEqualTo ("owner" );
242
245
assertThat (task .getPriority ()).isEqualTo (20 );
243
246
assertThat (task .getDelegationState ()).isEqualTo (DelegationState .RESOLVED );
244
- assertThat (task .getDueDate ()).isEqualTo (now . getTime ( ));
247
+ assertThat (task .getDueDate ()).isEqualTo (Date . from ( now ));
245
248
assertThat (task .getParentTaskId ()).isEqualTo (parentTask .getId ());
246
249
247
250
} finally {
0 commit comments