Skip to content

Commit

Permalink
TestRecomputeTask finally done.
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 2, 2014
1 parent 84a1c7d commit 6ef64ea
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 13 deletions.
Expand Up @@ -91,12 +91,15 @@ public class TestRecomputeTask extends AbstractInitializedModelIntegrationTest {

private static final File TASK_USER_RECOMPUTE_FILE = new File(TEST_DIR, "task-user-recompute.xml");
private static final String TASK_USER_RECOMPUTE_OID = "91919191-76e0-59e2-86d6-3d4f02d3aaaa";

private static final File TASK_USER_RECOMPUTE_CAPTAIN_FILE = new File(TEST_DIR, "task-user-recompute-captain.xml");
private static final String TASK_USER_RECOMPUTE_CAPTAIN_OID = "91919191-76e0-59e2-86d6-3d4f02d3aaac";

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
DebugUtil.setDetailedDebugDump(true);
// DebugUtil.setDetailedDebugDump(true);
}

@Test
Expand All @@ -117,7 +120,8 @@ public void test100RecomputeAll() throws Exception {

assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result);
assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result);
assignRole(USER_ELAINE_OID, ROLE_JUDGE_OID, task, result);
addObject(USER_HERMAN_FILE);
assignRole(USER_HERMAN_OID, ROLE_JUDGE_OID, task, result);

result.computeStatus();
TestUtil.assertSuccess(result);
Expand Down Expand Up @@ -210,7 +214,7 @@ public void test100RecomputeAll() throws Exception {
assertNoDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);

assertUsers(5);
assertUsers(6);

// Check audit
display("Audit", dummyAuditService);
Expand Down Expand Up @@ -244,7 +248,7 @@ public void test100RecomputeAll() throws Exception {
}

}
assertEquals("Unexpected number of audit modifications", 5, modifications);
assertEquals("Unexpected number of audit modifications", 6, modifications);

deleteObject(TaskType.class, TASK_USER_RECOMPUTE_OID, task, result);
}
Expand All @@ -259,7 +263,7 @@ private void displayRoles(Task task, OperationResult result) throws ObjectNotFou

}

@Test(enabled=false) // work in progress
@Test
public void test110RecomputeSome() throws Exception {
final String TEST_NAME = "test110RecomputeSome";
TestUtil.displayTestTile(this, TEST_NAME);
Expand All @@ -269,9 +273,9 @@ public void test110RecomputeSome() throws Exception {
OperationResult result = task.getResult();

// Preconditions
assertUsers(5);
assertUsers(6);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, "Elaine Marley", true);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", true);

result.computeStatus();
TestUtil.assertSuccess(result);
Expand All @@ -283,16 +287,16 @@ public void test110RecomputeSome() throws Exception {

// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(TASK_USER_RECOMPUTE_FILE);
addObject(TASK_USER_RECOMPUTE_CAPTAIN_FILE);

dummyAuditService.clear();

waitForTaskStart(TASK_USER_RECOMPUTE_OID, false);
waitForTaskStart(TASK_USER_RECOMPUTE_CAPTAIN_OID, false);

// WHEN
TestUtil.displayWhen(TEST_NAME);

waitForTaskFinish(TASK_USER_RECOMPUTE_OID, true, 40000);
waitForTaskFinish(TASK_USER_RECOMPUTE_CAPTAIN_OID, true, 40000);

// THEN
TestUtil.displayThen(TEST_NAME);
Expand All @@ -305,10 +309,13 @@ public void test110RecomputeSome() throws Exception {
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", "dagger");
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);

assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME);
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME);
// Red resource does not delete accounts on deprovision, it disables them
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);

assertUsers(5);
// Only captains are recomputed. Therefore herman stays unrecomputed
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", true);

assertUsers(6);

}

Expand Down
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2014 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<task oid="91919191-76e0-59e2-86d6-3d4f02d3aaac"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-2a"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-2"
xmlns:modelext="http://midpoint.evolveum.com/xml/ns/public/model/extension-2">

<name>User Recompute: Captain</name>

<extension>
<modelext:objectQuery>
<q:equal>
<q:path>employeeType</q:path>
<q:value>CAPTAIN</q:value>
</q:equal>
</modelext:objectQuery>
</extension>

<!-- No task identifier. It will be generated during import -->
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionStatus>runnable</executionStatus>

<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/recompute/handler-2</handlerUri>
<recurrence>single</recurrence>
<binding>tight</binding>

</task>

0 comments on commit 6ef64ea

Please sign in to comment.