Skip to content

Commit cffca0c

Browse files
committed
Remove various ContactHistory references
This keeps the ContactHistory class and tests, to avoid changing any database-related code in this PR.
1 parent 71c9407 commit cffca0c

File tree

9 files changed

+22
-158
lines changed

9 files changed

+22
-158
lines changed

core/src/main/java/google/registry/flows/FlowModule.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import dagger.Module;
2323
import dagger.Provides;
2424
import google.registry.flows.picker.FlowPicker;
25-
import google.registry.model.contact.ContactHistory;
2625
import google.registry.model.domain.DomainHistory;
2726
import google.registry.model.domain.metadata.MetadataExtension;
2827
import google.registry.model.eppcommon.AuthInfo;
@@ -267,23 +266,6 @@ B makeHistoryEntryBuilder(
267266
return builder;
268267
}
269268

270-
/**
271-
* Provides a partially filled in {@link ContactHistory.Builder}
272-
*
273-
* <p>This is not marked with {@link FlowScope} so that each retry gets a fresh one. Otherwise,
274-
* the fact that the builder is one-use would cause NPEs.
275-
*/
276-
@Provides
277-
static ContactHistory.Builder provideContactHistoryBuilder(
278-
Trid trid,
279-
@InputXml byte[] inputXmlBytes,
280-
@Superuser boolean isSuperuser,
281-
@RegistrarId String registrarId,
282-
EppInput eppInput) {
283-
return makeHistoryEntryBuilder(
284-
new ContactHistory.Builder(), trid, inputXmlBytes, isSuperuser, registrarId, eppInput);
285-
}
286-
287269
/**
288270
* Provides a partially filled in {@link HostHistory.Builder}
289271
*

core/src/main/java/google/registry/model/poll/PollMessage.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import google.registry.model.annotations.ExternalMessagingName;
2828
import google.registry.model.annotations.IdAllocation;
2929
import google.registry.model.contact.Contact;
30-
import google.registry.model.contact.ContactHistory;
3130
import google.registry.model.domain.Domain;
3231
import google.registry.model.domain.DomainHistory;
3332
import google.registry.model.domain.DomainRenewData;
@@ -272,12 +271,6 @@ public B setDomainHistoryId(HistoryEntryId historyId) {
272271
return thisCastToDerived();
273272
}
274273

275-
public B setContactHistoryId(HistoryEntryId historyId) {
276-
getInstance().contactRepoId = historyId.getRepoId();
277-
getInstance().contactHistoryRevisionId = historyId.getRevisionId();
278-
return thisCastToDerived();
279-
}
280-
281274
public B setHostHistoryId(HistoryEntryId historyId) {
282275
getInstance().hostRepoId = historyId.getRepoId();
283276
getInstance().hostHistoryRevisionId = historyId.getRevisionId();
@@ -290,9 +283,6 @@ public B setHistoryEntry(HistoryEntry history) {
290283
if (history instanceof DomainHistory) {
291284
return setDomainHistoryId(historyId);
292285
}
293-
if (history instanceof ContactHistory) {
294-
return setContactHistoryId(historyId);
295-
}
296286
if (history instanceof HostHistory) {
297287
return setHostHistoryId(historyId);
298288
}

core/src/main/java/google/registry/model/reporting/HistoryEntry.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import google.registry.model.ImmutableObject;
2424
import google.registry.model.UnsafeSerializable;
2525
import google.registry.model.annotations.IdAllocation;
26-
import google.registry.model.contact.ContactBase;
27-
import google.registry.model.contact.ContactHistory;
2826
import google.registry.model.domain.DomainBase;
2927
import google.registry.model.domain.DomainHistory;
3028
import google.registry.model.eppcommon.Trid;
@@ -348,8 +346,6 @@ public B setRequestedByRegistrar(Boolean requestedByRegistrar) {
348346
HistoryEntry.Builder<? extends HistoryEntry, ?> createBuilderForResource(E parent) {
349347
if (parent instanceof DomainBase) {
350348
return new DomainHistory.Builder().setDomain((DomainBase) parent);
351-
} else if (parent instanceof ContactBase) {
352-
return new ContactHistory.Builder().setContact((ContactBase) parent);
353349
} else if (parent instanceof HostBase) {
354350
return new HostHistory.Builder().setHost((HostBase) parent);
355351
} else {

core/src/main/java/google/registry/model/reporting/HistoryEntryDao.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import com.google.common.collect.ImmutableMap;
2626
import com.google.common.collect.Streams;
2727
import google.registry.model.EppResource;
28-
import google.registry.model.contact.Contact;
29-
import google.registry.model.contact.ContactHistory;
3028
import google.registry.model.domain.Domain;
3129
import google.registry.model.domain.DomainHistory;
3230
import google.registry.model.host.Host;
@@ -46,8 +44,6 @@ public class HistoryEntryDao {
4644
public static ImmutableMap<Class<? extends EppResource>, Class<? extends HistoryEntry>>
4745
RESOURCE_TYPES_TO_HISTORY_TYPES =
4846
ImmutableMap.of(
49-
Contact.class,
50-
ContactHistory.class,
5147
Domain.class,
5248
DomainHistory.class,
5349
Host.class,
@@ -59,7 +55,6 @@ public static ImmutableList<HistoryEntry> loadAllHistoryObjects(
5955
return tm().transact(
6056
() ->
6157
new ImmutableList.Builder<HistoryEntry>()
62-
.addAll(loadAllHistoryObjects(ContactHistory.class, afterTime, beforeTime))
6358
.addAll(loadAllHistoryObjects(DomainHistory.class, afterTime, beforeTime))
6459
.addAll(loadAllHistoryObjects(HostHistory.class, afterTime, beforeTime))
6560
.build());
@@ -121,7 +116,6 @@ public static Iterable<HistoryEntry> loadHistoryObjectsByRegistrars(
121116
return tm().reTransact(
122117
() ->
123118
Streams.concat(
124-
loadHistoryObjectByRegistrarsInternal(ContactHistory.class, registrarIds),
125119
loadHistoryObjectByRegistrarsInternal(DomainHistory.class, registrarIds),
126120
loadHistoryObjectByRegistrarsInternal(HostHistory.class, registrarIds))
127121
.sorted(Comparator.comparing(HistoryEntry::getModificationTime))

core/src/test/java/google/registry/beam/resave/ResaveAllEppResourcesPipelineTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static google.registry.testing.DatabaseHelper.loadByEntity;
2323
import static google.registry.testing.DatabaseHelper.persistActiveContact;
2424
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
25-
import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer;
2625
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
2726
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
2827
import static google.registry.testing.DatabaseHelper.persistNewRegistrars;
@@ -89,18 +88,6 @@ void testPipeline_unchangedEntity() {
8988
assertThat(loadByEntity(contact)).isEqualTo(contact);
9089
}
9190

92-
@Test
93-
void testPipeline_fulfilledContactTransfer() {
94-
Contact contact = persistActiveContact("test123");
95-
DateTime now = fakeClock.nowUtc();
96-
contact = persistContactWithPendingTransfer(contact, now, now.plusDays(5), now);
97-
fakeClock.advanceBy(Duration.standardDays(10));
98-
assertThat(loadByEntity(contact).getStatusValues()).contains(StatusValue.PENDING_TRANSFER);
99-
runPipeline();
100-
assertThat(loadByEntity(contact).getStatusValues())
101-
.doesNotContain(StatusValue.PENDING_TRANSFER);
102-
}
103-
10491
@Test
10592
void testPipeline_fulfilledDomainTransfer() {
10693
options.setFast(true);

core/src/test/java/google/registry/flows/ResourceFlowTestCase.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
import com.google.common.testing.TestLogHandler;
2525
import google.registry.model.EppResource;
2626
import google.registry.model.ForeignKeyUtils;
27-
import google.registry.model.contact.ContactBase;
28-
import google.registry.model.contact.ContactHistory;
2927
import google.registry.model.domain.DomainBase;
3028
import google.registry.model.domain.DomainHistory;
3129
import google.registry.model.eppinput.EppInput.ResourceCommandWrapper;
3230
import google.registry.model.eppinput.ResourceCommand;
33-
import google.registry.model.host.HostBase;
3431
import google.registry.model.host.HostHistory;
3532
import google.registry.model.reporting.HistoryEntry;
3633
import google.registry.model.tmch.ClaimsList;
@@ -131,18 +128,12 @@ protected void assertIcannReportingActivityFieldLogged(String fieldName) {
131128

132129
protected void assertLastHistoryContainsResource(EppResource resource) {
133130
HistoryEntry historyEntry = Iterables.getLast(DatabaseHelper.getHistoryEntries(resource));
134-
if (resource instanceof ContactBase) {
135-
ContactHistory contactHistory = (ContactHistory) historyEntry;
136-
// Don't use direct equals comparison since one might be a subclass of the other
137-
assertAboutImmutableObjects()
138-
.that(contactHistory.getContactBase().get())
139-
.hasFieldsEqualTo(resource);
140-
} else if (resource instanceof DomainBase) {
131+
if (resource instanceof DomainBase) {
141132
DomainHistory domainHistory = (DomainHistory) historyEntry;
142133
assertAboutImmutableObjects()
143134
.that(domainHistory.getDomainBase().get())
144135
.isEqualExceptFields(resource, "gracePeriods", "dsData", "nsHosts");
145-
} else if (resource instanceof HostBase) {
136+
} else {
146137
HostHistory hostHistory = (HostHistory) historyEntry;
147138
// Don't use direct equals comparison since one might be a subclass of the other
148139
assertAboutImmutableObjects()

core/src/test/java/google/registry/flows/poll/PollRequestFlowTest.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import google.registry.flows.FlowTestCase;
2929
import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException;
3030
import google.registry.model.contact.Contact;
31-
import google.registry.model.contact.ContactHistory;
3231
import google.registry.model.domain.Domain;
3332
import google.registry.model.eppcommon.Trid;
3433
import google.registry.model.host.Host;
@@ -225,29 +224,6 @@ void testSuccess_futureAutorenew() throws Exception {
225224
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
226225
}
227226

228-
@Test
229-
void testSuccess_contactDelete() throws Exception {
230-
// Contact delete poll messages do not have any response data, so ensure that no
231-
// response data block is produced in the poll message.
232-
HistoryEntry historyEntry =
233-
persistResource(
234-
new ContactHistory.Builder()
235-
.setRegistrarId("NewRegistrar")
236-
.setModificationTime(clock.nowUtc().minusDays(1))
237-
.setType(HistoryEntry.Type.CONTACT_DELETE)
238-
.setContact(contact)
239-
.build());
240-
persistResource(
241-
new PollMessage.OneTime.Builder()
242-
.setRegistrarId("NewRegistrar")
243-
.setMsg("Deleted contact jd1234")
244-
.setHistoryEntry(historyEntry)
245-
.setEventTime(clock.nowUtc().minusDays(1))
246-
.build());
247-
assertMutatingFlow(false);
248-
runFlowAssertResponse(loadFile("poll_response_contact_delete.xml"));
249-
}
250-
251227
@Test
252228
void testSuccess_hostDelete() throws Exception {
253229
// Host delete poll messages do not have any response data, so ensure that no

core/src/test/java/google/registry/model/reporting/HistoryEntryTest.java

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,33 @@
1818
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
1919
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
2020
import static google.registry.testing.DatabaseHelper.createTld;
21-
import static google.registry.testing.DatabaseHelper.persistActiveContact;
2221
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
2322
import static google.registry.testing.DatabaseHelper.persistResource;
2423
import static java.nio.charset.StandardCharsets.UTF_8;
2524
import static org.junit.Assert.assertThrows;
2625

2726
import com.google.common.collect.ImmutableSet;
2827
import google.registry.model.EntityTestCase;
29-
import google.registry.model.contact.Contact;
30-
import google.registry.model.contact.ContactHistory;
3128
import google.registry.model.domain.Domain;
3229
import google.registry.model.domain.DomainHistory;
3330
import google.registry.model.domain.Period;
3431
import google.registry.model.eppcommon.Trid;
3532
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
33+
import google.registry.model.reporting.HistoryEntry.Type;
3634
import org.joda.time.DateTime;
3735
import org.junit.jupiter.api.BeforeEach;
3836
import org.junit.jupiter.api.Test;
3937

4038
/** Unit tests for {@link HistoryEntry}. */
4139
class HistoryEntryTest extends EntityTestCase {
4240

41+
private Domain domain;
4342
private DomainHistory domainHistory;
44-
private Contact contact;
4543

4644
@BeforeEach
4745
void setUp() {
4846
createTld("foobar");
49-
Domain domain = persistActiveDomain("foo.foobar");
50-
contact = persistActiveContact("someone");
47+
domain = persistActiveDomain("foo.foobar");
5148
DomainTransactionRecord transactionRecord =
5249
new DomainTransactionRecord.Builder()
5350
.setTld("foobar")
@@ -91,12 +88,12 @@ void testBuilder_resourceMustBeSpecified() {
9188
assertThrows(
9289
IllegalArgumentException.class,
9390
() ->
94-
new ContactHistory.Builder()
91+
new DomainHistory.Builder()
9592
.setRevisionId(5L)
9693
.setModificationTime(DateTime.parse("1985-07-12T22:30:00Z"))
9794
.setRegistrarId("TheRegistrar")
9895
.setReason("Reason")
99-
.setType(HistoryEntry.Type.CONTACT_CREATE)
96+
.setType(Type.DOMAIN_CREATE)
10097
.build());
10198
assertThat(thrown).hasMessageThat().isEqualTo("EPP resource must be specified");
10299
}
@@ -107,10 +104,10 @@ void testBuilder_typeMustBeSpecified() {
107104
assertThrows(
108105
IllegalArgumentException.class,
109106
() ->
110-
new ContactHistory.Builder()
111-
.setContact(contact)
107+
new DomainHistory.Builder()
112108
.setRevisionId(5L)
113-
.setModificationTime(DateTime.parse("1985-07-12T22:30:00Z"))
109+
.setDomain(domain)
110+
.setModificationTime(DateTime.parse("1985-07-12T22:30.00Z"))
114111
.setRegistrarId("TheRegistrar")
115112
.setReason("Reason")
116113
.build());
@@ -123,12 +120,12 @@ void testBuilder_modificationTimeMustBeSpecified() {
123120
assertThrows(
124121
IllegalArgumentException.class,
125122
() ->
126-
new ContactHistory.Builder()
127-
.setContact(contact)
123+
new DomainHistory.Builder()
128124
.setRevisionId(5L)
129-
.setType(HistoryEntry.Type.CONTACT_CREATE)
125+
.setDomain(domain)
126+
.setType(Type.DOMAIN_CREATE)
130127
.setRegistrarId("TheRegistrar")
131-
.setReason("Reason")
128+
.setReason("reason")
132129
.build());
133130
assertThat(thrown).hasMessageThat().isEqualTo("Modification time must be specified");
134131
}
@@ -139,11 +136,11 @@ void testBuilder_registrarIdMustBeSpecified() {
139136
assertThrows(
140137
IllegalArgumentException.class,
141138
() ->
142-
new ContactHistory.Builder()
139+
new DomainHistory.Builder()
143140
.setRevisionId(5L)
144-
.setContact(contact)
145-
.setType(HistoryEntry.Type.CONTACT_CREATE)
146-
.setModificationTime(DateTime.parse("1985-07-12T22:30:00Z"))
141+
.setDomain(domain)
142+
.setType(Type.DOMAIN_CREATE)
143+
.setModificationTime(DateTime.parse("1985-07-12T22:30.00Z"))
147144
.setReason("Reason")
148145
.build());
149146
assertThat(thrown).hasMessageThat().isEqualTo("Registrar ID must be specified");
@@ -155,11 +152,11 @@ void testBuilder_syntheticHistoryEntries_mustNotBeRequestedByRegistrar() {
155152
assertThrows(
156153
IllegalArgumentException.class,
157154
() ->
158-
new ContactHistory.Builder()
159-
.setContact(contact)
155+
new DomainHistory.Builder()
160156
.setRevisionId(5L)
161-
.setType(HistoryEntry.Type.SYNTHETIC)
162-
.setModificationTime(DateTime.parse("1985-07-12T22:30:00Z"))
157+
.setDomain(domain)
158+
.setType(Type.SYNTHETIC)
159+
.setModificationTime(DateTime.parse("1985-07-12T22:30.00Z"))
163160
.setRegistrarId("TheRegistrar")
164161
.setReason("Reason")
165162
.setRequestedByRegistrar(true)

0 commit comments

Comments
 (0)