From 2caba95d28cd8509db85b0ff122b66e79bf8d728 Mon Sep 17 00:00:00 2001 From: ctingue Date: Tue, 12 Jul 2016 06:27:53 -0700 Subject: [PATCH] Tidy up ExpandrecurringBillingEventsAction Per nickfelt's suggestion on [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127193451 --- .../billing/ExpandRecurringBillingEventsAction.java | 7 ++----- javatests/google/registry/flows/FlowTestCase.java | 3 ++- .../registry/flows/contact/ContactInfoFlowTest.java | 3 --- .../google/registry/flows/host/HostInfoFlowTest.java | 4 ---- .../google/registry/flows/session/HelloFlowTest.java | 12 +----------- .../registry/flows/session/LogoutFlowTest.java | 4 ---- .../registry/rde/GhostrydeGpgIntegrationTest.java | 7 ++----- .../registry/rde/RegistrarToXjcConverterTest.java | 5 ++--- .../google/registry/rde/RydeGpgIntegrationTest.java | 7 ++----- .../google/registry/testing/ShardableTestCase.java | 1 + 10 files changed, 12 insertions(+), 41 deletions(-) diff --git a/java/google/registry/billing/ExpandRecurringBillingEventsAction.java b/java/google/registry/billing/ExpandRecurringBillingEventsAction.java index 525b63ac7..0fc7b1ede 100644 --- a/java/google/registry/billing/ExpandRecurringBillingEventsAction.java +++ b/java/google/registry/billing/ExpandRecurringBillingEventsAction.java @@ -241,11 +241,8 @@ public class ExpandRecurringBillingEventsAction implements Runnable { .filter(new Predicate() { @Override public boolean apply(OneTime billingEvent) { - Key cancellationMatchingBillingEvent = - billingEvent.getCancellationMatchingBillingEvent(); - return cancellationMatchingBillingEvent != null - && billingEvent.getCancellationMatchingBillingEvent().equals( - Key.create(recurringEvent)); + return Key.create(recurringEvent) + .equals(billingEvent.getCancellationMatchingBillingEvent()); }}) .transform(new Function() { @Override diff --git a/javatests/google/registry/flows/FlowTestCase.java b/javatests/google/registry/flows/FlowTestCase.java index 2c2bb8aa3..a0f7ffb79 100644 --- a/javatests/google/registry/flows/FlowTestCase.java +++ b/javatests/google/registry/flows/FlowTestCase.java @@ -50,6 +50,7 @@ import google.registry.testing.EppLoader; import google.registry.testing.FakeClock; import google.registry.testing.FakeHttpSession; import google.registry.testing.InjectRule; +import google.registry.testing.ShardableTestCase; import google.registry.util.TypeUtils.TypeInstantiator; import google.registry.xml.ValidationMode; @@ -68,7 +69,7 @@ import java.util.Map; * @param the flow type */ @RunWith(MockitoJUnitRunner.class) -public abstract class FlowTestCase { +public abstract class FlowTestCase extends ShardableTestCase { /** Whether to actually write to the datastore or just simulate. */ public enum CommitMode { LIVE, DRY_RUN } diff --git a/javatests/google/registry/flows/contact/ContactInfoFlowTest.java b/javatests/google/registry/flows/contact/ContactInfoFlowTest.java index 46e2ce90a..47ad1d137 100644 --- a/javatests/google/registry/flows/contact/ContactInfoFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactInfoFlowTest.java @@ -136,7 +136,4 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase { + @Test public void testHello() throws Exception { setEppInput("hello.xml"); @@ -35,15 +36,4 @@ public class HelloFlowTest extends FlowTestCase { "greeting_crr.xml", ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis())))); } - - // Extra methods so the test runner doesn't produce empty shards. - - @Test - public void testNothing1() {} - - @Test - public void testNothing2() {} - - @Test - public void testNothing3() {} } diff --git a/javatests/google/registry/flows/session/LogoutFlowTest.java b/javatests/google/registry/flows/session/LogoutFlowTest.java index 35a2a0f28..e59000889 100644 --- a/javatests/google/registry/flows/session/LogoutFlowTest.java +++ b/javatests/google/registry/flows/session/LogoutFlowTest.java @@ -52,8 +52,4 @@ public class LogoutFlowTest extends FlowTestCase { sessionMetadata.setClientId(null); // Turn off the implicit login runFlow(); } - - // Extra methods so the test runner doesn't produce empty shards. - @Test public void testNothing1() {} - @Test public void testNothing2() {} } diff --git a/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java b/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java index b20ff586a..c680c1dc6 100644 --- a/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java +++ b/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java @@ -26,11 +26,11 @@ import com.google.common.io.CharStreams; import google.registry.keyring.api.Keyring; import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.GpgSystemCommandRule; +import google.registry.testing.ShardableTestCase; import org.bouncycastle.openpgp.PGPPublicKey; import org.joda.time.DateTime; import org.junit.Rule; -import org.junit.Test; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; @@ -47,7 +47,7 @@ import java.io.OutputStream; /** GnuPG integration tests for {@link Ghostryde}. */ @RunWith(Theories.class) @SuppressWarnings("resource") -public class GhostrydeGpgIntegrationTest { +public class GhostrydeGpgIntegrationTest extends ShardableTestCase { @Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @@ -170,7 +170,4 @@ public class GhostrydeGpgIntegrationTest { return value; } } - - @Test public void makeShardingWork1() {} - @Test public void makeShardingWork2() {} } diff --git a/javatests/google/registry/rde/RegistrarToXjcConverterTest.java b/javatests/google/registry/rde/RegistrarToXjcConverterTest.java index b9c8751a4..67d7c7845 100644 --- a/javatests/google/registry/rde/RegistrarToXjcConverterTest.java +++ b/javatests/google/registry/rde/RegistrarToXjcConverterTest.java @@ -27,6 +27,7 @@ import google.registry.model.registrar.RegistrarAddress; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; +import google.registry.testing.ShardableTestCase; import google.registry.xjc.rderegistrar.XjcRdeRegistrar; import google.registry.xjc.rderegistrar.XjcRdeRegistrarAddrType; import google.registry.xjc.rderegistrar.XjcRdeRegistrarPostalInfoEnumType; @@ -49,7 +50,7 @@ import java.io.ByteArrayOutputStream; * some exceptional conditions. */ @RunWith(JUnit4.class) -public class RegistrarToXjcConverterTest { +public class RegistrarToXjcConverterTest extends ShardableTestCase { @Rule public final AppEngineRule appEngine = AppEngineRule.builder() @@ -147,6 +148,4 @@ public class RegistrarToXjcConverterTest { public void testMarshal() throws Exception { marshalStrict(RegistrarToXjcConverter.convert(registrar), new ByteArrayOutputStream(), UTF_8); } - - @Test public void makeShardingWork1() {} } diff --git a/javatests/google/registry/rde/RydeGpgIntegrationTest.java b/javatests/google/registry/rde/RydeGpgIntegrationTest.java index 3e83b1a3e..525b54b3a 100644 --- a/javatests/google/registry/rde/RydeGpgIntegrationTest.java +++ b/javatests/google/registry/rde/RydeGpgIntegrationTest.java @@ -27,13 +27,13 @@ import google.registry.keyring.api.Keyring; import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.GpgSystemCommandRule; import google.registry.testing.Providers; +import google.registry.testing.ShardableTestCase; import google.registry.util.FormattingLogger; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPublicKey; import org.joda.time.DateTime; import org.junit.Rule; -import org.junit.Test; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; @@ -51,7 +51,7 @@ import java.io.OutputStream; /** GPG combinatorial integration tests for the Ryde classes. */ @RunWith(Theories.class) @SuppressWarnings("resource") -public class RydeGpgIntegrationTest { +public class RydeGpgIntegrationTest extends ShardableTestCase { private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); @@ -281,7 +281,4 @@ public class RydeGpgIntegrationTest { return value; } } - - @Test public void makeShardingWork1() {} - @Test public void makeShardingWork2() {} } diff --git a/javatests/google/registry/testing/ShardableTestCase.java b/javatests/google/registry/testing/ShardableTestCase.java index af3d5d81c..6582117d2 100644 --- a/javatests/google/registry/testing/ShardableTestCase.java +++ b/javatests/google/registry/testing/ShardableTestCase.java @@ -23,6 +23,7 @@ import org.junit.Test; * sure that we never produces empty shards. */ public abstract class ShardableTestCase { + @Test public void testNothing1() {}