Skip to content

Commit

Permalink
Fix time assertions in TestUserTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 28, 2020
1 parent 9aff6e2 commit 5ca3427
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Expand Up @@ -114,7 +114,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
repoAddObjectFromFile(USER_TEMPLATE_MAROONED_FILE, initResult);
repoAddObjectFromFile(USER_TEMPLATE_USELESS_FILE, initResult);
repoAdd(USER_TEMPLATE_MID_5892, initResult);

setDefaultObjectTemplate(UserType.COMPLEX_TYPE, USER_TEMPLATE_COMPLEX_OID, initResult);
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MAROONED, USER_TEMPLATE_MAROONED_OID, initResult);
setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_USELESS, USER_TEMPLATE_USELESS_OID, initResult);
Expand Down Expand Up @@ -2453,8 +2453,6 @@ public void test302ModifyStanAccountAndReimport() throws Exception {
@Test
public void test800NullTimeFrom() throws Exception {
// GIVEN
Task task = getTask();
OperationResult result = getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);

importObjectFromFile(TASK_TRIGGER_SCANNER_FILE);
Expand Down Expand Up @@ -2510,7 +2508,7 @@ public void test804PreKaboom() throws Exception {
displayTestTitle(TEST_NAME);

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

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
Expand All @@ -2533,7 +2531,7 @@ public void test808Kaboom() throws Exception {
displayTestTitle(TEST_NAME);

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

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
Expand All @@ -2546,7 +2544,8 @@ public void test808Kaboom() throws Exception {
.end()
.triggers()
.single()
// Trigger for "tales bomb" mapping (see below)
// Trigger for "tales bomb" mapping (see below) - it was computed as funeralTimestamp + 3M
// (i.e. should be approximately equal to clock + 2M - 2D, because clock = realTime + 2D + 1M)
.assertHandlerUri(RecomputeTriggerHandler.HANDLER_URI)
.assertTimestampFuture("P2M", 5*24*60*60*1000L);
}
Expand All @@ -2563,7 +2562,7 @@ public void test810PreTalesBomb() throws Exception {
displayTestTitle(TEST_NAME);

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

// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
Expand All @@ -2577,8 +2576,18 @@ public void test810PreTalesBomb() throws Exception {
.end()
.triggers()
.single()
// Trigger for "tales bomb" mapping - it was computed as funeralTimestamp + 3M
// (i.e. should be approximately equal to clock + 2M - 3D, because clock = realTime + 2D + 1M + 1D)
//
// We need to set a tolerance bigger than 5 days here, because e.g. on Feb 28th 2020 the situation is as follows:
// - trigger time = 2020-05-28T00:00:00.000+01:00 (3M after funeral i.e. realTime rounded down to midnight)
// - clock = 2020-04-02T12:55:20.299+02:00 (realTime + 2D + 1M + 1D)
// - clock+2M (expected time) = 2020-06-02T12:55:20.299+02:00
// - clock+2M - 5 days (lower tolerance interval border) = 2020-05-28T12:55:21.979+02:00 that is after funeralTimestamp!
//
// So setting the tolerance to 7 days should be good enough.
.assertHandlerUri(RecomputeTriggerHandler.HANDLER_URI)
.assertTimestampFuture("P2M", 5*24*60*60*1000L);
.assertTimestampFuture("P2M", 7*24*60*60*1000L);
}

/**
Expand Down
Expand Up @@ -464,13 +464,13 @@
// it will not be processed.
return null
}
javax.xml.datatype.XMLGregorianCalendar funeralTimestamp = basic.getExtensionPropertyValue(focus,'funeralTimestamp')
javax.xml.datatype.XMLGregorianCalendar funeralTimestamp = basic.getExtensionPropertyValue(focus, 'funeralTimestamp')
if (funeralTimestamp == null) {
// Always process this mapping immediately
return basic.longAgo()
}
def timestamp = basic.addDuration(funeralTimestamp, "P3M")
timetamp = basic.roundDownToMidnight(timestamp)
timestamp = basic.roundDownToMidnight(timestamp)
return timestamp
</code>
</script>
Expand Down Expand Up @@ -507,7 +507,7 @@
return basic.longAgo()
}
def timestamp = basic.addDuration(funeralTimestamp, "P1Y")
timetamp = basic.roundDownToMidnight(timestamp)
timestamp = basic.roundDownToMidnight(timestamp)
return timestamp
</code>
</script>
Expand Down

0 comments on commit 5ca3427

Please sign in to comment.