From 3809ff59a534dd3b31ad85f9572a4c5fc322a50d Mon Sep 17 00:00:00 2001 From: larryruili Date: Thu, 31 Aug 2017 15:56:11 -0700 Subject: [PATCH] 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 --- java/google/registry/flows/domain/DomainFlowUtils.java | 7 +++++-- .../registry/flows/domain/DomainDeleteFlowTest.java | 7 +++++-- .../flows/domain/DomainTransferApproveFlowTest.java | 8 ++++++-- .../flows/domain/DomainTransferCancelFlowTest.java | 9 +++++++-- .../flows/domain/DomainTransferRejectFlowTest.java | 8 ++++++-- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index aa3ce74c9..31581ef96 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -960,8 +960,11 @@ public class DomainFlowUtils { ImmutableSet.Builder recordsBuilder = new ImmutableSet.Builder<>(); if (entryToCancel.isPresent()) { for (DomainTransactionRecord record : entryToCancel.get().getDomainTransactionRecords()) { - int cancelledAmount = -1 * record.getReportAmount(); - recordsBuilder.add(record.asBuilder().setReportAmount(cancelledAmount).build()); + // Only cancel fields which are cancelable + if (cancelableFields.contains(record.getReportField())) { + int cancelledAmount = -1 * record.getReportAmount(); + recordsBuilder.add(record.asBuilder().setReportAmount(cancelledAmount).build()); + } } } return recordsBuilder.build(); diff --git a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java index 1981c7d0e..5359ac2bd 100644 --- a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java @@ -870,17 +870,20 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase