From 48a1bacbb00de310ff95b531f639b2e8f54b1e2c Mon Sep 17 00:00:00 2001 From: mcilwain Date: Tue, 27 Dec 2016 09:17:01 -0800 Subject: [PATCH] Get rid of the delete() method on ReservedList It wasn't being used by any actual code, and having helper methods handling saving/persistence on entities like this is not a pattern we want to encourage, since it hides Datastore transactions from further up in the call chain. The idea is that you can always look for ofy() calls in the same layer of code to see where persisted data is being changed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143036027 --- .../model/registry/label/ReservedList.java | 18 ------------------ .../model/registry/label/ReservedListTest.java | 14 -------------- 2 files changed, 32 deletions(-) diff --git a/java/google/registry/model/registry/label/ReservedList.java b/java/google/registry/model/registry/label/ReservedList.java index 413f337ca..9c0764d96 100644 --- a/java/google/registry/model/registry/label/ReservedList.java +++ b/java/google/registry/model/registry/label/ReservedList.java @@ -16,7 +16,6 @@ package google.registry.model.registry.label; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION; @@ -36,7 +35,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; import com.google.common.util.concurrent.UncheckedExecutionException; import com.googlecode.objectify.Key; -import com.googlecode.objectify.VoidWork; import com.googlecode.objectify.annotation.Cache; import com.googlecode.objectify.annotation.Embed; import com.googlecode.objectify.annotation.Entity; @@ -234,22 +232,6 @@ public final class ReservedList return ofy().load().type(ReservedList.class).parent(getCrossTldKey()).id(listName).now(); }}); - /** Deletes the ReservedList with the given name. */ - public static void delete(final String listName) { - final ReservedList reservedList = ReservedList.get(listName).orNull(); - checkState( - reservedList != null, - "Attempted to delete reserved list %s which doesn't exist", - listName); - ofy().transactNew(new VoidWork() { - @Override - public void vrun() { - ofy().delete().entity(reservedList).now(); - } - }); - cache.invalidate(listName); - } - /** * Gets the {@link ReservationType} of a label in a single ReservedList, or returns an absent * Optional if none exists in the list. diff --git a/javatests/google/registry/model/registry/label/ReservedListTest.java b/javatests/google/registry/model/registry/label/ReservedListTest.java index 0d7c09163..ba8738efc 100644 --- a/javatests/google/registry/model/registry/label/ReservedListTest.java +++ b/javatests/google/registry/model/registry/label/ReservedListTest.java @@ -232,14 +232,6 @@ public class ReservedListTest { assertThat(rl.isInUse()).isFalse(); } - @Test - public void testDelete() throws Exception { - persistReservedList("reserved", "trombone,FULLY_BLOCKED"); - assertThat(ReservedList.get("reserved")).isPresent(); - ReservedList.delete("reserved"); - assertThat(ReservedList.get("reserved")).isAbsent(); - } - @Test public void testSetFromInputLines() throws Exception { ReservedList reservedList = persistReservedList("reserved", "trombone,FULLY_BLOCKED"); @@ -263,12 +255,6 @@ public class ReservedListTest { assertThat(original.getReservedListEntries()).isEqualTo(clone.getReservedListEntries()); } - @Test - public void testDelete_failsWhenListDoesntExist() throws Exception { - thrown.expect(IllegalStateException.class); - ReservedList.delete("reserved"); - } - @Test public void testSave_badSyntax() throws Exception { thrown.expect(IllegalArgumentException.class, "Could not parse line in reserved list");