Skip to content

Commit

Permalink
Make TestUserTemplate more stable
Browse files Browse the repository at this point in the history
Here we've replaced recurring trigger scanner task (interval 1 second)
with the one that runs on demand. It should make the tests
(test990SpecialTimedMapping in particular) more stable.

(cherry picked from commit cd061d3)
  • Loading branch information
mederly committed Jul 26, 2022
1 parent 8731d5a commit 23bd6ed
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_USELESS, USER_TEMPLATE_USELESS_OID, initResult);
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MID_5892, USER_TEMPLATE_MID_5892.oid, initResult);
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MID_6045, USER_TEMPLATE_MID_6045.oid, initResult);

addObject(CommonTasks.TASK_TRIGGER_SCANNER_ON_DEMAND, initTask, initResult);
}

@Override
Expand Down Expand Up @@ -2471,14 +2473,11 @@ public void test302ModifyStanAccountAndReimport() throws Exception {
*/
@Test
public void test800NullTimeFrom() throws Exception {
// GIVEN
OperationResult result = getTestOperationResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);

importObjectFromFile(TASK_TRIGGER_SCANNER_FILE);
waitForTaskStart(TASK_TRIGGER_SCANNER_OID, false);

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
// @formatter:off
Expand All @@ -2505,7 +2504,7 @@ public void test802FuneralTimestamp() throws Exception {
modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, funeralTimestamp);

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
// @formatter:off
Expand All @@ -2527,11 +2526,13 @@ public void test802FuneralTimestamp() throws Exception {
*/
@Test
public void test804PreKaboom() throws Exception {
OperationResult result = getTestOperationResult();

// GIVEN
clockForward("P2D"); // total override is realTime + 2D

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
// @formatter:off
Expand All @@ -2549,11 +2550,13 @@ public void test804PreKaboom() throws Exception {
*/
@Test
public void test808Kaboom() throws Exception {
OperationResult result = getTestOperationResult();

// GIVEN
clockForward("P1M"); // total override is realTime + 2D + 1M

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
// @formatter:off
Expand All @@ -2579,11 +2582,13 @@ public void test808Kaboom() throws Exception {
*/
@Test
public void test810PreTalesBomb() throws Exception {
OperationResult result = getTestOperationResult();

// GIVEN
clockForward("P1D"); // total override is realTime + 2D + 1M + 1D

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
// @formatter:off
Expand Down Expand Up @@ -2616,11 +2621,13 @@ public void test810PreTalesBomb() throws Exception {
*/
@Test
public void test812TalesBoom() throws Exception {
OperationResult result = getTestOperationResult();

// GIVEN
clockForward("P3M");

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
// @formatter:off
Expand All @@ -2640,6 +2647,7 @@ public void test812TalesBoom() throws Exception {
*/
@Test
public void test813TalesBoomRecompute() throws Exception {
OperationResult result = getTestOperationResult();
// GIVEN

// WHEN
Expand All @@ -2656,7 +2664,7 @@ public void test813TalesBoomRecompute() throws Exception {
.assertNone();

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
assertUserAfter(USER_JACK_OID)
Expand Down Expand Up @@ -2704,7 +2712,7 @@ public void test820TalesUnBoom() throws Exception {
.assertNone();

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
assertUserAfter(USER_JACK_OID)
Expand All @@ -2714,7 +2722,6 @@ public void test820TalesUnBoom() throws Exception {
.end()
.triggers()
.assertNone();

}

/**
Expand Down Expand Up @@ -2759,7 +2766,7 @@ public void test830PreLootBoom() throws Exception {
.assertTimestampFuture(funeralTimestamp, "P1Y", 2 * DAY_MILLIS);

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
assertUserAfter(USER_JACK_OID)
Expand All @@ -2782,11 +2789,13 @@ public void test830PreLootBoom() throws Exception {
*/
@Test
public void test832LootBoomConditionFalse() throws Exception {
OperationResult result = getTestOperationResult();

// GIVEN
clockForward("P9M");

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
assertUserAfter(USER_JACK_OID)
Expand Down Expand Up @@ -2857,7 +2866,7 @@ public void test840ResetFuneralTimestamp() throws Exception {
modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */);

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
runTriggerScannerOnDemand(result);

// THEN
assertUserAfter(USER_JACK_OID)
Expand Down

0 comments on commit 23bd6ed

Please sign in to comment.