Remove EppResource.SharedFields following successful data migration

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117412736
This commit is contained in:
mcilwain 2016-03-16 20:29:38 -07:00 committed by Justine Tunney
parent 401df6c34a
commit 99a50f7972
8 changed files with 6 additions and 222 deletions

View file

@ -4,55 +4,28 @@
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="ContactResource" ancestor="false" source="manual">
<property name="sharedFields.currentSponsorClientId" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For finding domain resources by registrar. --> <!-- For finding domain resources by registrar. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/> <property name="^i" direction="asc"/>
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="sharedFields.currentSponsorClientId" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For finding domain resources by tld. --> <!-- For finding domain resources by tld. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/> <property name="^i" direction="asc"/>
<property name="tld" direction="asc"/> <property name="tld" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="tld" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For finding domain resources by registrar. --> <!-- For finding domain resources by registrar. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="sharedFields.currentSponsorClientId" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For finding host resources by registrar. --> <!-- For finding host resources by registrar. -->
<datastore-index kind="HostResource" ancestor="false" source="manual"> <datastore-index kind="HostResource" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="HostResource" ancestor="false" source="manual">
<property name="sharedFields.currentSponsorClientId" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For finding account balance of Registrar and viewing billing history. --> <!-- For finding account balance of Registrar and viewing billing history. -->
<datastore-index kind="RegistrarBillingEntry" ancestor="true" source="manual"> <datastore-index kind="RegistrarBillingEntry" ancestor="true" source="manual">
<property name="currency" direction="asc"/> <property name="currency" direction="asc"/>
@ -63,43 +36,22 @@
<property name="allContacts.contactId.linked" direction="asc"/> <property name="allContacts.contactId.linked" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="allContacts.contactId.linked" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For determining the active domains linked to a given host. --> <!-- For determining the active domains linked to a given host. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="nameservers.linked" direction="asc"/> <property name="nameservers.linked" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="nameservers.linked" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For updating domains and applications after a host rename. --> <!-- For updating domains and applications after a host rename. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/> <property name="^i" direction="asc"/>
<property name="nameservers.linked" direction="asc"/> <property name="nameservers.linked" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="nameservers.linked" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For Whois ip lookup --> <!-- For Whois ip lookup -->
<datastore-index kind="HostResource" ancestor="false" source="manual"> <datastore-index kind="HostResource" ancestor="false" source="manual">
<property name="inetAddresses" direction="asc"/> <property name="inetAddresses" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="HostResource" ancestor="false" source="manual">
<property name="inetAddresses" direction="asc"/>
<property name="sharedFields.deletionTime" direction="asc"/>
</datastore-index>
<!-- For Poll --> <!-- For Poll -->
<datastore-index kind="PollMessage" ancestor="false" source="manual"> <datastore-index kind="PollMessage" ancestor="false" source="manual">
<property name="clientId" direction="asc"/> <property name="clientId" direction="asc"/>
@ -128,9 +80,4 @@
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
<property name="fullyQualifiedHostName" direction="asc"/> <property name="fullyQualifiedHostName" direction="asc"/>
</datastore-index> </datastore-index>
<!-- TODO(b/19035583): Remove sharedFields indexes. -->
<datastore-index kind="HostResource" ancestor="false" source="manual">
<property name="sharedFields.deletionTime" direction="asc"/>
<property name="fullyQualifiedHostName" direction="asc"/>
</datastore-index>
</datastore-indexes> </datastore-indexes>

View file

@ -22,7 +22,6 @@ import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.google.domain.registry.model.eppcommon.StatusValue; import com.google.domain.registry.model.eppcommon.StatusValue;
@ -31,11 +30,8 @@ import com.google.domain.registry.model.ofy.CommitLogManifest;
import com.google.domain.registry.model.transfer.TransferData; import com.google.domain.registry.model.transfer.TransferData;
import com.googlecode.objectify.Ref; import com.googlecode.objectify.Ref;
import com.googlecode.objectify.annotation.Embed;
import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.condition.IfNull;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -57,13 +53,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
@XmlElement(name = "roid") @XmlElement(name = "roid")
String repoId; String repoId;
/** The shared fields for this resource. */
// TODO(b/19035583): Remove this after touching all resources and waiting long enough to be sure
// we don't need to reload old commit logs.
@XmlTransient
@Deprecated
SharedFields sharedFields = new SharedFields();
/** The ID of the registrar that is currently sponsoring this resource. */ /** The ID of the registrar that is currently sponsoring this resource. */
@Index @Index
@XmlElement(name = "clID") @XmlElement(name = "clID")
@ -209,69 +198,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
/** EppResources that are loaded via foreign keys should implement this marker interface. */ /** EppResources that are loaded via foreign keys should implement this marker interface. */
public interface ForeignKeyedEppResource {} public interface ForeignKeyedEppResource {}
/** Common shared fields for {@link EppResource} types. */
//TODO(b/19035583): Delete this class.
@Embed
public static class SharedFields extends ImmutableObject {
/** The id of the registry client that is currently sponsoring this resource. */
@Index
String currentSponsorClientId;
/** The ID of the registry client that created this resource. */
String creationRegistryClientId;
/**
* The ID of the last registry client to update this resource. This does not refer to the last
* delta made on this object, which might include transfer flows or out-of-band edits; a
* resource must literally have had an EPP {@literal <update>} called on it for this field to be
* set. Can be null if the resource has never had {@literal <update>} called on it.
*/
@IgnoreSave(IfNull.class)
String lastUpdateRegistryClientId;
/** The time when this resource was created. */
@XmlTransient
CreateAutoTimestamp creationTime = CreateAutoTimestamp.create(null);
/**
* The time when this resource was or will be deleted.
* <p>
* For deleted resources, this is in the past.
* For pending-delete resources, this is in the near future.
* For active resources, this is {@code END_OF_TIME}.
* <p>
* This scheme allows for setting pending deletes in the future and having them magically drop
* out of the index at that time, as long as we query for resources whose delete time is
* before now.
*/
@Index
DateTime deletionTime;
/**
* The time that this resource was last updated. Can be null if the resource has never had
* {@literal <update>} called on it.
*/
@IgnoreSave(IfNull.class)
DateTime lastUpdateTime;
/**
* The time that this resource was last transferred. Can be null if the resource has never been
* transferred.
*/
@IgnoreSave(IfNull.class)
DateTime lastTransferTime;
/** Legacy field for status values associated with this resource. */
// TODO(b/25442343): Remove this.
@XmlTransient
Set<StatusValue.LegacyStatusValue> statusValues;
/** Data about any pending or past transfers on this contact. */
@IgnoreSave(IfNull.class)
TransferData transferData;
}
/** Abstract builder for {@link EppResource} types. */ /** Abstract builder for {@link EppResource} types. */
public abstract static class Builder<T extends EppResource, B extends Builder<?, ?>> public abstract static class Builder<T extends EppResource, B extends Builder<?, ?>>
extends GenericBuilder<T, B> { extends GenericBuilder<T, B> {
@ -282,76 +208,54 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
/** Create a {@link Builder} wrapping the given instance. */ /** Create a {@link Builder} wrapping the given instance. */
protected Builder(T instance) { protected Builder(T instance) {
super(instance); super(instance);
// Clone the SharedFields since the setters on this builder mutate its fields directly.
instance.sharedFields = ImmutableObject.clone(instance.sharedFields);
} }
/** Set the time this resource was created. Should only be used in tests. */ /** Set the time this resource was created. Should only be used in tests. */
@VisibleForTesting @VisibleForTesting
public B setCreationTimeForTest(DateTime creationTime) { public B setCreationTimeForTest(DateTime creationTime) {
getInstance().creationTime = CreateAutoTimestamp.create(creationTime); getInstance().creationTime = CreateAutoTimestamp.create(creationTime);
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.creationTime = CreateAutoTimestamp.create(creationTime);
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set the time after which this resource should be considered deleted. */ /** Set the time after which this resource should be considered deleted. */
public B setDeletionTime(DateTime deletionTime) { public B setDeletionTime(DateTime deletionTime) {
getInstance().deletionTime = deletionTime; getInstance().deletionTime = deletionTime;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.deletionTime = deletionTime;
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set the current sponsoring registrar. */ /** Set the current sponsoring registrar. */
public B setCurrentSponsorClientId(String currentSponsorClientId) { public B setCurrentSponsorClientId(String currentSponsorClientId) {
getInstance().currentSponsorClientId = currentSponsorClientId; getInstance().currentSponsorClientId = currentSponsorClientId;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.currentSponsorClientId = currentSponsorClientId;
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set the registrar that created this resource. */ /** Set the registrar that created this resource. */
public B setCreationClientId(String creationClientId) { public B setCreationClientId(String creationClientId) {
getInstance().creationClientId = creationClientId; getInstance().creationClientId = creationClientId;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.creationRegistryClientId = creationClientId;
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set the time when a {@literal <update>} was performed on this resource. */ /** Set the time when a {@literal <update>} was performed on this resource. */
public B setLastEppUpdateTime(DateTime lastEppUpdateTime) { public B setLastEppUpdateTime(DateTime lastEppUpdateTime) {
getInstance().lastEppUpdateTime = lastEppUpdateTime; getInstance().lastEppUpdateTime = lastEppUpdateTime;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.lastUpdateTime = lastEppUpdateTime;
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set the registrar who last performed a {@literal <update>} on this resource. */ /** Set the registrar who last performed a {@literal <update>} on this resource. */
public B setLastEppUpdateClientId(String lastEppUpdateClientId) { public B setLastEppUpdateClientId(String lastEppUpdateClientId) {
getInstance().lastEppUpdateClientId = lastEppUpdateClientId; getInstance().lastEppUpdateClientId = lastEppUpdateClientId;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.lastUpdateRegistryClientId = lastEppUpdateClientId;
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set the time when this resource was transferred. */ /** Set the time when this resource was transferred. */
public B setLastTransferTime(DateTime lastTransferTime) { public B setLastTransferTime(DateTime lastTransferTime) {
getInstance().lastTransferTime = lastTransferTime; getInstance().lastTransferTime = lastTransferTime;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.lastTransferTime = lastTransferTime;
return thisCastToDerived(); return thisCastToDerived();
} }
/** Set this resource's status values. */ /** Set this resource's status values. */
public B setStatusValues(ImmutableSet<StatusValue> statusValues) { public B setStatusValues(ImmutableSet<StatusValue> statusValues) {
getInstance().status = statusValues; getInstance().status = statusValues;
// TODO(b/25442343): Stop setting the legacy field.
getInstance().sharedFields.statusValues = statusValues == null
? null
: FluentIterable.from(statusValues)
.transform(StatusValue.LEGACY_CONVERTER)
.toSet();
return thisCastToDerived(); return thisCastToDerived();
} }
@ -380,8 +284,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
/** Set this resource's transfer data. */ /** Set this resource's transfer data. */
public B setTransferData(TransferData transferData) { public B setTransferData(TransferData transferData) {
getInstance().transferData = transferData; getInstance().transferData = transferData;
// TODO(b/19035583): Stop setting the legacy field.
getInstance().sharedFields.transferData = transferData;
return thisCastToDerived(); return thisCastToDerived();
} }

View file

@ -24,8 +24,6 @@ import static com.google.domain.registry.testing.DatastoreHelper.persistResource
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.EntityTestCase; import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.EppResource;
import com.google.domain.registry.model.EppResource.SharedFields;
import com.google.domain.registry.model.billing.BillingEvent; import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.contact.Disclose.PostalInfoChoice; import com.google.domain.registry.model.contact.Disclose.PostalInfoChoice;
import com.google.domain.registry.model.contact.PostalInfo.Type; import com.google.domain.registry.model.contact.PostalInfo.Type;
@ -44,8 +42,6 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.lang.reflect.Field;
/** Unit tests for {@link ContactResource}. */ /** Unit tests for {@link ContactResource}. */
public class ContactResourceTest extends EntityTestCase { public class ContactResourceTest extends EntityTestCase {
@ -134,9 +130,7 @@ public class ContactResourceTest extends EntityTestCase {
verifyIndexing( verifyIndexing(
contactResource, contactResource,
"deletionTime", "deletionTime",
"currentSponsorClientId", "currentSponsorClientId");
"sharedFields.deletionTime",
"sharedFields.currentSponsorClientId");
} }
@Test @Test
@ -173,12 +167,7 @@ public class ContactResourceTest extends EntityTestCase {
ContactResource withNull = new ContactResource.Builder().setTransferData(null).build(); ContactResource withNull = new ContactResource.Builder().setTransferData(null).build();
ContactResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build(); ContactResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty); assertThat(withNull).isEqualTo(withEmpty);
// We don't have package access to SharedFields so we need to use reflection to check for null. assertThat(withEmpty.hasTransferData()).isFalse();
Field sharedFieldsField = EppResource.class.getDeclaredField("sharedFields");
sharedFieldsField.setAccessible(true);
Field transferDataField = SharedFields.class.getDeclaredField("transferData");
transferDataField.setAccessible(true);
assertThat(transferDataField.get(sharedFieldsField.get(withEmpty))).isNull();
} }
@Test @Test

View file

@ -28,8 +28,6 @@ import static org.joda.money.CurrencyUnit.USD;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.EntityTestCase; import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.EppResource;
import com.google.domain.registry.model.EppResource.SharedFields;
import com.google.domain.registry.model.billing.BillingEvent; import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.domain.launch.ApplicationStatus; import com.google.domain.registry.model.domain.launch.ApplicationStatus;
import com.google.domain.registry.model.domain.launch.LaunchNotice; import com.google.domain.registry.model.domain.launch.LaunchNotice;
@ -52,8 +50,6 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.lang.reflect.Field;
/** Unit tests for {@link DomainApplication}. */ /** Unit tests for {@link DomainApplication}. */
public class DomainApplicationTest extends EntityTestCase { public class DomainApplicationTest extends EntityTestCase {
@ -131,8 +127,6 @@ public class DomainApplicationTest extends EntityTestCase {
"nameservers.linked", "nameservers.linked",
"deletionTime", "deletionTime",
"currentSponsorClientId", "currentSponsorClientId",
"sharedFields.deletionTime",
"sharedFields.currentSponsorClientId",
"tld"); "tld");
} }
@ -186,11 +180,6 @@ public class DomainApplicationTest extends EntityTestCase {
DomainApplication withNull = emptyBuilder().setTransferData(null).build(); DomainApplication withNull = emptyBuilder().setTransferData(null).build();
DomainApplication withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build(); DomainApplication withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty); assertThat(withNull).isEqualTo(withEmpty);
// We don't have package access to SharedFields so we need to use reflection to check for null. assertThat(withEmpty.hasTransferData()).isFalse();
Field sharedFieldsField = EppResource.class.getDeclaredField("sharedFields");
sharedFieldsField.setAccessible(true);
Field transferDataField = SharedFields.class.getDeclaredField("transferData");
transferDataField.setAccessible(true);
assertThat(transferDataField.get(sharedFieldsField.get(withEmpty))).isNull();
} }
} }

View file

@ -31,8 +31,6 @@ import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.domain.registry.model.EntityTestCase; import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.EppResource;
import com.google.domain.registry.model.EppResource.SharedFields;
import com.google.domain.registry.model.billing.BillingEvent; import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.billing.BillingEvent.Reason;
import com.google.domain.registry.model.contact.ContactResource; import com.google.domain.registry.model.contact.ContactResource;
@ -60,7 +58,6 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.lang.reflect.Field;
import java.util.List; import java.util.List;
/** Unit tests for {@link DomainResource}. */ /** Unit tests for {@link DomainResource}. */
@ -165,8 +162,6 @@ public class DomainResourceTest extends EntityTestCase {
"nameservers.linked", "nameservers.linked",
"currentSponsorClientId", "currentSponsorClientId",
"deletionTime", "deletionTime",
"sharedFields.currentSponsorClientId",
"sharedFields.deletionTime",
"tld"); "tld");
} }
@ -221,12 +216,7 @@ public class DomainResourceTest extends EntityTestCase {
newDomainResource("example.com").asBuilder().setTransferData(null).build(); newDomainResource("example.com").asBuilder().setTransferData(null).build();
DomainResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build(); DomainResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty); assertThat(withNull).isEqualTo(withEmpty);
// We don't have package access to SharedFields so we need to use reflection to check for null. assertThat(withEmpty.hasTransferData()).isFalse();
Field sharedFieldsField = EppResource.class.getDeclaredField("sharedFields");
sharedFieldsField.setAccessible(true);
Field transferDataField = SharedFields.class.getDeclaredField("transferData");
transferDataField.setAccessible(true);
assertThat(transferDataField.get(sharedFieldsField.get(withEmpty))).isNull();
} }
@Test @Test

View file

@ -24,8 +24,6 @@ import static com.google.domain.registry.testing.HostResourceSubject.assertAbout
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.EntityTestCase; import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.EppResource;
import com.google.domain.registry.model.EppResource.SharedFields;
import com.google.domain.registry.model.billing.BillingEvent; import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.domain.DomainResource; import com.google.domain.registry.model.domain.DomainResource;
import com.google.domain.registry.model.eppcommon.StatusValue; import com.google.domain.registry.model.eppcommon.StatusValue;
@ -45,7 +43,6 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import java.lang.reflect.Field;
import java.net.InetAddress; import java.net.InetAddress;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -108,12 +105,10 @@ public class HostResourceTest extends EntityTestCase {
verifyIndexing( verifyIndexing(
persistResource(hostResource.cloneProjectedAtTime(clock.nowUtc())), persistResource(hostResource.cloneProjectedAtTime(clock.nowUtc())),
"deletionTime", "deletionTime",
"sharedFields.deletionTime",
"fullyQualifiedHostName", "fullyQualifiedHostName",
"inetAddresses", "inetAddresses",
"superordinateDomain", "superordinateDomain",
"currentSponsorClientId", "currentSponsorClientId");
"sharedFields.currentSponsorClientId");
} }
@Test @Test
@ -158,12 +153,7 @@ public class HostResourceTest extends EntityTestCase {
HostResource withNull = new HostResource.Builder().setTransferData(null).build(); HostResource withNull = new HostResource.Builder().setTransferData(null).build();
HostResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build(); HostResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty); assertThat(withNull).isEqualTo(withEmpty);
// We don't have package access to SharedFields so we need to use reflection to check for null. assertThat(withEmpty.hasTransferData()).isFalse();
Field sharedFieldsField = EppResource.class.getDeclaredField("sharedFields");
sharedFieldsField.setAccessible(true);
Field transferDataField = SharedFields.class.getDeclaredField("transferData");
transferDataField.setAccessible(true);
assertThat(transferDataField.get(sharedFieldsField.get(withEmpty))).isNull();
} }
@Test @Test

View file

@ -5,17 +5,6 @@ enum com.google.common.collect.BoundType {
class com.google.domain.registry.model.CreateAutoTimestamp { class com.google.domain.registry.model.CreateAutoTimestamp {
org.joda.time.DateTime timestamp; org.joda.time.DateTime timestamp;
} }
class com.google.domain.registry.model.EppResource$SharedFields {
com.google.domain.registry.model.CreateAutoTimestamp creationTime;
com.google.domain.registry.model.transfer.TransferData transferData;
java.lang.String creationRegistryClientId;
java.lang.String currentSponsorClientId;
java.lang.String lastUpdateRegistryClientId;
java.util.Set<com.google.domain.registry.model.eppcommon.StatusValue$LegacyStatusValue> statusValues;
org.joda.time.DateTime deletionTime;
org.joda.time.DateTime lastTransferTime;
org.joda.time.DateTime lastUpdateTime;
}
class com.google.domain.registry.model.UpdateAutoTimestamp { class com.google.domain.registry.model.UpdateAutoTimestamp {
org.joda.time.DateTime timestamp; org.joda.time.DateTime timestamp;
} }
@ -146,7 +135,6 @@ class com.google.domain.registry.model.contact.ContactResource {
@Id java.lang.String repoId; @Id java.lang.String repoId;
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions; com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions;
com.google.domain.registry.model.CreateAutoTimestamp creationTime; com.google.domain.registry.model.CreateAutoTimestamp creationTime;
com.google.domain.registry.model.EppResource$SharedFields sharedFields;
com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp; com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp;
com.google.domain.registry.model.contact.ContactAuthInfo authInfo; com.google.domain.registry.model.contact.ContactAuthInfo authInfo;
com.google.domain.registry.model.contact.ContactPhoneNumber fax; com.google.domain.registry.model.contact.ContactPhoneNumber fax;
@ -201,7 +189,6 @@ class com.google.domain.registry.model.domain.DomainApplication {
@Id java.lang.String repoId; @Id java.lang.String repoId;
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions; com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions;
com.google.domain.registry.model.CreateAutoTimestamp creationTime; com.google.domain.registry.model.CreateAutoTimestamp creationTime;
com.google.domain.registry.model.EppResource$SharedFields sharedFields;
com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp; com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp;
com.google.domain.registry.model.domain.DomainAuthInfo authInfo; com.google.domain.registry.model.domain.DomainAuthInfo authInfo;
com.google.domain.registry.model.domain.launch.ApplicationStatus applicationStatus; com.google.domain.registry.model.domain.launch.ApplicationStatus applicationStatus;
@ -232,7 +219,6 @@ class com.google.domain.registry.model.domain.DomainBase {
@Id java.lang.String repoId; @Id java.lang.String repoId;
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions; com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions;
com.google.domain.registry.model.CreateAutoTimestamp creationTime; com.google.domain.registry.model.CreateAutoTimestamp creationTime;
com.google.domain.registry.model.EppResource$SharedFields sharedFields;
com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp; com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp;
com.google.domain.registry.model.domain.DomainAuthInfo authInfo; com.google.domain.registry.model.domain.DomainAuthInfo authInfo;
com.google.domain.registry.model.domain.launch.LaunchNotice launchNotice; com.google.domain.registry.model.domain.launch.LaunchNotice launchNotice;
@ -255,7 +241,6 @@ class com.google.domain.registry.model.domain.DomainResource {
@Id java.lang.String repoId; @Id java.lang.String repoId;
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions; com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions;
com.google.domain.registry.model.CreateAutoTimestamp creationTime; com.google.domain.registry.model.CreateAutoTimestamp creationTime;
com.google.domain.registry.model.EppResource$SharedFields sharedFields;
com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp; com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp;
com.google.domain.registry.model.domain.DomainAuthInfo authInfo; com.google.domain.registry.model.domain.DomainAuthInfo authInfo;
com.google.domain.registry.model.domain.launch.LaunchNotice launchNotice; com.google.domain.registry.model.domain.launch.LaunchNotice launchNotice;
@ -370,9 +355,6 @@ enum com.google.domain.registry.model.eppcommon.StatusValue {
SERVER_TRANSFER_PROHIBITED; SERVER_TRANSFER_PROHIBITED;
SERVER_UPDATE_PROHIBITED; SERVER_UPDATE_PROHIBITED;
} }
class com.google.domain.registry.model.eppcommon.StatusValue$LegacyStatusValue {
java.lang.String xmlStatusValue;
}
class com.google.domain.registry.model.eppcommon.Trid { class com.google.domain.registry.model.eppcommon.Trid {
java.lang.String clientTransactionId; java.lang.String clientTransactionId;
java.lang.String serverTransactionId; java.lang.String serverTransactionId;
@ -387,7 +369,6 @@ class com.google.domain.registry.model.host.HostResource {
@Id java.lang.String repoId; @Id java.lang.String repoId;
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions; com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<com.google.domain.registry.model.ofy.CommitLogManifest>> revisions;
com.google.domain.registry.model.CreateAutoTimestamp creationTime; com.google.domain.registry.model.CreateAutoTimestamp creationTime;
com.google.domain.registry.model.EppResource$SharedFields sharedFields;
com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp; com.google.domain.registry.model.UpdateAutoTimestamp updateTimestamp;
com.google.domain.registry.model.transfer.TransferData transferData; com.google.domain.registry.model.transfer.TransferData transferData;
com.googlecode.objectify.Ref<com.google.domain.registry.model.domain.DomainResource> superordinateDomain; com.googlecode.objectify.Ref<com.google.domain.registry.model.domain.DomainResource> superordinateDomain;

View file

@ -108,11 +108,9 @@ public class MutatingCommandTest {
String changes = command.prompt(); String changes = command.prompt();
assertThat(changes).isEqualTo( assertThat(changes).isEqualTo(
"Update HostResource@2-ROID\n" "Update HostResource@2-ROID\n"
+ "sharedFields.lastUpdateTime -> [null, 2014-09-09T09:09:09.000Z]\n"
+ "lastEppUpdateTime -> [null, 2014-09-09T09:09:09.000Z]\n" + "lastEppUpdateTime -> [null, 2014-09-09T09:09:09.000Z]\n"
+ "\n" + "\n"
+ "Update HostResource@3-ROID\n" + "Update HostResource@3-ROID\n"
+ "sharedFields.currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n" + "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "\n" + "\n"
+ "Update Registrar@Registrar1\n" + "Update Registrar@Registrar1\n"
@ -240,7 +238,6 @@ public class MutatingCommandTest {
+ host1 + "\n" + host1 + "\n"
+ "\n" + "\n"
+ "Update HostResource@3-ROID\n" + "Update HostResource@3-ROID\n"
+ "sharedFields.currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n" + "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "\n" + "\n"
+ "Delete Registrar@Registrar1\n" + "Delete Registrar@Registrar1\n"
@ -281,7 +278,6 @@ public class MutatingCommandTest {
+ host1 + "\n" + host1 + "\n"
+ "\n" + "\n"
+ "Update HostResource@3-ROID\n" + "Update HostResource@3-ROID\n"
+ "sharedFields.currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n" + "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "\n" + "\n"
+ "Delete Registrar@Registrar1\n" + "Delete Registrar@Registrar1\n"