mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 20:23:24 +02:00
Convert (most) HistoryEntry ofy calls to tm (#933)
* Convert (most) HistoryEntry ofy calls to tm As part of this change, it was necessary to do changes in the JPATM that are similar (but the opposite) of the changes that we did in DatastoreTM with regards to converting HistoryEntries to and from the *History classes. We leave the ofy() calls in the MapReduce ResaveAllHistoryEntriesAction for now; that can be converted during the Beam pipeline transition. Some other tests required registrar-name fixes as well -- because *History objects have a foreign key on the Registrar table, we have to use a "real" registrar name in tests. * Add simple HistoryEntryDaoTest
This commit is contained in:
parent
08cec96a93
commit
73210e4b09
26 changed files with 477 additions and 124 deletions
|
@ -525,8 +525,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
clock.advanceOneMilli();
|
||||
runFlow();
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
|
||||
HistoryEntry historyEntry =
|
||||
ofy().load().type(HistoryEntry.class).ancestor(reloadResourceByForeignKey()).first().now();
|
||||
HistoryEntry historyEntry = getHistoryEntries(reloadResourceByForeignKey()).get(0);
|
||||
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry())
|
||||
.hasValue(HistoryEntry.createVKey(Key.create(historyEntry)));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
// Copyright 2020 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.model.reporting;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainHistory;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
@DualDatabaseTest
|
||||
public class HistoryEntryDaoTest extends EntityTestCase {
|
||||
|
||||
private DomainBase domain;
|
||||
private HistoryEntry historyEntry;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
fakeClock.setTo(DateTime.parse("2020-10-01T00:00:00Z"));
|
||||
createTld("foobar");
|
||||
domain = persistActiveDomain("foo.foobar");
|
||||
DomainTransactionRecord transactionRecord =
|
||||
new DomainTransactionRecord.Builder()
|
||||
.setTld("foobar")
|
||||
.setReportingTime(fakeClock.nowUtc())
|
||||
.setReportField(TransactionReportField.NET_ADDS_1_YR)
|
||||
.setReportAmount(1)
|
||||
.build();
|
||||
// Set up a new persisted HistoryEntry entity.
|
||||
historyEntry =
|
||||
new DomainHistory.Builder()
|
||||
.setParent(domain)
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setPeriod(Period.create(1, Period.Unit.YEARS))
|
||||
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
|
||||
.setModificationTime(fakeClock.nowUtc())
|
||||
.setClientId("TheRegistrar")
|
||||
.setOtherClientId("otherClient")
|
||||
.setTrid(Trid.create("ABC-123", "server-trid"))
|
||||
.setBySuperuser(false)
|
||||
.setReason("reason")
|
||||
.setRequestedByRegistrar(false)
|
||||
.setDomainTransactionRecords(ImmutableSet.of(transactionRecord))
|
||||
.build();
|
||||
persistResource(historyEntry);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSimpleLoadAll() {
|
||||
assertThat(HistoryEntryDao.loadAllHistoryObjects(START_OF_TIME, END_OF_TIME))
|
||||
.comparingElementsUsing(immutableObjectCorrespondence("nsHosts"))
|
||||
.containsExactly(historyEntry);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSkips_tooEarly() {
|
||||
assertThat(HistoryEntryDao.loadAllHistoryObjects(fakeClock.nowUtc().plusMillis(1), END_OF_TIME))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSkips_tooLate() {
|
||||
assertThat(
|
||||
HistoryEntryDao.loadAllHistoryObjects(START_OF_TIME, fakeClock.nowUtc().minusMillis(1)))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testLoadByResource() {
|
||||
transactIfJpaTm(
|
||||
() ->
|
||||
assertThat(HistoryEntryDao.loadHistoryObjectsForResource(domain.createVKey()))
|
||||
.comparingElementsUsing(immutableObjectCorrespondence("nsHosts"))
|
||||
.containsExactly(historyEntry));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testLoadByResource_skips_tooEarly() {
|
||||
assertThat(
|
||||
HistoryEntryDao.loadHistoryObjectsForResource(
|
||||
domain.createVKey(), fakeClock.nowUtc().plusMillis(1), END_OF_TIME))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testLoadByResource_skips_tooLate() {
|
||||
assertThat(
|
||||
HistoryEntryDao.loadHistoryObjectsForResource(
|
||||
domain.createVKey(), START_OF_TIME, fakeClock.nowUtc().minusMillis(1)))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testLoadByResource_noEntriesForResource() {
|
||||
DomainBase newDomain = persistResource(newDomainBase("new.foobar"));
|
||||
assertThat(HistoryEntryDao.loadHistoryObjectsForResource(newDomain.createVKey())).isEmpty();
|
||||
}
|
||||
}
|
|
@ -14,22 +14,29 @@
|
|||
|
||||
package google.registry.model.reporting;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainHistory;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.testing.TestOfyOnly;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link HistoryEntry}. */
|
||||
@DualDatabaseTest
|
||||
class HistoryEntryTest extends EntityTestCase {
|
||||
|
||||
private HistoryEntry historyEntry;
|
||||
|
@ -37,6 +44,7 @@ class HistoryEntryTest extends EntityTestCase {
|
|||
@BeforeEach
|
||||
void setUp() {
|
||||
createTld("foobar");
|
||||
DomainBase domain = persistActiveDomain("foo.foobar");
|
||||
DomainTransactionRecord transactionRecord =
|
||||
new DomainTransactionRecord.Builder()
|
||||
.setTld("foobar")
|
||||
|
@ -46,13 +54,13 @@ class HistoryEntryTest extends EntityTestCase {
|
|||
.build();
|
||||
// Set up a new persisted HistoryEntry entity.
|
||||
historyEntry =
|
||||
new HistoryEntry.Builder()
|
||||
.setParent(newDomainBase("foo.foobar"))
|
||||
new DomainHistory.Builder()
|
||||
.setParent(domain)
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setPeriod(Period.create(1, Period.Unit.YEARS))
|
||||
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
|
||||
.setModificationTime(fakeClock.nowUtc())
|
||||
.setClientId("foo")
|
||||
.setClientId("TheRegistrar")
|
||||
.setOtherClientId("otherClient")
|
||||
.setTrid(Trid.create("ABC-123", "server-trid"))
|
||||
.setBySuperuser(false)
|
||||
|
@ -63,13 +71,23 @@ class HistoryEntryTest extends EntityTestCase {
|
|||
persistResource(historyEntry);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testPersistence() {
|
||||
assertThat(ofy().load().entity(historyEntry).now()).isEqualTo(historyEntry);
|
||||
transactIfJpaTm(
|
||||
() -> {
|
||||
HistoryEntry fromDatabase = tm().loadByEntity(historyEntry);
|
||||
assertAboutImmutableObjects()
|
||||
.that(fromDatabase)
|
||||
.isEqualExceptFields(historyEntry, "nsHosts", "domainTransactionRecords");
|
||||
assertAboutImmutableObjects()
|
||||
.that(Iterables.getOnlyElement(fromDatabase.getDomainTransactionRecords()))
|
||||
.isEqualExceptFields(
|
||||
Iterables.getOnlyElement(historyEntry.getDomainTransactionRecords()), "id");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyOnly
|
||||
void testIndexing() throws Exception {
|
||||
verifyIndexing(historyEntry, "modificationTime", "clientId");
|
||||
verifyIndexing(historyEntry.asHistoryEntry(), "modificationTime", "clientId");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
|||
registrarLol)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
|
||||
// deleted domain in lol
|
||||
|
@ -128,7 +128,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
|||
registrarLol)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.setDeletionTime(clock.nowUtc().minusDays(1))
|
||||
.build());
|
||||
// cat.みんな
|
||||
|
@ -168,7 +168,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
|||
registrarIdn)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
|
||||
// 1.tld
|
||||
|
@ -208,7 +208,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
|||
registrar1Tld)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
|
||||
// history entries
|
||||
|
|
|
@ -176,7 +176,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
|||
.asBuilder()
|
||||
.setSubordinateHosts(ImmutableSet.of("ns1.cat.lol", "ns2.cat.lol"))
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
persistResource(
|
||||
hostNs1CatLol.asBuilder().setSuperordinateDomain(domainCatLol.createVKey()).build());
|
||||
|
@ -216,7 +216,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
|||
registrar)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
// cat.example
|
||||
createTld("example");
|
||||
|
@ -255,7 +255,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
|||
registrar)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
// cat.みんな
|
||||
createTld("xn--q9jyb4c");
|
||||
|
@ -294,7 +294,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
|||
registrar)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
// cat.1.test
|
||||
createTld("1.test");
|
||||
|
@ -334,7 +334,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
|||
.asBuilder()
|
||||
.setSubordinateHosts(ImmutableSet.of("ns1.cat.1.test"))
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.build());
|
||||
|
||||
persistResource(makeRegistrar("otherregistrar", "other", Registrar.State.ACTIVE));
|
||||
|
@ -430,7 +430,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
|||
.asBuilder()
|
||||
.setNameservers(hostKeys)
|
||||
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
|
||||
.setCreationClientId("foo");
|
||||
.setCreationClientId("TheRegistrar");
|
||||
if (domainName.equals(mainDomainName)) {
|
||||
builder.setSubordinateHosts(subordinateHostnamesBuilder.build());
|
||||
}
|
||||
|
|
|
@ -191,7 +191,6 @@ class RdapJsonFormatterTest {
|
|||
hostResourceIpv6,
|
||||
registrar)
|
||||
.asBuilder()
|
||||
.setCreationClientId("foo")
|
||||
.setCreationTimeForTest(clock.nowUtc().minusMonths(4))
|
||||
.setLastEppUpdateTime(clock.nowUtc().minusMonths(3))
|
||||
.build());
|
||||
|
@ -206,7 +205,6 @@ class RdapJsonFormatterTest {
|
|||
null,
|
||||
registrar)
|
||||
.asBuilder()
|
||||
.setCreationClientId("foo")
|
||||
.setCreationTimeForTest(clock.nowUtc())
|
||||
.setLastEppUpdateTime(null)
|
||||
.build());
|
||||
|
|
|
@ -313,7 +313,7 @@ class RdapTestHelper {
|
|||
}
|
||||
builder.append(
|
||||
String.format(
|
||||
"Different: %s -> %s\ninstead of %s\n\n",
|
||||
"Actual: %s -> %s\nExpected: %s\n\n",
|
||||
name, jsonifyAndIndent(actual), jsonifyAndIndent(expected)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ public final class FullFieldsTestEntityHelper {
|
|||
.setPeriod(period)
|
||||
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
|
||||
.setModificationTime(modificationTime)
|
||||
.setClientId("foo")
|
||||
.setClientId(resource.getPersistedCurrentSponsorClientId())
|
||||
.setTrid(Trid.create("ABC-123", "server-trid"))
|
||||
.setBySuperuser(false)
|
||||
.setReason(reason)
|
||||
|
|
|
@ -22,12 +22,14 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntr
|
|||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link GetClaimsListCommand}. */
|
||||
@DualDatabaseTest
|
||||
class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesCommand> {
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
|
||||
|
@ -40,7 +42,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
|||
domain = persistActiveDomain("example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_works() throws Exception {
|
||||
persistResource(
|
||||
makeHistoryEntry(
|
||||
|
@ -51,7 +53,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
|||
clock.nowUtc()));
|
||||
runCommand("--id=example.tld", "--type=DOMAIN");
|
||||
assertStdoutIs(
|
||||
"Client: foo\n"
|
||||
"Client: TheRegistrar\n"
|
||||
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
||||
+ "Client TRID: ABC-123\n"
|
||||
+ "Server TRID: server-trid\n"
|
||||
|
@ -60,7 +62,57 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
|||
+ "\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_nothingBefore() throws Exception {
|
||||
persistResource(
|
||||
makeHistoryEntry(
|
||||
domain,
|
||||
HistoryEntry.Type.DOMAIN_CREATE,
|
||||
Period.create(1, Period.Unit.YEARS),
|
||||
"created",
|
||||
clock.nowUtc()));
|
||||
runCommand("--before", clock.nowUtc().minusMinutes(1).toString());
|
||||
assertStdoutIs("");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_nothingAfter() throws Exception {
|
||||
persistResource(
|
||||
makeHistoryEntry(
|
||||
domain,
|
||||
HistoryEntry.Type.DOMAIN_CREATE,
|
||||
Period.create(1, Period.Unit.YEARS),
|
||||
"created",
|
||||
clock.nowUtc()));
|
||||
runCommand("--after", clock.nowUtc().plusMinutes(1).toString());
|
||||
assertStdoutIs("");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_withinRange() throws Exception {
|
||||
persistResource(
|
||||
makeHistoryEntry(
|
||||
domain,
|
||||
HistoryEntry.Type.DOMAIN_CREATE,
|
||||
Period.create(1, Period.Unit.YEARS),
|
||||
"created",
|
||||
clock.nowUtc()));
|
||||
runCommand(
|
||||
"--after",
|
||||
clock.nowUtc().minusMinutes(1).toString(),
|
||||
"--before",
|
||||
clock.nowUtc().plusMinutes(1).toString());
|
||||
assertStdoutIs(
|
||||
"Client: TheRegistrar\n"
|
||||
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
||||
+ "Client TRID: ABC-123\n"
|
||||
+ "Server TRID: server-trid\n"
|
||||
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
+ "<xml/>\n"
|
||||
+ "\n");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_noTrid() throws Exception {
|
||||
persistResource(
|
||||
makeHistoryEntry(
|
||||
|
@ -74,7 +126,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
|||
.build());
|
||||
runCommand("--id=example.tld", "--type=DOMAIN");
|
||||
assertStdoutIs(
|
||||
"Client: foo\n"
|
||||
"Client: TheRegistrar\n"
|
||||
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
||||
+ "Client TRID: null\n"
|
||||
+ "Server TRID: null\n"
|
||||
|
|
|
@ -37,15 +37,17 @@ import google.registry.model.registrar.Registrar;
|
|||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.schema.domain.RegistryLock;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.tools.CommandTestCase;
|
||||
import google.registry.util.StringGenerator.Alphabets;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link BackfillRegistryLocksCommand}. */
|
||||
@DualDatabaseTest
|
||||
class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryLocksCommand> {
|
||||
|
||||
@BeforeEach
|
||||
|
@ -57,7 +59,7 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
command.stringGenerator = new DeterministicStringGenerator(Alphabets.BASE_58);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSimpleBackfill() throws Exception {
|
||||
DomainBase domain = persistLockedDomain("example.tld");
|
||||
Truth8.assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId())).isEmpty();
|
||||
|
@ -69,7 +71,7 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
Truth8.assertThat(lockOptional.get().getLockCompletionTimestamp()).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testBackfill_onlyLockedDomains() throws Exception {
|
||||
DomainBase neverLockedDomain = persistActiveDomain("neverlocked.tld");
|
||||
DomainBase previouslyLockedDomain = persistLockedDomain("unlocked.tld");
|
||||
|
@ -89,7 +91,7 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
assertThat(Iterables.getOnlyElement(locks).getDomainName()).isEqualTo("locked.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testBackfill_skipsDeletedDomains() throws Exception {
|
||||
DomainBase domain = persistDeletedDomain("example.tld", fakeClock.nowUtc());
|
||||
persistResource(domain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build());
|
||||
|
@ -98,7 +100,7 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
Truth8.assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId())).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testBackfill_skipsDomains_ifLockAlreadyExists() throws Exception {
|
||||
DomainBase domain = persistLockedDomain("example.tld");
|
||||
|
||||
|
@ -123,7 +125,7 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
.isEqualTo(previousLock.getLockCompletionTimestamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testBackfill_usesUrsTime_ifExists() throws Exception {
|
||||
DateTime ursTime = fakeClock.nowUtc();
|
||||
DomainBase ursDomain = persistLockedDomain("urs.tld");
|
||||
|
@ -151,7 +153,7 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
assertThat(nonUrsLock.getLockCompletionTimestamp()).hasValue(fakeClock.nowUtc());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_mustProvideDomainRoids() {
|
||||
assertThat(assertThrows(IllegalArgumentException.class, this::runCommandForced))
|
||||
.hasMessageThat()
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1997-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1997-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1997-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
@ -47,7 +47,7 @@
|
|||
},
|
||||
{
|
||||
"eventAction": "deletion",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "evilregistrar",
|
||||
"eventDate": "1999-07-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1997-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1997-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1997-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "unicoderegistrar",
|
||||
"eventDate": "1999-09-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
@ -44,7 +44,7 @@
|
|||
},
|
||||
{
|
||||
"eventAction": "transfer",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "unicoderegistrar",
|
||||
"eventDate": "1999-12-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "unicoderegistrar",
|
||||
"eventDate": "1999-09-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
@ -44,7 +44,7 @@
|
|||
},
|
||||
{
|
||||
"eventAction": "transfer",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "unicoderegistrar",
|
||||
"eventDate": "1999-12-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "unicoderegistrar",
|
||||
"eventDate": "2000-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"events": [
|
||||
{
|
||||
"eventAction": "registration",
|
||||
"eventActor": "foo",
|
||||
"eventActor": "TheRegistrar",
|
||||
"eventDate": "1999-01-01T00:00:00.000Z"
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue