Record transaction for domain adds, renews and allocates

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

Adds and renews each result in a +1 counter for the NET_ADDS/RENEWS_#_YR field,
which I've added simple (# of years, add or renew) -> Enum functions to get.
Allocates are just a special case of adds, and are counted in a similar manner.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165963249
This commit is contained in:
larryruili 2017-08-21 12:57:01 -07:00 committed by Ben McIlwain
parent cb854f1b8b
commit c40dc67c5b
8 changed files with 170 additions and 24 deletions

View file

@ -22,6 +22,7 @@ import static google.registry.model.eppcommon.StatusValue.OK;
import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED;
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.reporting.DomainTransactionRecord.TransactionFieldAmount.TransactionReportField.netAddsFieldFromYears;
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
import static google.registry.testing.DatastoreHelper.assertPollMessagesForResource;
@ -127,6 +128,8 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.DomainTransactionRecord.TransactionFieldAmount;
import google.registry.model.reporting.HistoryEntry;
import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.DatastoreHelper;
@ -1989,6 +1992,27 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
assertClientIdFieldLogged("TheRegistrar");
}
@Test
public void testIcannTransactionRecord_getsStored() throws Exception {
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setAddGracePeriodLength(Duration.standardMinutes(9))
.build());
runFlow();
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
DomainTransactionRecord transactionRecord =
historyEntry.getDomainTransactionRecord();
assertThat(transactionRecord.getTld()).isEqualTo("tld");
assertThat(transactionRecord.getReportingTime())
.isEqualTo(historyEntry.getModificationTime().plusMinutes(9));
assertThat(transactionRecord.getTransactionFieldAmounts())
.containsExactly(TransactionFieldAmount.create(netAddsFieldFromYears(2), 1));
}
@Test
public void testEppMetric_isSuccessfullyCreated() throws Exception {
persistContactsAndHosts();