Skip to content

Commit

Permalink
Revert getTask in tests to the "plain" version
Browse files Browse the repository at this point in the history
This commit removes all the special treatment of Quartz and live
information to task in getTask method, renaming it to getTaskPlain.
(This might not be the definite name, though.)

This should fix recent test failures.
  • Loading branch information
mederly committed Mar 9, 2020
1 parent 6316193 commit 154a42c
Show file tree
Hide file tree
Showing 28 changed files with 235 additions and 215 deletions.
Expand Up @@ -514,7 +514,7 @@ private void resetStateToInitialConfig(AjaxRequestTarget target) {
final String taskOidToRemoving = taskOid;

try {
while(!getTaskManager().getTask(taskOid, result).isClosed()) {TimeUnit.SECONDS.sleep(5);}
while(!getTaskManager().getTaskPlain(taskOid, result).isClosed()) {TimeUnit.SECONDS.sleep(5);}

runPrivileged(new Producer<Object>() {

Expand Down
Expand Up @@ -119,7 +119,7 @@ public void test110DetermineObjectClassObjectClass() throws Exception {

importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE);

Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_OBJECTCLASS_OID, result);
Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_OBJECTCLASS_OID, result);
display("Task", task);

// WHEN
Expand All @@ -139,7 +139,7 @@ public void test112DetermineObjectClassKindIntent() throws Exception {

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE);

Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_KIND_INTENT_OID, result);
Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OID, result);
display("Task", task);

// WHEN
Expand All @@ -159,7 +159,7 @@ public void test114DetermineObjectClassKindIntentObjectClass() throws Exception

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);

Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
display("Task", task);

// WHEN
Expand All @@ -179,7 +179,7 @@ public void test120DetermineObjectClassObjectClassModel() throws Exception {

importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE);

Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_OBJECTCLASS_OID, result);
Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_OBJECTCLASS_OID, result);
display("Task", task);

// WHEN
Expand All @@ -200,7 +200,7 @@ public void test122DetermineObjectClassKindIntentModel() throws Exception {

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE);

Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_KIND_INTENT_OID, result);
Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OID, result);
display("Task", task);

// WHEN
Expand All @@ -222,7 +222,7 @@ public void test124DetermineObjectClassKindIntentObjectClassModel() throws Excep

importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);

Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
display("Task", task);

// WHEN
Expand Down
Expand Up @@ -159,7 +159,7 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception {
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
reconciliationTaskResultListener.clear();

Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
Task taskBefore = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_UUID_OID, result);

// WHEN
when();
Expand Down Expand Up @@ -233,7 +233,7 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception {
display("Old shadow OID", augustusShadowOid);
display("Account ID " + oldAccount.getId() + " -> " + newAccount.getId());

Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
Task taskBefore = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_UUID_OID, result);

getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
Expand Down Expand Up @@ -318,7 +318,7 @@ public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Excepti
display("Old shadow OID", augustusShadowOid);
display("Account ID " + oldAccount.getId() + " -> " + account.getId());

Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
Task taskBefore = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_UUID_OID, result);

getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
Expand Down
Expand Up @@ -40,7 +40,7 @@ protected void assertLastScanTimestamp(String taskOid, XMLGregorianCalendar star
throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException,
ConfigurationException, ExpressionEvaluationException {
OperationResult result = createOperationResult("assertLastScanTimestamp");
Task master = taskManager.getTask(taskOid, result);
Task master = taskManager.getTaskPlain(taskOid, result);
for (Task subtask : master.listSubtasks(result)) {
super.assertLastScanTimestamp(subtask.getOid(), startCal, endCal);
}
Expand Down
Expand Up @@ -3672,7 +3672,7 @@ protected void rerunTask(String taskOid) throws CommonException {

protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus expectedExecutionStatus) throws ObjectNotFoundException, SchemaException {
final OperationResult result = new OperationResult(AbstractIntegrationTest.class + ".assertTaskExecutionStatus");
Task task = taskManager.getTask(taskOid, result);
Task task = taskManager.getTaskPlain(taskOid, result);
assertEquals("Wrong executionStatus in " + task, expectedExecutionStatus, task.getExecutionStatus());
}

Expand Down
Expand Up @@ -80,7 +80,7 @@ public void test100ReportUserList() throws Exception {

display("Background task", task);

waitForTaskFinish(task.getOid(), true);
waitForTaskFinish(task.getOid(), false);

// THEN
then();
Expand Down Expand Up @@ -139,7 +139,7 @@ public void test200ReportUserListScript() throws Exception {

display("Background task", task);

waitForTaskFinish(task.getOid(), true);
waitForTaskFinish(task.getOid(), false);

// THEN
then();
Expand Down Expand Up @@ -198,7 +198,7 @@ protected PrismObject<TaskType> runReport(PrismObject<ReportType> report, boolea

display("Background task (running)", task);

waitForTaskFinish(task.getOid(), true, DEFAULT_TASK_WAIT_TIMEOUT, errorOk);
waitForTaskFinish(task.getOid(), false, DEFAULT_TASK_WAIT_TIMEOUT, errorOk);

// THEN
then();
Expand Down
Expand Up @@ -119,7 +119,7 @@ public void test010Sanity() throws Exception {
assertNotNull("No resource schema", resource.asObjectable().getSchema());
assertNotNull("No native capabilities", resource.asObjectable().getCapabilities().getNative());

Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
Task syncTask = taskManager.getTaskPlain(SYNC_TASK_OID, result);
AssertJUnit.assertNotNull(syncTask);
assertSyncToken(syncTask, 0, result);
}
Expand All @@ -128,7 +128,7 @@ public void test010Sanity() throws Exception {
public void test100SyncAddWill() throws Exception {
final OperationResult result = createOperationResult();

Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
Task syncTask = taskManager.getTaskPlain(SYNC_TASK_OID, result);
AssertJUnit.assertNotNull(syncTask);
assertSyncToken(syncTask, 0, result);
((SynchronizationServiceMock) syncServiceMock).reset();
Expand Down Expand Up @@ -187,7 +187,7 @@ public void test100SyncAddWill() throws Exception {
public void test500SyncAddProtected() throws Exception {
final OperationResult result = createOperationResult();

Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
Task syncTask = taskManager.getTaskPlain(SYNC_TASK_OID, result);
AssertJUnit.assertNotNull(syncTask);
assertSyncToken(syncTask, 1, result);
((SynchronizationServiceMock) syncServiceMock).reset();
Expand Down
Expand Up @@ -1402,14 +1402,14 @@ protected void assertFilter(ObjectFilter filter, Class<? extends ObjectFilter> e

protected void assertSyncToken(String syncTaskOid, Object expectedValue) throws ObjectNotFoundException, SchemaException {
OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken");
Task task = taskManager.getTask(syncTaskOid, result);
Task task = taskManager.getTaskPlain(syncTaskOid, result);
assertSyncToken(task, expectedValue, result);
result.computeStatus();
TestUtil.assertSuccess(result);
}

protected void assertSyncToken(String syncTaskOid, Object expectedValue, OperationResult result) throws ObjectNotFoundException, SchemaException {
Task task = taskManager.getTask(syncTaskOid, result);
Task task = taskManager.getTaskPlain(syncTaskOid, result);
assertSyncToken(task, expectedValue, result);
}

Expand Down
Expand Up @@ -253,19 +253,30 @@ void modifyTask(String oid, Collection<? extends ItemDelta> modifications, Opera
*
* Works only on persistent tasks.
*
* Gets the task simply by fetching it from repository. No attempts to augment it with the live data nor Quartz scheduling
* information nor subtasks is done. TODO can we use options (noFetch? raw?) to achieve this?
*
* @param taskOid OID of the persistent task.
* @return Task instance
* @throws SchemaException error dealing with resource schema
* @throws ObjectNotFoundException wrong OID format, etc.
*/
@NotNull
Task getTask(String taskOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;
Task getTaskPlain(String taskOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;

/**
* Gets the task simply by fetching it from repository. No attempts to augment it with the live data nor Quartz scheduling
* information nor subtasks is done. TODO can we use options (noFetch? raw?) to achieve this?
*/
@NotNull
Task getTaskWithResult(String taskOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;
Task getTaskPlain(String taskOid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;

/**
* Gets the task (as in getTaskPlain) but with its operation result.
*/
@NotNull
Task getTask(String taskOid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;
Task getTaskWithResult(String taskOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;


/**
* Returns a task with a given identifier.
Expand Down

0 comments on commit 154a42c

Please sign in to comment.