mirror of
https://github.com/google/nomulus.git
synced 2025-06-22 20:30:46 +02:00
Fix a flaky test (#1204)
In testSuccess_expandSingleEvent_notIdempotentforDifferentRecurring(), two Recurring entities are created with the only difference being their IDs. If we don't order the Recurrings by ID when loading them there is no guarantee which one is expanded first. In this test the expected OneTime entities are created with the assumption that the first loaded DomainHistory (parent of a OneTime) corresponds to the expanding the Recurring with the smaller ID (2L). Since the DomainHistory entities are loaded in order of IDs, and the IDs are created monotonically in time in tests, we need to load the Recurrings in order of their IDs to ensure that the first DomainHistory is the result of expanding the Recurring with ID of 2L. This should impose minimum performance penalty as we are ordering by the primary key. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1204) <!-- Reviewable:end -->
This commit is contained in:
parent
b59a30ffed
commit
4e1efc02f6
1 changed files with 4 additions and 3 deletions
|
@ -127,10 +127,11 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
||||||
jpaTm()
|
jpaTm()
|
||||||
.query(
|
.query(
|
||||||
"FROM BillingRecurrence "
|
"FROM BillingRecurrence "
|
||||||
+ "WHERE event_time <= :executeTime "
|
+ "WHERE eventTime <= :executeTime "
|
||||||
+ "AND event_time < recurrence_end_time",
|
+ "AND eventTime < recurrenceEndTime "
|
||||||
|
+ "ORDER BY id ASC",
|
||||||
Recurring.class)
|
Recurring.class)
|
||||||
.setParameter("executeTime", executeTime.toDate())
|
.setParameter("executeTime", executeTime)
|
||||||
// Need to get a list from the transaction and then convert it to a stream
|
// Need to get a list from the transaction and then convert it to a stream
|
||||||
// for further processing. If we get a stream directly, each elements gets
|
// for further processing. If we get a stream directly, each elements gets
|
||||||
// processed downstream eagerly but Hibernate returns a
|
// processed downstream eagerly but Hibernate returns a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue