Filter cancellation records for only cancellable records

Previously, I would cancel all the records associated with HistoryEntry that's
available for cancellation. This could cause unexpected behavior if we
cancelled a historyEntry which itself had cancelled records (in effect we would
negate the negation unintentionally). This is easily remedied by only
cancelling records which want to be cancelled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167204383
This commit is contained in:
larryruili 2017-08-31 15:56:11 -07:00 committed by jianglai
parent d8c1501213
commit 3809ff59a5
5 changed files with 29 additions and 10 deletions

View file

@ -870,17 +870,20 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
clock.advanceOneMilli();
DomainTransactionRecord renewRecord =
DomainTransactionRecord.create("tld", TIME_BEFORE_FLOW.plusDays(1), NET_RENEWS_3_YR, 1);
// We don't want to cancel non-add or renew records
DomainTransactionRecord notCancellableRecord =
DomainTransactionRecord.create("tld", TIME_BEFORE_FLOW.plusDays(1), RESTORED_DOMAINS, 5);
earlierHistoryEntry =
persistResource(
earlierHistoryEntry
.asBuilder()
.setType(DOMAIN_CREATE)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(2))
.setDomainTransactionRecords(ImmutableSet.of(renewRecord))
.setDomainTransactionRecords(ImmutableSet.of(renewRecord, notCancellableRecord))
.build());
runFlow();
HistoryEntry persistedEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE);
// Transaction record should be the non-grace period delete, and the renew cancellation record
// We should only see the non-grace period delete record and the renew cancellation record
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(