Record domain transaction for DomainRestoreFlow

This is the first of many cls adding explicit logging in all our domain mutation flows to facilitate transaction reporting.

Restores are relatively simple- it happens immediately, so the reporting time is just the time of the HistoryEntry, and we add a single "RESTORED_DOMAINS" count of 1.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165639084
This commit is contained in:
larryruili 2017-08-17 15:35:38 -07:00 committed by Ben McIlwain
parent bf383081ce
commit 2fe82921a7
3 changed files with 35 additions and 0 deletions

View file

@ -16,6 +16,7 @@ package google.registry.flows.domain;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.reporting.DomainTransactionRecord.TransactionFieldAmount.TransactionReportField.RESTORED_DOMAINS;
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
@ -60,6 +61,8 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.DomainTransactionRecord.TransactionFieldAmount;
import google.registry.model.reporting.HistoryEntry;
import java.util.Map;
import org.joda.money.Money;
@ -568,4 +571,21 @@ public class DomainRestoreRequestFlowTest extends
assertIcannReportingActivityFieldLogged("srs-dom-rgp-restore-request");
assertTldsFieldLogged("tld");
}
@Test
public void testIcannTransactionReportField_getsStored() throws Exception {
persistPendingDeleteDomain();
runFlow();
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainRestore =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
DomainTransactionRecord transactionRecord =
historyEntryDomainRestore.getDomainTransactionRecord();
assertThat(transactionRecord.getTld()).isEqualTo("tld");
assertThat(transactionRecord.getReportingTime())
.isEqualTo(historyEntryDomainRestore.getModificationTime());
assertThat(transactionRecord.getTransactionFieldAmounts())
.containsExactly(TransactionFieldAmount.create(RESTORED_DOMAINS, 1));
}
}