Skip to content

Commit

Permalink
Fix code for running trigger task on demand
Browse files Browse the repository at this point in the history
This should improve the stability of TestStrings.
  • Loading branch information
mederly committed May 11, 2021
1 parent 833cece commit ac45fc1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Expand Up @@ -5632,14 +5632,16 @@ protected List<AuditEventRecord> filter(List<AuditEventRecord> records, AuditEve
.collect(Collectors.toList());
}

protected void resetTriggerTask(String taskOid, File taskFile, OperationResult result)
// Use this when you want to start the task manually.
protected void clearTaskSchedule(String taskOid, File taskFile, OperationResult result)
throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, FileNotFoundException {
taskManager.suspendAndDeleteTasks(Collections.singletonList(taskOid), 60000L, true, result);
importObjectFromFile(taskFile, result);
taskManager.suspendTasks(Collections.singletonList(taskOid), 60000L, result);
modifySystemObjectInRepo(TaskType.class, taskOid,
prismContext.deltaFor(TaskType.class)
.item(TaskType.F_SCHEDULE).replace()
.item(TaskType.F_BINDING).replace(TaskBindingType.LOOSE) // tightly-bound tasks must have interval set
.asItemDeltas(),
result);
taskManager.resumeTasks(singleton(taskOid), result);
Expand Down
Expand Up @@ -187,7 +187,7 @@ public void test200CreateE2ApprovalCase() throws Exception {
OperationResult result = getTestOperationResult();

clock.resetOverride();
resetTriggerTask(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result);
clearTaskSchedule(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result);

// WHEN
assignRole(userJackOid, ROLE_E2_OID, task, result); // should start approval process
Expand Down
Expand Up @@ -135,7 +135,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_FILE, initTask, initResult);

// we prefer running trigger scanner by hand
resetTriggerTask(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, initResult);
clearTaskSchedule(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, initResult);
// and we don't need validity scanner
taskManager.suspendAndDeleteTasks(Collections.singletonList(TASK_VALIDITY_SCANNER_OID), 60000L, true, initResult);

Expand Down Expand Up @@ -843,7 +843,7 @@ public void test208SixDaysLater() throws Exception {

// GIVEN
clock.resetOverride();
resetTriggerTask(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result);
clearTaskSchedule(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result);
clock.overrideDuration("P6D");

// WHEN
Expand Down

0 comments on commit ac45fc1

Please sign in to comment.