mirror of
https://github.com/google/nomulus.git
synced 2025-06-11 15:04:46 +02:00
Upgrade mapreduce and DNS tests from JUnit 4 to JUnit 5 (#701)
* Upgrade mapreduce and DNS tests from JUnit 4 to JUnit 5 * Merge branch 'master' into junit5-batch-and-dns
This commit is contained in:
parent
56be3f37ef
commit
bdc269baf7
47 changed files with 659 additions and 800 deletions
|
@ -33,29 +33,26 @@ import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
|||
import google.registry.util.Retrier;
|
||||
import google.registry.util.TaskQueueUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link CommitLogCheckpointAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class CommitLogCheckpointActionTest {
|
||||
|
||||
private static final String QUEUE_NAME = "export-commits";
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
CommitLogCheckpointStrategy strategy = mock(CommitLogCheckpointStrategy.class);
|
||||
private CommitLogCheckpointStrategy strategy = mock(CommitLogCheckpointStrategy.class);
|
||||
|
||||
DateTime now = DateTime.now(UTC);
|
||||
CommitLogCheckpointAction task = new CommitLogCheckpointAction();
|
||||
private DateTime now = DateTime.now(UTC);
|
||||
private CommitLogCheckpointAction task = new CommitLogCheckpointAction();
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
task.clock = new FakeClock(now);
|
||||
task.strategy = strategy;
|
||||
task.taskQueueUtils = new TaskQueueUtils(new Retrier(null, 1));
|
||||
|
@ -66,7 +63,7 @@ public class CommitLogCheckpointActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_noCheckpointEverWritten_writesCheckpointAndEnqueuesTask() {
|
||||
void testRun_noCheckpointEverWritten_writesCheckpointAndEnqueuesTask() {
|
||||
task.run();
|
||||
assertTasksEnqueued(
|
||||
QUEUE_NAME,
|
||||
|
@ -78,7 +75,7 @@ public class CommitLogCheckpointActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_checkpointWrittenBeforeNow_writesCheckpointAndEnqueuesTask() {
|
||||
void testRun_checkpointWrittenBeforeNow_writesCheckpointAndEnqueuesTask() {
|
||||
DateTime oneMinuteAgo = now.minusMinutes(1);
|
||||
persistResource(CommitLogCheckpointRoot.create(oneMinuteAgo));
|
||||
task.run();
|
||||
|
@ -92,7 +89,7 @@ public class CommitLogCheckpointActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_checkpointWrittenAfterNow_doesntOverwrite_orEnqueueTask() {
|
||||
void testRun_checkpointWrittenAfterNow_doesntOverwrite_orEnqueueTask() {
|
||||
DateTime oneMinuteFromNow = now.plusMinutes(1);
|
||||
persistResource(CommitLogCheckpointRoot.create(oneMinuteFromNow));
|
||||
task.run();
|
||||
|
|
|
@ -36,27 +36,22 @@ import google.registry.testing.FakeClock;
|
|||
import google.registry.testing.InjectRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link CommitLogCheckpointStrategy}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class CommitLogCheckpointStrategyTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
|
||||
final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
|
||||
final Ofy ofy = new Ofy(clock);
|
||||
final TransactionManager tm = new DatastoreTransactionManager(ofy);
|
||||
final CommitLogCheckpointStrategy strategy = new CommitLogCheckpointStrategy();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
|
||||
private final Ofy ofy = new Ofy(clock);
|
||||
private final TransactionManager tm = new DatastoreTransactionManager(ofy);
|
||||
private final CommitLogCheckpointStrategy strategy = new CommitLogCheckpointStrategy();
|
||||
|
||||
/**
|
||||
* Supplier to inject into CommitLogBucket for doling out predictable bucket IDs.
|
||||
|
@ -64,7 +59,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
* <p>If not overridden, the supplier returns 1 so that other saves won't hit an NPE (since even
|
||||
* if they use saveWithoutBackup() the transaction still selects a bucket key early).
|
||||
*/
|
||||
final FakeSupplier<Integer> fakeBucketIdSupplier = new FakeSupplier<>(1);
|
||||
private final FakeSupplier<Integer> fakeBucketIdSupplier = new FakeSupplier<>(1);
|
||||
|
||||
/** Gross but necessary supplier that can be modified to return the desired value. */
|
||||
private static class FakeSupplier<T> implements Supplier<T> {
|
||||
|
@ -74,7 +69,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
/** Set this value field to make the supplier return this value. */
|
||||
T value = null;
|
||||
|
||||
public FakeSupplier(T defaultValue) {
|
||||
FakeSupplier(T defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
@ -84,8 +79,8 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
strategy.clock = clock;
|
||||
strategy.ofy = ofy;
|
||||
|
||||
|
@ -102,13 +97,13 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_readBucketTimestamps_noCommitLogs() {
|
||||
void test_readBucketTimestamps_noCommitLogs() {
|
||||
assertThat(strategy.readBucketTimestamps())
|
||||
.containsExactly(1, START_OF_TIME, 2, START_OF_TIME, 3, START_OF_TIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_readBucketTimestamps_withSomeCommitLogs() {
|
||||
void test_readBucketTimestamps_withSomeCommitLogs() {
|
||||
DateTime startTime = clock.nowUtc();
|
||||
writeCommitLogToBucket(1);
|
||||
clock.advanceOneMilli();
|
||||
|
@ -118,7 +113,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_readBucketTimestamps_againAfterUpdate_reflectsUpdate() {
|
||||
void test_readBucketTimestamps_againAfterUpdate_reflectsUpdate() {
|
||||
DateTime firstTime = clock.nowUtc();
|
||||
writeCommitLogToBucket(1);
|
||||
writeCommitLogToBucket(2);
|
||||
|
@ -133,14 +128,14 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_readNewCommitLogsAndFindThreshold_noCommitsAtAll_returnsEndOfTime() {
|
||||
void test_readNewCommitLogsAndFindThreshold_noCommitsAtAll_returnsEndOfTime() {
|
||||
ImmutableMap<Integer, DateTime> bucketTimes =
|
||||
ImmutableMap.of(1, START_OF_TIME, 2, START_OF_TIME, 3, START_OF_TIME);
|
||||
assertThat(strategy.readNewCommitLogsAndFindThreshold(bucketTimes)).isEqualTo(END_OF_TIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_readNewCommitLogsAndFindThreshold_noNewCommits_returnsEndOfTime() {
|
||||
void test_readNewCommitLogsAndFindThreshold_noNewCommits_returnsEndOfTime() {
|
||||
DateTime now = clock.nowUtc();
|
||||
writeCommitLogToBucket(1);
|
||||
clock.advanceOneMilli();
|
||||
|
@ -153,7 +148,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_readNewCommitLogsAndFindThreshold_tiedNewCommits_returnsCommitTimeMinusOne() {
|
||||
void test_readNewCommitLogsAndFindThreshold_tiedNewCommits_returnsCommitTimeMinusOne() {
|
||||
DateTime now = clock.nowUtc();
|
||||
writeCommitLogToBucket(1);
|
||||
writeCommitLogToBucket(2);
|
||||
|
@ -164,7 +159,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_readNewCommitLogsAndFindThreshold_someNewCommits_returnsEarliestTimeMinusOne() {
|
||||
void test_readNewCommitLogsAndFindThreshold_someNewCommits_returnsEarliestTimeMinusOne() {
|
||||
DateTime now = clock.nowUtc();
|
||||
writeCommitLogToBucket(1); // 1A
|
||||
writeCommitLogToBucket(2); // 2A
|
||||
|
@ -191,7 +186,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_readNewCommitLogsAndFindThreshold_commitsAtBucketTimes() {
|
||||
void test_readNewCommitLogsAndFindThreshold_commitsAtBucketTimes() {
|
||||
DateTime now = clock.nowUtc();
|
||||
ImmutableMap<Integer, DateTime> bucketTimes =
|
||||
ImmutableMap.of(1, now.minusMillis(1), 2, now, 3, now.plusMillis(1));
|
||||
|
@ -199,7 +194,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_computeBucketCheckpointTimes_earlyThreshold_setsEverythingToThreshold() {
|
||||
void test_computeBucketCheckpointTimes_earlyThreshold_setsEverythingToThreshold() {
|
||||
DateTime now = clock.nowUtc();
|
||||
ImmutableMap<Integer, DateTime> bucketTimes =
|
||||
ImmutableMap.of(1, now.minusMillis(1), 2, now, 3, now.plusMillis(1));
|
||||
|
@ -208,7 +203,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_computeBucketCheckpointTimes_middleThreshold_clampsToThreshold() {
|
||||
void test_computeBucketCheckpointTimes_middleThreshold_clampsToThreshold() {
|
||||
DateTime now = clock.nowUtc();
|
||||
ImmutableMap<Integer, DateTime> bucketTimes =
|
||||
ImmutableMap.of(1, now.minusMillis(1), 2, now, 3, now.plusMillis(1));
|
||||
|
@ -217,7 +212,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_computeBucketCheckpointTimes_lateThreshold_leavesBucketTimesAsIs() {
|
||||
void test_computeBucketCheckpointTimes_lateThreshold_leavesBucketTimesAsIs() {
|
||||
DateTime now = clock.nowUtc();
|
||||
ImmutableMap<Integer, DateTime> bucketTimes =
|
||||
ImmutableMap.of(1, now.minusMillis(1), 2, now, 3, now.plusMillis(1));
|
||||
|
@ -226,7 +221,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_computeCheckpoint_noCommitsAtAll_bucketCheckpointTimesAreStartOfTime() {
|
||||
void test_computeCheckpoint_noCommitsAtAll_bucketCheckpointTimesAreStartOfTime() {
|
||||
assertThat(strategy.computeCheckpoint())
|
||||
.isEqualTo(CommitLogCheckpoint.create(
|
||||
clock.nowUtc(),
|
||||
|
@ -234,7 +229,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_computeCheckpoint_noNewCommitLogs_bucketCheckpointTimesAreBucketTimes() {
|
||||
void test_computeCheckpoint_noNewCommitLogs_bucketCheckpointTimesAreBucketTimes() {
|
||||
DateTime now = clock.nowUtc();
|
||||
writeCommitLogToBucket(1);
|
||||
clock.advanceOneMilli();
|
||||
|
@ -250,7 +245,7 @@ public class CommitLogCheckpointStrategyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_computeCheckpoint_someNewCommits_bucketCheckpointTimesAreClampedToThreshold() {
|
||||
void test_computeCheckpoint_someNewCommits_bucketCheckpointTimesAreClampedToThreshold() {
|
||||
DateTime now = clock.nowUtc();
|
||||
writeCommitLogToBucket(1); // 1A
|
||||
writeCommitLogToBucket(2); // 2A
|
||||
|
|
|
@ -29,14 +29,11 @@ import google.registry.testing.InjectRule;
|
|||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DeleteOldCommitLogsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class DeleteOldCommitLogsActionTest
|
||||
extends MapreduceTestCase<DeleteOldCommitLogsAction> {
|
||||
|
||||
|
@ -44,11 +41,10 @@ public class DeleteOldCommitLogsActionTest
|
|||
private final FakeResponse response = new FakeResponse();
|
||||
private ContactResource contact;
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
action = new DeleteOldCommitLogsAction();
|
||||
action.mrRunner = makeDefaultRunner();
|
||||
|
@ -107,11 +103,9 @@ public class DeleteOldCommitLogsActionTest
|
|||
return ImmutableList.copyOf(ofy().load().type(clazz).iterable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that with very short maxAge, only the referenced elements remain.
|
||||
*/
|
||||
/** Check that with very short maxAge, only the referenced elements remain. */
|
||||
@Test
|
||||
public void test_shortMaxAge() throws Exception {
|
||||
void test_shortMaxAge() throws Exception {
|
||||
runMapreduce(Duration.millis(1));
|
||||
|
||||
assertThat(ImmutableList.copyOf(ofy().load().type(CommitLogManifest.class).keys().iterable()))
|
||||
|
@ -121,11 +115,9 @@ public class DeleteOldCommitLogsActionTest
|
|||
assertThat(ofyLoadType(CommitLogMutation.class)).hasSize(contact.getRevisions().size() * 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that with very long maxAge, all the elements remain.
|
||||
*/
|
||||
/** Check that with very long maxAge, all the elements remain. */
|
||||
@Test
|
||||
public void test_longMaxAge() throws Exception {
|
||||
void test_longMaxAge() throws Exception {
|
||||
|
||||
ImmutableList<CommitLogManifest> initialManifests = ofyLoadType(CommitLogManifest.class);
|
||||
ImmutableList<CommitLogMutation> initialMutations = ofyLoadType(CommitLogMutation.class);
|
||||
|
|
|
@ -39,17 +39,14 @@ import google.registry.testing.GcsTestingUtils;
|
|||
import google.registry.testing.TestObject;
|
||||
import java.util.List;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ExportCommitLogDiffAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExportCommitLogDiffActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
|
@ -64,15 +61,15 @@ public class ExportCommitLogDiffActionTest {
|
|||
|
||||
private final ExportCommitLogDiffAction task = new ExportCommitLogDiffAction();
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
task.gcsService = gcsService;
|
||||
task.gcsBucket = "gcs bucket";
|
||||
task.batchSize = 5;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_noCommitHistory_onlyUpperCheckpointExported() throws Exception {
|
||||
void testRun_noCommitHistory_onlyUpperCheckpointExported() throws Exception {
|
||||
task.lowerCheckpointTime = oneMinuteAgo;
|
||||
task.upperCheckpointTime = now;
|
||||
|
||||
|
@ -104,7 +101,7 @@ public class ExportCommitLogDiffActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_regularCommitHistory_exportsCorrectCheckpointDiff() throws Exception {
|
||||
void testRun_regularCommitHistory_exportsCorrectCheckpointDiff() throws Exception {
|
||||
task.lowerCheckpointTime = oneMinuteAgo;
|
||||
task.upperCheckpointTime = now;
|
||||
|
||||
|
@ -175,7 +172,7 @@ public class ExportCommitLogDiffActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_simultaneousTransactions_bothExported() throws Exception {
|
||||
void testRun_simultaneousTransactions_bothExported() throws Exception {
|
||||
task.lowerCheckpointTime = oneMinuteAgo;
|
||||
task.upperCheckpointTime = now;
|
||||
|
||||
|
@ -227,7 +224,7 @@ public class ExportCommitLogDiffActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_exportsAcrossMultipleBatches() throws Exception {
|
||||
void testRun_exportsAcrossMultipleBatches() throws Exception {
|
||||
task.batchSize = 2;
|
||||
task.lowerCheckpointTime = oneMinuteAgo;
|
||||
task.upperCheckpointTime = now;
|
||||
|
@ -288,7 +285,7 @@ public class ExportCommitLogDiffActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_checkpointDiffWithNeverTouchedBuckets_exportsCorrectly() throws Exception {
|
||||
void testRun_checkpointDiffWithNeverTouchedBuckets_exportsCorrectly() throws Exception {
|
||||
task.lowerCheckpointTime = oneMinuteAgo;
|
||||
task.upperCheckpointTime = now;
|
||||
|
||||
|
@ -322,8 +319,7 @@ public class ExportCommitLogDiffActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_checkpointDiffWithNonExistentBucketTimestamps_exportsCorrectly()
|
||||
throws Exception {
|
||||
void testRun_checkpointDiffWithNonExistentBucketTimestamps_exportsCorrectly() throws Exception {
|
||||
// Non-existent bucket timestamps can exist when the commit log bucket count was increased
|
||||
// recently.
|
||||
|
||||
|
@ -404,7 +400,7 @@ public class ExportCommitLogDiffActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_exportingFromStartOfTime_exportsAllCommits() throws Exception {
|
||||
void testRun_exportingFromStartOfTime_exportsAllCommits() throws Exception {
|
||||
task.lowerCheckpointTime = START_OF_TIME;
|
||||
task.upperCheckpointTime = now;
|
||||
|
||||
|
|
|
@ -44,28 +44,25 @@ import java.util.List;
|
|||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.LogRecord;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link GcsDiffFileLister}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class GcsDiffFileListerTest {
|
||||
|
||||
static final String GCS_BUCKET = "gcs bucket";
|
||||
private static final String GCS_BUCKET = "gcs bucket";
|
||||
|
||||
final DateTime now = DateTime.now(UTC);
|
||||
final GcsDiffFileLister diffLister = new GcsDiffFileLister();
|
||||
final GcsService gcsService = GcsServiceFactory.createGcsService();
|
||||
private final DateTime now = DateTime.now(UTC);
|
||||
private final GcsDiffFileLister diffLister = new GcsDiffFileLister();
|
||||
private final GcsService gcsService = GcsServiceFactory.createGcsService();
|
||||
private final TestLogHandler logHandler = new TestLogHandler();
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
diffLister.gcsService = gcsService;
|
||||
diffLister.gcsBucket = GCS_BUCKET;
|
||||
diffLister.executor = newDirectExecutorService();
|
||||
|
@ -111,13 +108,13 @@ public class GcsDiffFileListerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testList_noFilesFound() {
|
||||
void testList_noFilesFound() {
|
||||
DateTime fromTime = now.plusMillis(1);
|
||||
assertThat(listDiffFiles(fromTime, null)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testList_patchesHoles() {
|
||||
void testList_patchesHoles() {
|
||||
// Fake out the GCS list() method to return only the first and last file.
|
||||
// We can't use Mockito.spy() because GcsService's impl is final.
|
||||
diffLister.gcsService = (GcsService) newProxyInstance(
|
||||
|
@ -162,7 +159,7 @@ public class GcsDiffFileListerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testList_failsOnFork() throws Exception {
|
||||
void testList_failsOnFork() throws Exception {
|
||||
// We currently have files for now-4m ... now, construct the following sequence:
|
||||
// now-8m <- now-7m <- now-6m now-5m <- now-4m ... now
|
||||
// ^___________________________|
|
||||
|
@ -179,7 +176,7 @@ public class GcsDiffFileListerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testList_boundaries() {
|
||||
void testList_boundaries() {
|
||||
assertThat(listDiffFiles(now.minusMinutes(4), now))
|
||||
.containsExactly(
|
||||
now.minusMinutes(4),
|
||||
|
@ -192,7 +189,7 @@ public class GcsDiffFileListerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testList_failsOnGaps() throws Exception {
|
||||
void testList_failsOnGaps() throws Exception {
|
||||
// We currently have files for now-4m ... now, construct the following sequence:
|
||||
// now-8m <- now-7m <- now-6m {missing} <- now-4m ... now
|
||||
for (int i = 6; i < 9; ++i) {
|
||||
|
@ -228,7 +225,7 @@ public class GcsDiffFileListerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testList_toTimeSpecified() {
|
||||
void testList_toTimeSpecified() {
|
||||
assertThat(listDiffFiles(
|
||||
now.minusMinutes(4).minusSeconds(1), now.minusMinutes(2).plusSeconds(1)))
|
||||
.containsExactly(
|
||||
|
|
|
@ -54,31 +54,28 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link RestoreCommitLogsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RestoreCommitLogsActionTest {
|
||||
|
||||
static final String GCS_BUCKET = "gcs bucket";
|
||||
private static final String GCS_BUCKET = "gcs bucket";
|
||||
|
||||
final DateTime now = DateTime.now(UTC);
|
||||
final RestoreCommitLogsAction action = new RestoreCommitLogsAction();
|
||||
final GcsService gcsService = createGcsService();
|
||||
private final DateTime now = DateTime.now(UTC);
|
||||
private final RestoreCommitLogsAction action = new RestoreCommitLogsAction();
|
||||
private final GcsService gcsService = createGcsService();
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withOfyTestEntities(TestObject.class)
|
||||
.build();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
action.gcsService = gcsService;
|
||||
action.dryRun = false;
|
||||
action.datastoreService = DatastoreServiceFactory.getDatastoreService();
|
||||
|
@ -91,7 +88,7 @@ public class RestoreCommitLogsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRestore_multipleDiffFiles() throws Exception {
|
||||
void testRestore_multipleDiffFiles() throws Exception {
|
||||
ofy().saveWithoutBackup().entities(
|
||||
TestObject.create("previous to keep"),
|
||||
TestObject.create("previous to delete")).now();
|
||||
|
@ -141,7 +138,7 @@ public class RestoreCommitLogsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRestore_noManifests() throws Exception {
|
||||
void testRestore_noManifests() throws Exception {
|
||||
ofy().saveWithoutBackup().entity(
|
||||
TestObject.create("previous to keep")).now();
|
||||
saveDiffFileNotToRestore(now.minusMinutes(1));
|
||||
|
@ -155,7 +152,7 @@ public class RestoreCommitLogsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRestore_manifestWithNoDeletions() throws Exception {
|
||||
void testRestore_manifestWithNoDeletions() throws Exception {
|
||||
ofy().saveWithoutBackup().entity(TestObject.create("previous to keep")).now();
|
||||
Key<CommitLogBucket> bucketKey = getBucketKey(1);
|
||||
Key<CommitLogManifest> manifestKey = CommitLogManifest.createKey(bucketKey, now);
|
||||
|
@ -174,7 +171,7 @@ public class RestoreCommitLogsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRestore_manifestWithNoMutations() throws Exception {
|
||||
void testRestore_manifestWithNoMutations() throws Exception {
|
||||
ofy().saveWithoutBackup().entities(
|
||||
TestObject.create("previous to keep"),
|
||||
TestObject.create("previous to delete")).now();
|
||||
|
@ -195,7 +192,7 @@ public class RestoreCommitLogsActionTest {
|
|||
|
||||
// This is a pathological case that shouldn't be possible, but we should be robust to it.
|
||||
@Test
|
||||
public void testRestore_manifestWithNoMutationsOrDeletions() throws Exception {
|
||||
void testRestore_manifestWithNoMutationsOrDeletions() throws Exception {
|
||||
ofy().saveWithoutBackup().entities(
|
||||
TestObject.create("previous to keep")).now();
|
||||
saveDiffFileNotToRestore(now.minusMinutes(1));
|
||||
|
@ -211,7 +208,7 @@ public class RestoreCommitLogsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRestore_mutateExistingEntity() throws Exception {
|
||||
void testRestore_mutateExistingEntity() throws Exception {
|
||||
ofy().saveWithoutBackup().entity(TestObject.create("existing", "a")).now();
|
||||
Key<CommitLogManifest> manifestKey = CommitLogManifest.createKey(getBucketKey(1), now);
|
||||
saveDiffFileNotToRestore(now.minusMinutes(1));
|
||||
|
@ -229,7 +226,7 @@ public class RestoreCommitLogsActionTest {
|
|||
|
||||
// This should be harmless; deletes are idempotent.
|
||||
@Test
|
||||
public void testRestore_deleteMissingEntity() throws Exception {
|
||||
void testRestore_deleteMissingEntity() throws Exception {
|
||||
ofy().saveWithoutBackup().entity(TestObject.create("previous to keep", "a")).now();
|
||||
saveDiffFileNotToRestore(now.minusMinutes(1));
|
||||
Iterable<ImmutableObject> commitLogs = saveDiffFile(
|
||||
|
|
|
@ -50,26 +50,24 @@ import google.registry.util.Retrier;
|
|||
import java.util.logging.Level;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/** Unit tests for {@link AsyncTaskEnqueuer}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class AsyncTaskEnqueuerTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Mock private AppEngineServiceUtils appEngineServiceUtils;
|
||||
|
||||
|
@ -77,8 +75,8 @@ public class AsyncTaskEnqueuerTest {
|
|||
private final CapturingLogHandler logHandler = new CapturingLogHandler();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2015-05-18T12:34:56Z"));
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
LoggerConfig.getConfig(AsyncTaskEnqueuer.class).addHandler(logHandler);
|
||||
when(appEngineServiceUtils.getServiceHostname("backend")).thenReturn("backend.hostname.fake");
|
||||
asyncTaskEnqueuer = createForTesting(appEngineServiceUtils, clock, standardSeconds(90));
|
||||
|
@ -96,7 +94,7 @@ public class AsyncTaskEnqueuerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_enqueueAsyncResave_success() {
|
||||
void test_enqueueAsyncResave_success() {
|
||||
ContactResource contact = persistActiveContact("jd23456");
|
||||
asyncTaskEnqueuer.enqueueAsyncResave(contact, clock.nowUtc(), clock.nowUtc().plusDays(5));
|
||||
assertTasksEnqueued(
|
||||
|
@ -114,7 +112,7 @@ public class AsyncTaskEnqueuerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_enqueueAsyncResave_multipleResaves() {
|
||||
void test_enqueueAsyncResave_multipleResaves() {
|
||||
ContactResource contact = persistActiveContact("jd23456");
|
||||
DateTime now = clock.nowUtc();
|
||||
asyncTaskEnqueuer.enqueueAsyncResave(
|
||||
|
@ -130,16 +128,15 @@ public class AsyncTaskEnqueuerTest {
|
|||
.header("content-type", "application/x-www-form-urlencoded")
|
||||
.param(PARAM_RESOURCE_KEY, Key.create(contact).getString())
|
||||
.param(PARAM_REQUESTED_TIME, now.toString())
|
||||
.param(
|
||||
PARAM_RESAVE_TIMES,
|
||||
"2015-05-20T14:34:56.000Z,2015-05-21T15:34:56.000Z")
|
||||
.param(PARAM_RESAVE_TIMES, "2015-05-20T14:34:56.000Z,2015-05-21T15:34:56.000Z")
|
||||
.etaDelta(
|
||||
standardHours(24).minus(standardSeconds(30)),
|
||||
standardHours(24).plus(standardSeconds(30))));
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() throws Exception {
|
||||
void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() throws Exception {
|
||||
ContactResource contact = persistActiveContact("jd23456");
|
||||
asyncTaskEnqueuer.enqueueAsyncResave(contact, clock.nowUtc(), clock.nowUtc().plusDays(31));
|
||||
assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
|
@ -147,7 +144,7 @@ public class AsyncTaskEnqueuerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEnqueueRelock() {
|
||||
void testEnqueueRelock() {
|
||||
RegistryLock lock =
|
||||
saveRegistryLock(
|
||||
new RegistryLock.Builder()
|
||||
|
@ -177,8 +174,9 @@ public class AsyncTaskEnqueuerTest {
|
|||
standardHours(6).plus(standardSeconds(30))));
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testFailure_enqueueRelock_noDuration() {
|
||||
void testFailure_enqueueRelock_noDuration() {
|
||||
RegistryLock lockWithoutDuration =
|
||||
saveRegistryLock(
|
||||
new RegistryLock.Builder()
|
||||
|
|
|
@ -21,19 +21,16 @@ import static google.registry.batch.AsyncTaskMetrics.OperationType.CONTACT_AND_H
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.testing.FakeClock;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link AsyncTaskMetrics}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class AsyncTaskMetricsTest {
|
||||
class AsyncTaskMetricsTest {
|
||||
|
||||
private final FakeClock clock = new FakeClock();
|
||||
private final AsyncTaskMetrics asyncTaskMetrics = new AsyncTaskMetrics(clock);
|
||||
|
||||
@Test
|
||||
public void testRecordAsyncFlowResult_calculatesDurationMillisCorrectly() {
|
||||
void testRecordAsyncFlowResult_calculatesDurationMillisCorrectly() {
|
||||
asyncTaskMetrics.recordAsyncFlowResult(
|
||||
CONTACT_AND_HOST_DELETE,
|
||||
SUCCESS,
|
||||
|
|
|
@ -105,19 +105,16 @@ import google.registry.util.SystemSleeper;
|
|||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/** Unit tests for {@link DeleteContactsAndHostsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class DeleteContactsAndHostsActionTest
|
||||
extends MapreduceTestCase<DeleteContactsAndHostsAction> {
|
||||
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
private AsyncTaskEnqueuer enqueuer;
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z"));
|
||||
|
@ -146,8 +143,8 @@ public class DeleteContactsAndHostsActionTest
|
|||
ofy().clearSessionCache();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
enqueuer =
|
||||
AsyncTaskEnqueuerTest.createForTesting(
|
||||
|
@ -171,7 +168,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contact_referencedByActiveDomain_doesNotGetDeleted() throws Exception {
|
||||
void testSuccess_contact_referencedByActiveDomain_doesNotGetDeleted() throws Exception {
|
||||
ContactResource contact = persistContactPendingDelete("blah8221");
|
||||
persistResource(newDomainBase("example.tld", contact));
|
||||
DateTime timeEnqueued = clock.nowUtc();
|
||||
|
@ -211,17 +208,17 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contact_notReferenced_getsDeleted_andPiiWipedOut() throws Exception {
|
||||
void testSuccess_contact_notReferenced_getsDeleted_andPiiWipedOut() throws Exception {
|
||||
runSuccessfulContactDeletionTest(Optional.of("fakeClientTrid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contact_andNoClientTrid_deletesSuccessfully() throws Exception {
|
||||
void testSuccess_contact_andNoClientTrid_deletesSuccessfully() throws Exception {
|
||||
runSuccessfulContactDeletionTest(Optional.empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_cannotAcquireLock() {
|
||||
void test_cannotAcquireLock() {
|
||||
// Make lock acquisition fail.
|
||||
acquireLock();
|
||||
enqueueMapreduceOnly();
|
||||
|
@ -229,7 +226,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_mapreduceHasWorkToDo_lockIsAcquired() {
|
||||
void test_mapreduceHasWorkToDo_lockIsAcquired() {
|
||||
ContactResource contact = persistContactPendingDelete("blah8221");
|
||||
persistResource(newDomainBase("example.tld", contact));
|
||||
DateTime timeEnqueued = clock.nowUtc();
|
||||
|
@ -244,7 +241,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_noTasksToLease_releasesLockImmediately() {
|
||||
void test_noTasksToLease_releasesLockImmediately() {
|
||||
enqueueMapreduceOnly();
|
||||
// If the Lock was correctly released, then we can acquire it now.
|
||||
assertThat(acquireLock()).isPresent();
|
||||
|
@ -293,8 +290,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contactWithoutPendingTransfer_isDeletedAndHasNoTransferData()
|
||||
throws Exception {
|
||||
void testSuccess_contactWithoutPendingTransfer_isDeletedAndHasNoTransferData() throws Exception {
|
||||
ContactResource contact = persistContactPendingDelete("blah8221");
|
||||
enqueuer.enqueueAsyncDelete(
|
||||
contact,
|
||||
|
@ -308,7 +304,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contactWithPendingTransfer_getsDeleted() throws Exception {
|
||||
void testSuccess_contactWithPendingTransfer_getsDeleted() throws Exception {
|
||||
DateTime transferRequestTime = clock.nowUtc().minusDays(3);
|
||||
ContactResource contact =
|
||||
persistContactWithPendingTransfer(
|
||||
|
@ -371,7 +367,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contact_referencedByDeletedDomain_getsDeleted() throws Exception {
|
||||
void testSuccess_contact_referencedByDeletedDomain_getsDeleted() throws Exception {
|
||||
ContactResource contactUsed = persistContactPendingDelete("blah1234");
|
||||
persistResource(
|
||||
newDomainBase("example.tld", contactUsed)
|
||||
|
@ -410,7 +406,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contact_notRequestedByOwner_doesNotGetDeleted() throws Exception {
|
||||
void testSuccess_contact_notRequestedByOwner_doesNotGetDeleted() throws Exception {
|
||||
ContactResource contact = persistContactPendingDelete("jane0991");
|
||||
enqueuer.enqueueAsyncDelete(
|
||||
contact,
|
||||
|
@ -438,7 +434,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contact_notRequestedByOwner_isSuperuser_getsDeleted() throws Exception {
|
||||
void testSuccess_contact_notRequestedByOwner_isSuperuser_getsDeleted() throws Exception {
|
||||
ContactResource contact = persistContactWithPii("nate007");
|
||||
enqueuer.enqueueAsyncDelete(
|
||||
contact,
|
||||
|
@ -480,7 +476,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_targetResourcesDontExist_areDelayedForADay() throws Exception {
|
||||
void testSuccess_targetResourcesDontExist_areDelayedForADay() throws Exception {
|
||||
ContactResource contactNotSaved = newContactResource("somecontact");
|
||||
HostResource hostNotSaved = newHostResource("a11.blah.foo");
|
||||
DateTime timeBeforeRun = clock.nowUtc();
|
||||
|
@ -519,7 +515,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_unparseableTasks_areDelayedForADay() throws Exception {
|
||||
void testSuccess_unparseableTasks_areDelayedForADay() throws Exception {
|
||||
TaskOptions task =
|
||||
TaskOptions.Builder.withMethod(Method.PULL).param("gobbledygook", "kljhadfgsd9f7gsdfh");
|
||||
getQueue(QUEUE_ASYNC_DELETE).add(task);
|
||||
|
@ -535,7 +531,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_resourcesNotInPendingDelete_areSkipped() throws Exception {
|
||||
void testSuccess_resourcesNotInPendingDelete_areSkipped() throws Exception {
|
||||
ContactResource contact = persistActiveContact("blah2222");
|
||||
HostResource host = persistActiveHost("rustles.your.jimmies");
|
||||
DateTime timeEnqueued = clock.nowUtc();
|
||||
|
@ -567,7 +563,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_alreadyDeletedResources_areSkipped() throws Exception {
|
||||
void testSuccess_alreadyDeletedResources_areSkipped() throws Exception {
|
||||
ContactResource contactDeleted = persistDeletedContact("blah1236", clock.nowUtc().minusDays(2));
|
||||
HostResource hostDeleted = persistDeletedHost("a.lim.lop", clock.nowUtc().minusDays(3));
|
||||
enqueuer.enqueueAsyncDelete(
|
||||
|
@ -590,7 +586,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host_referencedByActiveDomain_doesNotGetDeleted() throws Exception {
|
||||
void testSuccess_host_referencedByActiveDomain_doesNotGetDeleted() throws Exception {
|
||||
HostResource host = persistHostPendingDelete("ns1.example.tld");
|
||||
persistUsedDomain("example.tld", persistActiveContact("abc456"), host);
|
||||
DateTime timeEnqueued = clock.nowUtc();
|
||||
|
@ -627,12 +623,12 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host_notReferenced_getsDeleted() throws Exception {
|
||||
void testSuccess_host_notReferenced_getsDeleted() throws Exception {
|
||||
runSuccessfulHostDeletionTest(Optional.of("fakeClientTrid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host_andNoClientTrid_deletesSuccessfully() throws Exception {
|
||||
void testSuccess_host_andNoClientTrid_deletesSuccessfully() throws Exception {
|
||||
runSuccessfulHostDeletionTest(Optional.empty());
|
||||
}
|
||||
|
||||
|
@ -675,7 +671,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host_referencedByDeletedDomain_getsDeleted() throws Exception {
|
||||
void testSuccess_host_referencedByDeletedDomain_getsDeleted() throws Exception {
|
||||
HostResource host = persistHostPendingDelete("ns1.example.tld");
|
||||
persistResource(
|
||||
newDomainBase("example.tld")
|
||||
|
@ -715,7 +711,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_subordinateHost_getsDeleted() throws Exception {
|
||||
void testSuccess_subordinateHost_getsDeleted() throws Exception {
|
||||
DomainBase domain =
|
||||
persistResource(
|
||||
newDomainBase("example.tld")
|
||||
|
@ -766,7 +762,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host_notRequestedByOwner_doesNotGetDeleted() throws Exception {
|
||||
void testSuccess_host_notRequestedByOwner_doesNotGetDeleted() throws Exception {
|
||||
HostResource host = persistHostPendingDelete("ns2.example.tld");
|
||||
enqueuer.enqueueAsyncDelete(
|
||||
host,
|
||||
|
@ -794,7 +790,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host_notRequestedByOwner_isSuperuser_getsDeleted() throws Exception {
|
||||
void testSuccess_host_notRequestedByOwner_isSuperuser_getsDeleted() throws Exception {
|
||||
HostResource host = persistHostPendingDelete("ns66.example.tld");
|
||||
enqueuer.enqueueAsyncDelete(
|
||||
host,
|
||||
|
@ -828,7 +824,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_deleteABunchOfContactsAndHosts_butNotSome() throws Exception {
|
||||
void testSuccess_deleteABunchOfContactsAndHosts_butNotSome() throws Exception {
|
||||
ContactResource c1 = persistContactPendingDelete("nsaid54");
|
||||
ContactResource c2 = persistContactPendingDelete("nsaid55");
|
||||
ContactResource c3 = persistContactPendingDelete("nsaid57");
|
||||
|
|
|
@ -52,23 +52,19 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DeleteProberDataAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataAction> {
|
||||
class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataAction> {
|
||||
|
||||
private static final DateTime DELETION_TIME = DateTime.parse("2010-01-01T00:00:00.000Z");
|
||||
|
||||
@Rule
|
||||
public final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
||||
@RegisterExtension final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
// Entities in these two should not be touched.
|
||||
createTld("tld", "TLD");
|
||||
// Since "example" doesn't end with .test, its entities won't be deleted even though it is of
|
||||
|
@ -105,7 +101,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_deletesAllAndOnlyProberData() throws Exception {
|
||||
void test_deletesAllAndOnlyProberData() throws Exception {
|
||||
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
|
||||
Set<ImmutableObject> exampleEntities = persistLotsOfDomains("example");
|
||||
Set<ImmutableObject> notTestEntities = persistLotsOfDomains("not-test.test");
|
||||
|
@ -120,7 +116,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_deletesAllAndOnlyGivenTlds() throws Exception {
|
||||
void testSuccess_deletesAllAndOnlyGivenTlds() throws Exception {
|
||||
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
|
||||
Set<ImmutableObject> exampleEntities = persistLotsOfDomains("example");
|
||||
Set<ImmutableObject> notTestEntities = persistLotsOfDomains("not-test.test");
|
||||
|
@ -136,7 +132,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFail_givenNonTestTld() {
|
||||
void testFail_givenNonTestTld() {
|
||||
action.tlds = ImmutableSet.of("not-test.test");
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, this::runMapreduce);
|
||||
|
@ -146,7 +142,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFail_givenNonExistentTld() {
|
||||
void testFail_givenNonExistentTld() {
|
||||
action.tlds = ImmutableSet.of("non-existent.test");
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, this::runMapreduce);
|
||||
|
@ -156,7 +152,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFail_givenNonDotTestTldOnProd() {
|
||||
void testFail_givenNonDotTestTldOnProd() {
|
||||
action.tlds = ImmutableSet.of("example");
|
||||
RegistryEnvironment.PRODUCTION.setup(systemPropertyRule);
|
||||
IllegalArgumentException thrown =
|
||||
|
@ -167,7 +163,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
|
||||
void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
|
||||
DomainBase nic = persistActiveDomain("nic.ib-any.test");
|
||||
ForeignKeyIndex<DomainBase> fkiNic =
|
||||
ForeignKeyIndex.load(DomainBase.class, "nic.ib-any.test", START_OF_TIME);
|
||||
|
@ -178,7 +174,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDryRun_doesntDeleteData() throws Exception {
|
||||
void testDryRun_doesntDeleteData() throws Exception {
|
||||
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
|
||||
Set<ImmutableObject> oaEntities = persistLotsOfDomains("oa-canary.test");
|
||||
action.isDryRun = true;
|
||||
|
@ -188,7 +184,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_activeDomain_isSoftDeleted() throws Exception {
|
||||
void testSuccess_activeDomain_isSoftDeleted() throws Exception {
|
||||
DomainBase domain = persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
|
@ -203,7 +199,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception {
|
||||
void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception {
|
||||
DomainBase domain = persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
|
@ -220,7 +216,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_recentlyCreatedDomain_isntDeletedYet() throws Exception {
|
||||
void test_recentlyCreatedDomain_isntDeletedYet() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
|
@ -234,7 +230,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDryRun_doesntSoftDeleteData() throws Exception {
|
||||
void testDryRun_doesntSoftDeleteData() throws Exception {
|
||||
DomainBase domain = persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
|
@ -246,7 +242,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_domainWithSubordinateHosts_isSkipped() throws Exception {
|
||||
void test_domainWithSubordinateHosts_isSkipped() throws Exception {
|
||||
persistActiveHost("ns1.blah.ib-any.test");
|
||||
DomainBase nakedDomain =
|
||||
persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1));
|
||||
|
@ -263,7 +259,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_registryAdminClientId_isRequiredForSoftDeletion() {
|
||||
void testFailure_registryAdminClientId_isRequiredForSoftDeletion() {
|
||||
persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
|
|
|
@ -59,28 +59,25 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ExpandRecurringBillingEventsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExpandRecurringBillingEventsActionTest
|
||||
extends MapreduceTestCase<ExpandRecurringBillingEventsAction> {
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
private final DateTime beginningOfTest = DateTime.parse("2000-10-02T00:00:00Z");
|
||||
private final FakeClock clock = new FakeClock(beginningOfTest);
|
||||
|
||||
DomainBase domain;
|
||||
HistoryEntry historyEntry;
|
||||
BillingEvent.Recurring recurring;
|
||||
private DomainBase domain;
|
||||
private HistoryEntry historyEntry;
|
||||
private BillingEvent.Recurring recurring;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
action = new ExpandRecurringBillingEventsAction();
|
||||
action.mrRunner = makeDefaultRunner();
|
||||
|
@ -161,7 +158,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent() throws Exception {
|
||||
void testSuccess_expandSingleEvent() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
runMapreduce();
|
||||
|
@ -176,7 +173,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_deletedDomain() throws Exception {
|
||||
void testSuccess_expandSingleEvent_deletedDomain() throws Exception {
|
||||
DateTime deletionTime = DateTime.parse("2000-08-01T00:00:00Z");
|
||||
DomainBase deletedDomain = persistDeletedDomain("deleted.tld", deletionTime);
|
||||
historyEntry = persistResource(new HistoryEntry.Builder().setParent(deletedDomain).build());
|
||||
|
@ -208,7 +205,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_idempotentForDuplicateRuns() throws Exception {
|
||||
void testSuccess_expandSingleEvent_idempotentForDuplicateRuns() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
runMapreduce();
|
||||
|
@ -225,7 +222,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_idempotentForExistingOneTime() throws Exception {
|
||||
void testSuccess_expandSingleEvent_idempotentForExistingOneTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
BillingEvent.OneTime persisted = persistResource(defaultOneTimeBuilder()
|
||||
.setParent(historyEntry)
|
||||
|
@ -240,8 +237,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_notIdempotentForDifferentBillingTime()
|
||||
throws Exception {
|
||||
void testSuccess_expandSingleEvent_notIdempotentForDifferentBillingTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
runMapreduce();
|
||||
|
@ -259,8 +255,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_notIdempotentForDifferentRecurring()
|
||||
throws Exception {
|
||||
void testSuccess_expandSingleEvent_notIdempotentForDifferentRecurring() throws Exception {
|
||||
persistResource(recurring);
|
||||
BillingEvent.Recurring recurring2 = persistResource(recurring.asBuilder()
|
||||
.setId(3L)
|
||||
|
@ -289,7 +284,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_ignoreRecurringBeforeWindow() throws Exception {
|
||||
void testSuccess_ignoreRecurringBeforeWindow() throws Exception {
|
||||
recurring = persistResource(recurring.asBuilder()
|
||||
.setEventTime(DateTime.parse("1997-01-05T00:00:00Z"))
|
||||
.setRecurrenceEndTime(DateTime.parse("1999-10-05T00:00:00Z"))
|
||||
|
@ -303,7 +298,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_ignoreRecurringAfterWindow() throws Exception {
|
||||
void testSuccess_ignoreRecurringAfterWindow() throws Exception {
|
||||
recurring = persistResource(recurring.asBuilder()
|
||||
.setEventTime(clock.nowUtc().plusYears(2))
|
||||
.build());
|
||||
|
@ -315,7 +310,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_billingTimeAtCursorTime() throws Exception {
|
||||
void testSuccess_expandSingleEvent_billingTimeAtCursorTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(DateTime.parse("2000-02-19T00:00:00Z"));
|
||||
runMapreduce();
|
||||
|
@ -328,8 +323,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_cursorTimeBetweenEventAndBillingTime()
|
||||
throws Exception {
|
||||
void testSuccess_expandSingleEvent_cursorTimeBetweenEventAndBillingTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(DateTime.parse("2000-01-12T00:00:00Z"));
|
||||
runMapreduce();
|
||||
|
@ -342,7 +336,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_billingTimeAtExecutionTime() throws Exception {
|
||||
void testSuccess_expandSingleEvent_billingTimeAtExecutionTime() throws Exception {
|
||||
DateTime testTime = DateTime.parse("2000-02-19T00:00:00Z").minusMillis(1);
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
|
@ -359,7 +353,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_multipleYearCreate() throws Exception {
|
||||
void testSuccess_expandSingleEvent_multipleYearCreate() throws Exception {
|
||||
DateTime testTime = beginningOfTest.plusYears(2);
|
||||
action.cursorTimeParam = Optional.of(recurring.getEventTime());
|
||||
recurring =
|
||||
|
@ -381,7 +375,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_withCursor() throws Exception {
|
||||
void testSuccess_expandSingleEvent_withCursor() throws Exception {
|
||||
persistResource(recurring);
|
||||
saveCursor(START_OF_TIME);
|
||||
runMapreduce();
|
||||
|
@ -394,7 +388,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_withCursorPastExpected() throws Exception {
|
||||
void testSuccess_expandSingleEvent_withCursorPastExpected() throws Exception {
|
||||
persistResource(recurring);
|
||||
// Simulate a quick second run of the mapreduce (this should be a no-op).
|
||||
saveCursor(clock.nowUtc().minusSeconds(1));
|
||||
|
@ -406,7 +400,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_recurrenceEndBeforeEvent() throws Exception {
|
||||
void testSuccess_expandSingleEvent_recurrenceEndBeforeEvent() throws Exception {
|
||||
// This can occur when a domain is transferred or deleted before a domain comes up for renewal.
|
||||
recurring = persistResource(recurring.asBuilder()
|
||||
.setRecurrenceEndTime(recurring.getEventTime().minusDays(5))
|
||||
|
@ -420,7 +414,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_dryRun() throws Exception {
|
||||
void testSuccess_expandSingleEvent_dryRun() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.isDryRun = true;
|
||||
saveCursor(START_OF_TIME); // Need a saved cursor to verify that it didn't move.
|
||||
|
@ -432,7 +426,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_multipleYears() throws Exception {
|
||||
void testSuccess_expandSingleEvent_multipleYears() throws Exception {
|
||||
DateTime testTime = clock.nowUtc().plusYears(5);
|
||||
clock.setTo(testTime);
|
||||
List<BillingEvent> expectedEvents = new ArrayList<>();
|
||||
|
@ -463,7 +457,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_multipleYears_cursorInBetweenYears() throws Exception {
|
||||
void testSuccess_expandSingleEvent_multipleYears_cursorInBetweenYears() throws Exception {
|
||||
DateTime testTime = clock.nowUtc().plusYears(5);
|
||||
clock.setTo(testTime);
|
||||
List<BillingEvent> expectedEvents = new ArrayList<>();
|
||||
|
@ -492,7 +486,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_singleEvent_beforeRenewal() throws Exception {
|
||||
void testSuccess_singleEvent_beforeRenewal() throws Exception {
|
||||
DateTime testTime = DateTime.parse("2000-01-04T00:00:00Z");
|
||||
clock.setTo(testTime);
|
||||
persistResource(recurring);
|
||||
|
@ -505,7 +499,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_singleEvent_afterRecurrenceEnd_inAutorenewGracePeriod() throws Exception {
|
||||
void testSuccess_singleEvent_afterRecurrenceEnd_inAutorenewGracePeriod() throws Exception {
|
||||
// The domain creation date is 1999-01-05, and the first renewal date is thus 2000-01-05.
|
||||
DateTime testTime = DateTime.parse("2001-02-06T00:00:00Z");
|
||||
clock.setTo(testTime);
|
||||
|
@ -530,8 +524,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_singleEvent_afterRecurrenceEnd_outsideAutorenewGracePeriod()
|
||||
throws Exception {
|
||||
void testSuccess_singleEvent_afterRecurrenceEnd_outsideAutorenewGracePeriod() throws Exception {
|
||||
// The domain creation date is 1999-01-05, and the first renewal date is thus 2000-01-05.
|
||||
DateTime testTime = DateTime.parse("2001-02-06T00:00:00Z");
|
||||
clock.setTo(testTime);
|
||||
|
@ -556,7 +549,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_billingTimeOnLeapYear() throws Exception {
|
||||
void testSuccess_expandSingleEvent_billingTimeOnLeapYear() throws Exception {
|
||||
recurring =
|
||||
persistResource(
|
||||
recurring.asBuilder().setEventTime(DateTime.parse("2000-01-15T00:00:00Z")).build());
|
||||
|
@ -575,7 +568,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandSingleEvent_billingTimeNotOnLeapYear() throws Exception {
|
||||
void testSuccess_expandSingleEvent_billingTimeNotOnLeapYear() throws Exception {
|
||||
DateTime testTime = DateTime.parse("2001-12-01T00:00:00Z");
|
||||
recurring =
|
||||
persistResource(
|
||||
|
@ -597,7 +590,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_expandMultipleEvents() throws Exception {
|
||||
void testSuccess_expandMultipleEvents() throws Exception {
|
||||
persistResource(recurring);
|
||||
BillingEvent.Recurring recurring2 = persistResource(recurring.asBuilder()
|
||||
.setEventTime(recurring.getEventTime().plusMonths(3))
|
||||
|
@ -630,7 +623,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_premiumDomain() throws Exception {
|
||||
void testSuccess_premiumDomain() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
|
@ -651,7 +644,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_varyingRenewPrices() throws Exception {
|
||||
void testSuccess_varyingRenewPrices() throws Exception {
|
||||
DateTime testTime = beginningOfTest.plusYears(1);
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -691,7 +684,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cursorAfterExecutionTime() {
|
||||
void testFailure_cursorAfterExecutionTime() {
|
||||
action.cursorTimeParam = Optional.of(clock.nowUtc().plusYears(1));
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, this::runMapreduce);
|
||||
|
@ -701,7 +694,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cursorAtExecutionTime() {
|
||||
void testFailure_cursorAtExecutionTime() {
|
||||
// The clock advances one milli on runMapreduce.
|
||||
action.cursorTimeParam = Optional.of(clock.nowUtc().plusMillis(1));
|
||||
IllegalArgumentException thrown =
|
||||
|
@ -712,7 +705,7 @@ public class ExpandRecurringBillingEventsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_mapperException_doesNotMoveCursor() throws Exception {
|
||||
void testFailure_mapperException_doesNotMoveCursor() throws Exception {
|
||||
saveCursor(START_OF_TIME); // Need a saved cursor to verify that it didn't move.
|
||||
// Set target to a TLD that doesn't exist.
|
||||
recurring = persistResource(recurring.asBuilder().setTargetId("domain.junk").build());
|
||||
|
|
|
@ -61,27 +61,24 @@ import google.registry.util.SystemSleeper;
|
|||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/** Unit tests for {@link RefreshDnsOnHostRenameAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RefreshDnsOnHostRenameActionTest
|
||||
extends MapreduceTestCase<RefreshDnsOnHostRenameAction> {
|
||||
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
private AsyncTaskEnqueuer enqueuer;
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z"));
|
||||
private final FakeResponse fakeResponse = new FakeResponse();
|
||||
@Mock private RequestStatusChecker requestStatusChecker;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("tld");
|
||||
enqueuer =
|
||||
AsyncTaskEnqueuerTest.createForTesting(
|
||||
|
@ -124,7 +121,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_dnsUpdateEnqueued() throws Exception {
|
||||
void testSuccess_dnsUpdateEnqueued() throws Exception {
|
||||
HostResource host = persistActiveHost("ns1.example.tld");
|
||||
persistResource(newDomainBase("example.tld", host));
|
||||
persistResource(newDomainBase("otherexample.tld", host));
|
||||
|
@ -141,7 +138,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleHostsProcessedInBatch() throws Exception {
|
||||
void testSuccess_multipleHostsProcessedInBatch() throws Exception {
|
||||
HostResource host1 = persistActiveHost("ns1.example.tld");
|
||||
HostResource host2 = persistActiveHost("ns2.example.tld");
|
||||
HostResource host3 = persistActiveHost("ns3.example.tld");
|
||||
|
@ -165,7 +162,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_deletedHost_doesntTriggerDnsRefresh() throws Exception {
|
||||
void testSuccess_deletedHost_doesntTriggerDnsRefresh() throws Exception {
|
||||
HostResource host = persistDeletedHost("ns11.fakesss.tld", clock.nowUtc().minusDays(4));
|
||||
persistResource(newDomainBase("example1.tld", host));
|
||||
DateTime timeEnqueued = clock.nowUtc();
|
||||
|
@ -180,7 +177,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
|
||||
void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
|
||||
HostResource renamedHost = persistActiveHost("ns1.example.tld");
|
||||
persistResource(
|
||||
newDomainBase("example.tld", renamedHost)
|
||||
|
@ -194,7 +191,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_hostDoesntExist_delaysTask() throws Exception {
|
||||
void testRun_hostDoesntExist_delaysTask() throws Exception {
|
||||
HostResource host = newHostResource("ns1.example.tld");
|
||||
enqueuer.enqueueAsyncDnsRefresh(host, clock.nowUtc());
|
||||
enqueueMapreduceOnly();
|
||||
|
@ -208,7 +205,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_cannotAcquireLock() {
|
||||
void test_cannotAcquireLock() {
|
||||
// Make lock acquisition fail.
|
||||
acquireLock();
|
||||
enqueueMapreduceOnly();
|
||||
|
@ -217,7 +214,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_mapreduceHasWorkToDo_lockIsAcquired() {
|
||||
void test_mapreduceHasWorkToDo_lockIsAcquired() {
|
||||
HostResource host = persistActiveHost("ns1.example.tld");
|
||||
enqueuer.enqueueAsyncDnsRefresh(host, clock.nowUtc());
|
||||
enqueueMapreduceOnly();
|
||||
|
@ -225,7 +222,7 @@ public class RefreshDnsOnHostRenameActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_noTasksToLease_releasesLockImmediately() throws Exception {
|
||||
void test_noTasksToLease_releasesLockImmediately() throws Exception {
|
||||
enqueueMapreduceOnly();
|
||||
assertNoDnsTasksEnqueued();
|
||||
assertNoTasksEnqueued(QUEUE_ASYNC_HOST_RENAME);
|
||||
|
|
|
@ -44,14 +44,11 @@ import google.registry.util.AppEngineServiceUtils;
|
|||
import google.registry.util.StringGenerator.Alphabets;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link RelockDomainAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RelockDomainActionTest {
|
||||
|
||||
private static final String DOMAIN_NAME = "example.tld";
|
||||
|
@ -67,7 +64,7 @@ public class RelockDomainActionTest {
|
|||
AsyncTaskEnqueuerTest.createForTesting(
|
||||
mock(AppEngineServiceUtils.class), clock, Duration.ZERO));
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngineRule =
|
||||
AppEngineRule.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
|
@ -78,8 +75,8 @@ public class RelockDomainActionTest {
|
|||
private RegistryLock oldLock;
|
||||
private RelockDomainAction action;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTlds("tld", "net");
|
||||
HostResource host = persistActiveHost("ns1.example.net");
|
||||
domain = persistResource(newDomainBase(DOMAIN_NAME, host));
|
||||
|
@ -95,7 +92,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLock() {
|
||||
void testLock() {
|
||||
action.run();
|
||||
assertThat(reloadDomain(domain).getStatusValues())
|
||||
.containsAtLeastElementsIn(REGISTRY_LOCK_STATUSES);
|
||||
|
@ -107,7 +104,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownCode() {
|
||||
void testFailure_unknownCode() {
|
||||
action = createAction(12128675309L);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_NO_CONTENT);
|
||||
|
@ -115,7 +112,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_pendingDelete() {
|
||||
void testFailure_pendingDelete() {
|
||||
persistResource(domain.asBuilder().setStatusValues(ImmutableSet.of(PENDING_DELETE)).build());
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_NO_CONTENT);
|
||||
|
@ -124,7 +121,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_pendingTransfer() {
|
||||
void testFailure_pendingTransfer() {
|
||||
persistResource(domain.asBuilder().setStatusValues(ImmutableSet.of(PENDING_TRANSFER)).build());
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_NO_CONTENT);
|
||||
|
@ -133,7 +130,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_domainAlreadyLocked() {
|
||||
void testFailure_domainAlreadyLocked() {
|
||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, null, true);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_NO_CONTENT);
|
||||
|
@ -142,7 +139,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_domainDeleted() {
|
||||
void testFailure_domainDeleted() {
|
||||
persistDomainAsDeleted(domain, clock.nowUtc());
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_NO_CONTENT);
|
||||
|
@ -151,7 +148,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_domainTransferred() {
|
||||
void testFailure_domainTransferred() {
|
||||
persistResource(domain.asBuilder().setPersistedCurrentSponsorClientId("NewRegistrar").build());
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_NO_CONTENT);
|
||||
|
@ -164,7 +161,7 @@ public class RelockDomainActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_relockAlreadySet() {
|
||||
void testFailure_relockAlreadySet() {
|
||||
RegistryLock newLock =
|
||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, null, true);
|
||||
saveRegistryLock(oldLock.asBuilder().setRelock(newLock).build());
|
||||
|
|
|
@ -25,18 +25,14 @@ import google.registry.model.transfer.TransferStatus;
|
|||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ResaveAllEppResourcesAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ResaveAllEppResourcesActionTest
|
||||
extends MapreduceTestCase<ResaveAllEppResourcesAction> {
|
||||
class ResaveAllEppResourcesActionTest extends MapreduceTestCase<ResaveAllEppResourcesAction> {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
action = new ResaveAllEppResourcesAction();
|
||||
action.mrRunner = makeDefaultRunner();
|
||||
action.response = new FakeResponse();
|
||||
|
@ -48,7 +44,7 @@ public class ResaveAllEppResourcesActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_mapreduceSuccessfullyResavesEntity() throws Exception {
|
||||
void test_mapreduceSuccessfullyResavesEntity() throws Exception {
|
||||
ContactResource contact = persistActiveContact("test123");
|
||||
DateTime creationTime = contact.getUpdateTimestamp().getTimestamp();
|
||||
assertThat(ofy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
||||
|
@ -60,7 +56,7 @@ public class ResaveAllEppResourcesActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_mapreduceResolvesPendingTransfer() throws Exception {
|
||||
void test_mapreduceResolvesPendingTransfer() throws Exception {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
// Set up a contact with a transfer that implicitly completed five days ago.
|
||||
ContactResource contact =
|
||||
|
|
|
@ -49,33 +49,32 @@ import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
|||
import google.registry.util.AppEngineServiceUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/** Unit tests for {@link ResaveEntityAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class ResaveEntityActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Mock private AppEngineServiceUtils appEngineServiceUtils;
|
||||
@Mock private Response response;
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2016-02-11T10:00:00Z"));
|
||||
private AsyncTaskEnqueuer asyncTaskEnqueuer;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
when(appEngineServiceUtils.getServiceHostname("backend")).thenReturn("backend.hostname.fake");
|
||||
asyncTaskEnqueuer =
|
||||
|
@ -93,8 +92,9 @@ public class ResaveEntityActionTest {
|
|||
action.run();
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void test_domainPendingTransfer_isResavedAndTransferCompleted() {
|
||||
void test_domainPendingTransfer_isResavedAndTransferCompleted() {
|
||||
DomainBase domain =
|
||||
persistDomainWithPendingTransfer(
|
||||
persistDomainWithDependentResources(
|
||||
|
@ -116,7 +116,7 @@ public class ResaveEntityActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_domainPendingDeletion_isResavedAndReenqueued() {
|
||||
void test_domainPendingDeletion_isResavedAndReenqueued() {
|
||||
DomainBase domain =
|
||||
persistResource(
|
||||
newDomainBase("domain.tld")
|
||||
|
|
|
@ -35,22 +35,18 @@ import java.io.StringWriter;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for Dagger injection of the DNS package. */
|
||||
@RunWith(JUnit4.class)
|
||||
public final class DnsInjectionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
private final HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
private final HttpServletResponse rsp = mock(HttpServletResponse.class);
|
||||
|
@ -59,8 +55,8 @@ public final class DnsInjectionTest {
|
|||
private DnsTestComponent component;
|
||||
private DnsQueue dnsQueue;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
when(rsp.getWriter()).thenReturn(new PrintWriter(httpOutput));
|
||||
component = DaggerDnsTestComponent.builder()
|
||||
|
@ -71,7 +67,7 @@ public final class DnsInjectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadDnsQueueAction_injectsAndWorks() {
|
||||
void testReadDnsQueueAction_injectsAndWorks() {
|
||||
persistActiveSubordinateHost("ns1.example.lol", persistActiveDomain("example.lol"));
|
||||
clock.advanceOneMilli();
|
||||
dnsQueue.addDomainRefreshTask("example.lol");
|
||||
|
@ -81,7 +77,7 @@ public final class DnsInjectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshDns_domain_injectsAndWorks() {
|
||||
void testRefreshDns_domain_injectsAndWorks() {
|
||||
persistActiveDomain("example.lol");
|
||||
when(req.getParameter("type")).thenReturn("domain");
|
||||
when(req.getParameter("name")).thenReturn("example.lol");
|
||||
|
@ -90,7 +86,7 @@ public final class DnsInjectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshDns_missingDomain_throwsNotFound() {
|
||||
void testRefreshDns_missingDomain_throwsNotFound() {
|
||||
when(req.getParameter("type")).thenReturn("domain");
|
||||
when(req.getParameter("name")).thenReturn("example.lol");
|
||||
NotFoundException thrown =
|
||||
|
@ -99,7 +95,7 @@ public final class DnsInjectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshDns_host_injectsAndWorks() {
|
||||
void testRefreshDns_host_injectsAndWorks() {
|
||||
persistActiveSubordinateHost("ns1.example.lol", persistActiveDomain("example.lol"));
|
||||
when(req.getParameter("type")).thenReturn("host");
|
||||
when(req.getParameter("name")).thenReturn("ns1.example.lol");
|
||||
|
@ -108,7 +104,7 @@ public final class DnsInjectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshDns_missingHost_throwsNotFound() {
|
||||
void testRefreshDns_missingHost_throwsNotFound() {
|
||||
when(req.getParameter("type")).thenReturn("host");
|
||||
when(req.getParameter("name")).thenReturn("ns1.example.lol");
|
||||
NotFoundException thrown =
|
||||
|
|
|
@ -24,31 +24,28 @@ import google.registry.testing.AppEngineRule;
|
|||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DnsQueue}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class DnsQueueTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
private DnsQueue dnsQueue;
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2010-01-01T10:00:00Z"));
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
dnsQueue = DnsQueue.createForTesting(clock);
|
||||
dnsQueue.leaseTasksBatchSize = 10;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_addHostRefreshTask_success() {
|
||||
void test_addHostRefreshTask_success() {
|
||||
createTld("tld");
|
||||
dnsQueue.addHostRefreshTask("octopus.tld");
|
||||
assertTasksEnqueued(
|
||||
|
@ -61,7 +58,7 @@ public class DnsQueueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_addHostRefreshTask_failsOnUnknownTld() {
|
||||
void test_addHostRefreshTask_failsOnUnknownTld() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
|
@ -78,7 +75,7 @@ public class DnsQueueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_addDomainRefreshTask_success() {
|
||||
void test_addDomainRefreshTask_success() {
|
||||
createTld("tld");
|
||||
dnsQueue.addDomainRefreshTask("octopus.tld");
|
||||
assertTasksEnqueued(
|
||||
|
@ -91,7 +88,7 @@ public class DnsQueueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_addDomainRefreshTask_failsOnUnknownTld() {
|
||||
void test_addDomainRefreshTask_failsOnUnknownTld() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
|
|
|
@ -44,22 +44,18 @@ import google.registry.testing.FakeLockHandler;
|
|||
import google.registry.testing.InjectRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link PublishDnsUpdatesAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class PublishDnsUpdatesActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
|
||||
private final FakeLockHandler lockHandler = new FakeLockHandler(true);
|
||||
private final DnsWriter dnsWriter = mock(DnsWriter.class);
|
||||
|
@ -67,8 +63,8 @@ public class PublishDnsUpdatesActionTest {
|
|||
private final DnsQueue dnsQueue = mock(DnsQueue.class);
|
||||
private PublishDnsUpdatesAction action;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
createTld("xn--q9jyb4c");
|
||||
persistResource(
|
||||
|
@ -104,7 +100,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHost_published() {
|
||||
void testHost_published() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.hosts = ImmutableSet.of("ns1.example.xn--q9jyb4c");
|
||||
|
||||
|
@ -132,7 +128,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomain_published() {
|
||||
void testDomain_published() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.xn--q9jyb4c");
|
||||
|
||||
|
@ -160,7 +156,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAction_acquiresCorrectLock() {
|
||||
void testAction_acquiresCorrectLock() {
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build());
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.lockIndex = 2;
|
||||
|
@ -178,7 +174,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublish_commitFails() {
|
||||
void testPublish_commitFails() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.xn--q9jyb4c", "example2.xn--q9jyb4c");
|
||||
action.hosts =
|
||||
|
@ -207,11 +203,12 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHostAndDomain_published() {
|
||||
void testHostAndDomain_published() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.xn--q9jyb4c", "example2.xn--q9jyb4c");
|
||||
action.hosts = ImmutableSet.of(
|
||||
"ns1.example.xn--q9jyb4c", "ns2.example.xn--q9jyb4c", "ns1.example2.xn--q9jyb4c");
|
||||
action.hosts =
|
||||
ImmutableSet.of(
|
||||
"ns1.example.xn--q9jyb4c", "ns2.example.xn--q9jyb4c", "ns1.example2.xn--q9jyb4c");
|
||||
|
||||
action.run();
|
||||
|
||||
|
@ -241,7 +238,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWrongTld_notPublished() {
|
||||
void testWrongTld_notPublished() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com", "example2.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
|
||||
|
@ -269,7 +266,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLockIsntAvailable() {
|
||||
void testLockIsntAvailable() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com", "example2.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
|
||||
|
@ -293,7 +290,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testParam_invalidLockIndex() {
|
||||
void testParam_invalidLockIndex() {
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build());
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com");
|
||||
|
@ -319,7 +316,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRegistryParam_mismatchedMaxLocks() {
|
||||
void testRegistryParam_mismatchedMaxLocks() {
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build());
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com");
|
||||
|
@ -345,7 +342,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWrongDnsWriter() {
|
||||
void testWrongDnsWriter() {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com", "example2.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
|
||||
|
|
|
@ -56,14 +56,11 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.IntStream;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ReadDnsQueueAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ReadDnsQueueActionTest {
|
||||
|
||||
private static final int TEST_TLD_UPDATE_BATCH_SIZE = 100;
|
||||
|
@ -72,7 +69,7 @@ public class ReadDnsQueueActionTest {
|
|||
// test in the future. Set to year 3000 so it'll remain in the future for a very long time.
|
||||
private FakeClock clock = new FakeClock(DateTime.parse("3000-01-01TZ"));
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
|
@ -93,8 +90,8 @@ public class ReadDnsQueueActionTest {
|
|||
.withClock(clock)
|
||||
.build();
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
// Because of b/73372999 - the FakeClock can't be in the past, or the TaskQueues stop working.
|
||||
// To make sure it's never in the past, we set the date far-far into the future
|
||||
clock.setTo(DateTime.parse("3000-01-01TZ"));
|
||||
|
@ -171,7 +168,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_methodPostIsDefault() {
|
||||
void testSuccess_methodPostIsDefault() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
|
@ -187,7 +184,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_allSingleLockTlds() {
|
||||
void testSuccess_allSingleLockTlds() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
|
@ -200,7 +197,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_moreUpdatesThanQueueBatchSize() {
|
||||
void testSuccess_moreUpdatesThanQueueBatchSize() {
|
||||
// The task queue has a batch size of 1000 (that's the maximum number of items you can lease at
|
||||
// once).
|
||||
ImmutableList<String> domains =
|
||||
|
@ -219,15 +216,14 @@ public class ReadDnsQueueActionTest {
|
|||
assertThat(queuedParams).hasSize(15);
|
||||
// Check all the expected domains are indeed enqueued
|
||||
assertThat(
|
||||
queuedParams
|
||||
.stream()
|
||||
queuedParams.stream()
|
||||
.map(params -> params.get("domains").stream().collect(onlyElement()))
|
||||
.flatMap(values -> Splitter.on(',').splitToList(values).stream()))
|
||||
.containsExactlyElementsIn(domains);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_twoDnsWriters() {
|
||||
void testSuccess_twoDnsWriters() {
|
||||
persistResource(
|
||||
Registry.get("com")
|
||||
.asBuilder()
|
||||
|
@ -242,7 +238,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_differentUpdateTimes_usesMinimum() {
|
||||
void testSuccess_differentUpdateTimes_usesMinimum() {
|
||||
clock.setTo(DateTime.parse("3000-02-03TZ"));
|
||||
dnsQueue.addDomainRefreshTask("domain1.com");
|
||||
clock.setTo(DateTime.parse("3000-02-04TZ"));
|
||||
|
@ -256,18 +252,18 @@ public class ReadDnsQueueActionTest {
|
|||
assertThat(getQueuedParams(DNS_PUBLISH_PUSH_QUEUE_NAME)).hasSize(1);
|
||||
assertThat(getQueuedParams(DNS_PUBLISH_PUSH_QUEUE_NAME).get(0))
|
||||
.containsExactly(
|
||||
"enqueued", "3000-02-05T01:00:00.000Z",
|
||||
"itemsCreated", "3000-02-03T00:00:00.000Z",
|
||||
"tld", "com",
|
||||
"dnsWriter", "comWriter",
|
||||
"domains", "domain1.com,domain2.com,domain3.com",
|
||||
"hosts", "",
|
||||
"lockIndex", "1",
|
||||
"numPublishLocks", "1");
|
||||
"enqueued", "3000-02-05T01:00:00.000Z",
|
||||
"itemsCreated", "3000-02-03T00:00:00.000Z",
|
||||
"tld", "com",
|
||||
"dnsWriter", "comWriter",
|
||||
"domains", "domain1.com,domain2.com,domain3.com",
|
||||
"hosts", "",
|
||||
"lockIndex", "1",
|
||||
"numPublishLocks", "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_oneTldPaused_returnedToQueue() {
|
||||
void testSuccess_oneTldPaused_returnedToQueue() {
|
||||
persistResource(Registry.get("net").asBuilder().setDnsPaused(true).build());
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
|
@ -281,7 +277,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_oneTldUnknown_returnedToQueue() {
|
||||
void testSuccess_oneTldUnknown_returnedToQueue() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
|
||||
|
@ -301,7 +297,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_corruptTaskTldMismatch_published() {
|
||||
void testSuccess_corruptTaskTldMismatch_published() {
|
||||
// TODO(mcilwain): what's the correct action to take in this case?
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
|
@ -322,7 +318,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_corruptTaskNoTld_discarded() {
|
||||
void testSuccess_corruptTaskNoTld_discarded() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
|
||||
|
@ -341,7 +337,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_corruptTaskNoName_discarded() {
|
||||
void testSuccess_corruptTaskNoName_discarded() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
|
||||
|
@ -360,7 +356,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_corruptTaskNoType_discarded() {
|
||||
void testSuccess_corruptTaskNoType_discarded() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
|
||||
|
@ -379,7 +375,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_corruptTaskWrongType_discarded() {
|
||||
void testSuccess_corruptTaskWrongType_discarded() {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
|
||||
|
@ -399,7 +395,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_zone_getsIgnored() {
|
||||
void testSuccess_zone_getsIgnored() {
|
||||
dnsQueue.addHostRefreshTask("ns1.domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addZoneRefreshTask("example");
|
||||
|
@ -420,7 +416,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_manyDomainsAndHosts() {
|
||||
void testSuccess_manyDomainsAndHosts() {
|
||||
for (int i = 0; i < 150; i++) {
|
||||
// 0: domain; 1: host 1; 2: host 2
|
||||
for (int thingType = 0; thingType < 3; thingType++) {
|
||||
|
@ -491,7 +487,7 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_lockGroupsHostBySuperordinateDomain() {
|
||||
void testSuccess_lockGroupsHostBySuperordinateDomain() {
|
||||
dnsQueue.addDomainRefreshTask("hello.multilock.uk");
|
||||
dnsQueue.addHostRefreshTask("ns1.abc.hello.multilock.uk");
|
||||
dnsQueue.addHostRefreshTask("ns2.hello.multilock.uk");
|
||||
|
|
|
@ -30,17 +30,14 @@ import google.registry.request.HttpException.BadRequestException;
|
|||
import google.registry.request.HttpException.NotFoundException;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link RefreshDnsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RefreshDnsActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
|
@ -51,13 +48,13 @@ public class RefreshDnsActionTest {
|
|||
new RefreshDnsAction(name, type, clock, dnsQueue).run();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_host() {
|
||||
void testSuccess_host() {
|
||||
DomainBase domain = persistActiveDomain("example.xn--q9jyb4c");
|
||||
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain);
|
||||
run(TargetType.HOST, "ns1.example.xn--q9jyb4c");
|
||||
|
@ -66,7 +63,7 @@ public class RefreshDnsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_externalHostNotEnqueued() {
|
||||
void testSuccess_externalHostNotEnqueued() {
|
||||
persistActiveDomain("example.xn--q9jyb4c");
|
||||
persistActiveHost("ns1.example.xn--q9jyb4c");
|
||||
BadRequestException thrown =
|
||||
|
@ -85,7 +82,7 @@ public class RefreshDnsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_domain() {
|
||||
void testSuccess_domain() {
|
||||
persistActiveDomain("example.xn--q9jyb4c");
|
||||
run(TargetType.DOMAIN, "example.xn--q9jyb4c");
|
||||
verify(dnsQueue).addDomainRefreshTask("example.xn--q9jyb4c");
|
||||
|
@ -93,17 +90,17 @@ public class RefreshDnsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unqualifiedName() {
|
||||
void testFailure_unqualifiedName() {
|
||||
assertThrows(BadRequestException.class, () -> run(TargetType.DOMAIN, "example"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_hostDoesNotExist() {
|
||||
void testFailure_hostDoesNotExist() {
|
||||
assertThrows(NotFoundException.class, () -> run(TargetType.HOST, "ns1.example.xn--q9jyb4c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_domainDoesNotExist() {
|
||||
void testFailure_domainDoesNotExist() {
|
||||
assertThrows(NotFoundException.class, () -> run(TargetType.DOMAIN, "example.xn--q9jyb4c"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,10 @@ package google.registry.dns.writer;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link BaseDnsWriter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class BaseDnsWriterTest {
|
||||
class BaseDnsWriterTest {
|
||||
|
||||
static class StubDnsWriter extends BaseDnsWriter {
|
||||
|
||||
|
@ -46,7 +43,7 @@ public class BaseDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_cannotBeCalledTwice() {
|
||||
void test_cannotBeCalledTwice() {
|
||||
StubDnsWriter writer = new StubDnsWriter();
|
||||
assertThat(writer.commitCallCount).isEqualTo(0);
|
||||
writer.commit();
|
||||
|
|
|
@ -53,27 +53,25 @@ import java.net.Inet4Address;
|
|||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/** Test case for {@link CloudDnsWriter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CloudDnsWriterTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
|
||||
private static final Inet4Address IPv4 = (Inet4Address) InetAddresses.forString("127.0.0.1");
|
||||
private static final Inet6Address IPv6 = (Inet6Address) InetAddresses.forString("::1");
|
||||
private static final Duration DEFAULT_A_TTL = Duration.standardSeconds(11);
|
||||
|
@ -116,8 +114,8 @@ public class CloudDnsWriterTest {
|
|||
return listResourceRecordSetsRequest;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
createTld("tld");
|
||||
writer =
|
||||
new CloudDnsWriter(
|
||||
|
@ -312,15 +310,17 @@ public class CloudDnsWriterTest {
|
|||
.build();
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testLoadDomain_nonExistentDomain() {
|
||||
void testLoadDomain_nonExistentDomain() {
|
||||
writer.publishDomain("example.tld");
|
||||
|
||||
verifyZone(ImmutableSet.of());
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testLoadDomain_noDsDataOrNameservers() {
|
||||
void testLoadDomain_noDsDataOrNameservers() {
|
||||
persistResource(fakeDomain("example.tld", ImmutableSet.of(), 0));
|
||||
writer.publishDomain("example.tld");
|
||||
|
||||
|
@ -328,7 +328,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadDomain_deleteOldData() {
|
||||
void testLoadDomain_deleteOldData() {
|
||||
stubZone = fakeDomainRecords("example.tld", 2, 2, 2, 2);
|
||||
persistResource(fakeDomain("example.tld", ImmutableSet.of(), 0));
|
||||
writer.publishDomain("example.tld");
|
||||
|
@ -337,7 +337,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadDomain_withExternalNs() {
|
||||
void testLoadDomain_withExternalNs() {
|
||||
persistResource(
|
||||
fakeDomain("example.tld", ImmutableSet.of(persistResource(fakeHost("0.external"))), 0));
|
||||
writer.publishDomain("example.tld");
|
||||
|
@ -346,7 +346,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadDomain_withDsData() {
|
||||
void testLoadDomain_withDsData() {
|
||||
persistResource(
|
||||
fakeDomain("example.tld", ImmutableSet.of(persistResource(fakeHost("0.external"))), 1));
|
||||
writer.publishDomain("example.tld");
|
||||
|
@ -355,7 +355,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadDomain_withInBailiwickNs_IPv4() {
|
||||
void testLoadDomain_withInBailiwickNs_IPv4() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
"example.tld",
|
||||
|
@ -370,7 +370,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadDomain_withInBailiwickNs_IPv6() {
|
||||
void testLoadDomain_withInBailiwickNs_IPv6() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
"example.tld",
|
||||
|
@ -385,7 +385,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadDomain_withNameserveThatEndsWithDomainName() {
|
||||
void testLoadDomain_withNameserveThatEndsWithDomainName() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
"example.tld",
|
||||
|
@ -396,8 +396,9 @@ public class CloudDnsWriterTest {
|
|||
verifyZone(fakeDomainRecords("example.tld", "ns.another-example.tld."));
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testLoadHost_externalHost() {
|
||||
void testLoadHost_externalHost() {
|
||||
writer.publishHost("ns1.example.com");
|
||||
|
||||
// external hosts should not be published in our zone
|
||||
|
@ -405,7 +406,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadHost_removeStaleNsRecords() {
|
||||
void testLoadHost_removeStaleNsRecords() {
|
||||
// Initialize the zone with both NS records
|
||||
stubZone = fakeDomainRecords("example.tld", 2, 0, 0, 0);
|
||||
|
||||
|
@ -426,8 +427,9 @@ public class CloudDnsWriterTest {
|
|||
verifyZone(fakeDomainRecords("example.tld", 1, 0, 0, 0));
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void retryMutateZoneOnError() {
|
||||
void retryMutateZoneOnError() {
|
||||
CloudDnsWriter spyWriter = spy(writer);
|
||||
// First call - throw. Second call - do nothing.
|
||||
doThrow(ZoneStateException.class)
|
||||
|
@ -439,8 +441,9 @@ public class CloudDnsWriterTest {
|
|||
verify(spyWriter, times(2)).mutateZone(ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testLoadDomain_withClientHold() {
|
||||
void testLoadDomain_withClientHold() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
"example.tld",
|
||||
|
@ -454,8 +457,9 @@ public class CloudDnsWriterTest {
|
|||
verifyZone(ImmutableSet.of());
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testLoadDomain_withServerHold() {
|
||||
void testLoadDomain_withServerHold() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
"example.tld",
|
||||
|
@ -470,8 +474,9 @@ public class CloudDnsWriterTest {
|
|||
verifyZone(ImmutableSet.of());
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testLoadDomain_withPendingDelete() {
|
||||
void testLoadDomain_withPendingDelete() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
"example.tld",
|
||||
|
@ -486,7 +491,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDuplicateRecords() {
|
||||
void testDuplicateRecords() {
|
||||
// In publishing DNS records, we can end up publishing information on the same host twice
|
||||
// (through a domain change and a host change), so this scenario needs to work.
|
||||
persistResource(
|
||||
|
@ -504,7 +509,7 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidZoneNames() {
|
||||
void testInvalidZoneNames() {
|
||||
createTld("triple.secret.tld");
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
|
@ -518,8 +523,9 @@ public class CloudDnsWriterTest {
|
|||
assertThat(zoneNameCaptor.getValue()).isEqualTo("triple-secret-tld");
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testEmptyCommit() {
|
||||
void testEmptyCommit() {
|
||||
writer.commit();
|
||||
verify(dnsConnection, times(0)).changes();
|
||||
}
|
||||
|
|
|
@ -33,10 +33,8 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Arrays;
|
||||
import javax.net.SocketFactory;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbill.DNS.ARecord;
|
||||
import org.xbill.DNS.DClass;
|
||||
import org.xbill.DNS.Flags;
|
||||
|
@ -49,8 +47,7 @@ import org.xbill.DNS.Type;
|
|||
import org.xbill.DNS.Update;
|
||||
|
||||
/** Unit tests for {@link DnsMessageTransport}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class DnsMessageTransportTest {
|
||||
class DnsMessageTransportTest {
|
||||
|
||||
private static final String UPDATE_HOST = "127.0.0.1";
|
||||
|
||||
|
@ -60,8 +57,9 @@ public class DnsMessageTransportTest {
|
|||
private Message simpleQuery;
|
||||
private Message expectedResponse;
|
||||
private DnsMessageTransport resolver;
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
simpleQuery =
|
||||
Message.newQuery(Record.newRecord(Name.fromString("example.com."), Type.A, DClass.IN));
|
||||
expectedResponse = responseMessageWithCode(simpleQuery, Rcode.NOERROR);
|
||||
|
@ -71,7 +69,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSentMessageHasCorrectLengthAndContent() throws Exception {
|
||||
void testSentMessageHasCorrectLengthAndContent() throws Exception {
|
||||
ByteArrayInputStream inputStream =
|
||||
new ByteArrayInputStream(messageToBytesWithLength(expectedResponse));
|
||||
when(mockSocket.getInputStream()).thenReturn(inputStream);
|
||||
|
@ -89,7 +87,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReceivedMessageWithLengthHasCorrectContent() throws Exception {
|
||||
void testReceivedMessageWithLengthHasCorrectContent() throws Exception {
|
||||
ByteArrayInputStream inputStream =
|
||||
new ByteArrayInputStream(messageToBytesWithLength(expectedResponse));
|
||||
when(mockSocket.getInputStream()).thenReturn(inputStream);
|
||||
|
@ -102,7 +100,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEofReceivingResponse() throws Exception {
|
||||
void testEofReceivingResponse() throws Exception {
|
||||
byte[] messageBytes = messageToBytesWithLength(expectedResponse);
|
||||
ByteArrayInputStream inputStream =
|
||||
new ByteArrayInputStream(Arrays.copyOf(messageBytes, messageBytes.length - 1));
|
||||
|
@ -112,7 +110,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTimeoutReceivingResponse() throws Exception {
|
||||
void testTimeoutReceivingResponse() throws Exception {
|
||||
InputStream mockInputStream = mock(InputStream.class);
|
||||
when(mockInputStream.read()).thenThrow(new SocketTimeoutException("testing"));
|
||||
when(mockSocket.getInputStream()).thenReturn(mockInputStream);
|
||||
|
@ -126,7 +124,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSentMessageTooLongThrowsException() throws Exception {
|
||||
void testSentMessageTooLongThrowsException() throws Exception {
|
||||
Update oversize = new Update(Name.fromString("tld", Name.root));
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
oversize.add(
|
||||
|
@ -143,7 +141,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testResponseIdMismatchThrowsExeption() throws Exception {
|
||||
void testResponseIdMismatchThrowsExeption() throws Exception {
|
||||
expectedResponse.getHeader().setID(1 + simpleQuery.getHeader().getID());
|
||||
when(mockSocket.getInputStream())
|
||||
.thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)));
|
||||
|
@ -159,7 +157,7 @@ public class DnsMessageTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testResponseOpcodeMismatchThrowsException() throws Exception {
|
||||
void testResponseOpcodeMismatchThrowsException() throws Exception {
|
||||
simpleQuery.getHeader().setOpcode(Opcode.QUERY);
|
||||
expectedResponse.getHeader().setOpcode(Opcode.STATUS);
|
||||
when(mockSocket.getInputStream())
|
||||
|
|
|
@ -49,16 +49,16 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
import org.xbill.DNS.Flags;
|
||||
import org.xbill.DNS.Message;
|
||||
import org.xbill.DNS.Opcode;
|
||||
|
@ -70,15 +70,14 @@ import org.xbill.DNS.Type;
|
|||
import org.xbill.DNS.Update;
|
||||
|
||||
/** Unit tests for {@link DnsUpdateWriter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class DnsUpdateWriterTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Mock private DnsMessageTransport mockResolver;
|
||||
@Captor private ArgumentCaptor<Update> updateCaptor;
|
||||
|
@ -87,8 +86,8 @@ public class DnsUpdateWriterTest {
|
|||
|
||||
private DnsUpdateWriter writer;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
|
||||
createTld("tld");
|
||||
|
@ -99,7 +98,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishDomainCreate_publishesNameServers() throws Exception {
|
||||
void testPublishDomainCreate_publishesNameServers() throws Exception {
|
||||
HostResource host1 = persistActiveHost("ns1.example.tld");
|
||||
HostResource host2 = persistActiveHost("ns2.example.tld");
|
||||
DomainBase domain =
|
||||
|
@ -120,8 +119,9 @@ public class DnsUpdateWriterTest {
|
|||
assertThatTotalUpdateSetsIs(update, 2); // The delete and NS sets
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testPublishAtomic_noCommit() {
|
||||
void testPublishAtomic_noCommit() {
|
||||
HostResource host1 = persistActiveHost("ns.example1.tld");
|
||||
DomainBase domain1 =
|
||||
persistActiveDomain("example1.tld")
|
||||
|
@ -145,7 +145,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishAtomic_oneUpdate() throws Exception {
|
||||
void testPublishAtomic_oneUpdate() throws Exception {
|
||||
HostResource host1 = persistActiveHost("ns.example1.tld");
|
||||
DomainBase domain1 =
|
||||
persistActiveDomain("example1.tld")
|
||||
|
@ -177,7 +177,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishDomainCreate_publishesDelegationSigner() throws Exception {
|
||||
void testPublishDomainCreate_publishesDelegationSigner() throws Exception {
|
||||
DomainBase domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
|
@ -201,7 +201,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception {
|
||||
void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception {
|
||||
DomainBase domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
|
@ -221,7 +221,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishDomainDelete_removesDnsRecords() throws Exception {
|
||||
void testPublishDomainDelete_removesDnsRecords() throws Exception {
|
||||
persistDeletedDomain("example.tld", clock.nowUtc().minusDays(1));
|
||||
|
||||
writer.publishDomain("example.tld");
|
||||
|
@ -235,7 +235,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishHostCreate_publishesAddressRecords() throws Exception {
|
||||
void testPublishHostCreate_publishesAddressRecords() throws Exception {
|
||||
HostResource host =
|
||||
persistResource(
|
||||
newHostResource("ns1.example.tld")
|
||||
|
@ -268,7 +268,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishHostDelete_removesDnsRecords() throws Exception {
|
||||
void testPublishHostDelete_removesDnsRecords() throws Exception {
|
||||
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
persistActiveDomain("example.tld");
|
||||
|
||||
|
@ -284,7 +284,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishHostDelete_removesGlueRecords() throws Exception {
|
||||
void testPublishHostDelete_removesGlueRecords() throws Exception {
|
||||
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
persistResource(
|
||||
persistActiveDomain("example.tld")
|
||||
|
@ -305,7 +305,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishDomainExternalAndInBailiwickNameServer() throws Exception {
|
||||
void testPublishDomainExternalAndInBailiwickNameServer() throws Exception {
|
||||
HostResource externalNameserver = persistResource(newHostResource("ns1.example.com"));
|
||||
HostResource inBailiwickNameserver =
|
||||
persistResource(
|
||||
|
@ -342,7 +342,7 @@ public class DnsUpdateWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPublishDomainDeleteOrphanGlues() throws Exception {
|
||||
void testPublishDomainDeleteOrphanGlues() throws Exception {
|
||||
HostResource inBailiwickNameserver =
|
||||
persistResource(
|
||||
newHostResource("ns1.example.tld")
|
||||
|
@ -377,9 +377,10 @@ public class DnsUpdateWriterTest {
|
|||
assertThatTotalUpdateSetsIs(update, 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@SuppressWarnings("AssertThrowsMultipleStatements")
|
||||
public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
|
||||
@Test
|
||||
void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
|
||||
DomainBase domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
|
@ -397,9 +398,10 @@ public class DnsUpdateWriterTest {
|
|||
assertThat(thrown).hasMessageThat().contains("SERVFAIL");
|
||||
}
|
||||
|
||||
@Test
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@SuppressWarnings("AssertThrowsMultipleStatements")
|
||||
public void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
|
||||
@Test
|
||||
void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
|
||||
HostResource host =
|
||||
persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld"))
|
||||
.asBuilder()
|
||||
|
|
|
@ -27,21 +27,19 @@ import google.registry.export.datastore.Operation;
|
|||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link BackupDatastoreAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class BackupDatastoreActionTest {
|
||||
|
||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
||||
|
||||
@Mock private DatastoreAdmin datastoreAdmin;
|
||||
@Mock private Export exportRequest;
|
||||
|
@ -50,8 +48,8 @@ public class BackupDatastoreActionTest {
|
|||
private final FakeResponse response = new FakeResponse();
|
||||
private final BackupDatastoreAction action = new BackupDatastoreAction();
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
action.datastoreAdmin = datastoreAdmin;
|
||||
action.response = response;
|
||||
|
||||
|
@ -66,7 +64,7 @@ public class BackupDatastoreActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBackup_enqueuesPollTask() {
|
||||
void testBackup_enqueuesPollTask() {
|
||||
action.run();
|
||||
assertTasksEnqueued(
|
||||
CheckBackupAction.QUEUE,
|
||||
|
|
|
@ -52,17 +52,14 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link BigqueryPollJobAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class BigqueryPollJobActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
|
@ -79,8 +76,8 @@ public class BigqueryPollJobActionTest {
|
|||
private final CapturingLogHandler logHandler = new CapturingLogHandler();
|
||||
private BigqueryPollJobAction action = new BigqueryPollJobAction();
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
action.bigquery = bigquery;
|
||||
when(bigquery.jobs()).thenReturn(bigqueryJobs);
|
||||
when(bigqueryJobs.get(PROJECT_ID, JOB_ID)).thenReturn(bigqueryJobsGet);
|
||||
|
@ -100,14 +97,14 @@ public class BigqueryPollJobActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_enqueuePollTask() {
|
||||
void testSuccess_enqueuePollTask() {
|
||||
new BigqueryPollJobEnqueuer(TASK_QUEUE_UTILS).enqueuePollTask(
|
||||
new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID));
|
||||
assertTasksEnqueued(BigqueryPollJobAction.QUEUE, newPollJobTaskMatcher("GET"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_enqueuePollTask_withChainedTask() throws Exception {
|
||||
void testSuccess_enqueuePollTask_withChainedTask() throws Exception {
|
||||
TaskOptions chainedTask = TaskOptions.Builder
|
||||
.withUrl("/_dr/something")
|
||||
.method(Method.POST)
|
||||
|
@ -126,7 +123,7 @@ public class BigqueryPollJobActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_jobCompletedSuccessfully() throws Exception {
|
||||
void testSuccess_jobCompletedSuccessfully() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("DONE")));
|
||||
action.run();
|
||||
|
@ -135,7 +132,7 @@ public class BigqueryPollJobActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_chainedPayloadAndJobSucceeded_enqueuesChainedTask() throws Exception {
|
||||
void testSuccess_chainedPayloadAndJobSucceeded_enqueuesChainedTask() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("DONE")));
|
||||
|
||||
|
@ -167,7 +164,7 @@ public class BigqueryPollJobActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testJobFailed() throws Exception {
|
||||
void testJobFailed() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(new Job().setStatus(
|
||||
new JobStatus()
|
||||
.setState("DONE")
|
||||
|
@ -179,20 +176,20 @@ public class BigqueryPollJobActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testJobPending() throws Exception {
|
||||
void testJobPending() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("PENDING")));
|
||||
assertThrows(NotModifiedException.class, action::run);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobStatusUnreadable() throws Exception {
|
||||
void testJobStatusUnreadable() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenThrow(IOException.class);
|
||||
assertThrows(NotModifiedException.class, action::run);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badChainedTaskPayload() throws Exception {
|
||||
void testFailure_badChainedTaskPayload() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("DONE")));
|
||||
action.payload = "payload".getBytes(UTF_8);
|
||||
|
|
|
@ -42,26 +42,26 @@ import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
|||
import google.registry.testing.TestDataHelper;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/** Unit tests for {@link CheckBackupAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CheckBackupActionTest {
|
||||
|
||||
static final DateTime START_TIME = DateTime.parse("2014-08-01T01:02:03Z");
|
||||
static final DateTime COMPLETE_TIME = START_TIME.plus(Duration.standardMinutes(30));
|
||||
private static final DateTime START_TIME = DateTime.parse("2014-08-01T01:02:03Z");
|
||||
private static final DateTime COMPLETE_TIME = START_TIME.plus(Duration.standardMinutes(30));
|
||||
|
||||
static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
|
||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
||||
|
||||
@Mock private DatastoreAdmin datastoreAdmin;
|
||||
@Mock private Get getNotFoundBackupProgressRequest;
|
||||
|
@ -72,8 +72,8 @@ public class CheckBackupActionTest {
|
|||
private final FakeClock clock = new FakeClock(COMPLETE_TIME.plusMillis(1000));
|
||||
private final CheckBackupAction action = new CheckBackupAction();
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
action.requestMethod = Method.POST;
|
||||
action.datastoreAdmin = datastoreAdmin;
|
||||
action.clock = clock;
|
||||
|
@ -121,8 +121,9 @@ public class CheckBackupActionTest {
|
|||
.param("kinds", kinds));
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testSuccess_enqueuePollTask() {
|
||||
void testSuccess_enqueuePollTask() {
|
||||
CheckBackupAction.enqueuePollTask("some_backup_name", ImmutableSet.of("one", "two", "three"));
|
||||
assertTasksEnqueued(
|
||||
CheckBackupAction.QUEUE,
|
||||
|
@ -134,7 +135,7 @@ public class CheckBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_forPendingBackup_returnsNotModified() throws Exception {
|
||||
void testPost_forPendingBackup_returnsNotModified() throws Exception {
|
||||
setPendingBackup();
|
||||
|
||||
NotModifiedException thrown = assertThrows(NotModifiedException.class, action::run);
|
||||
|
@ -144,7 +145,7 @@ public class CheckBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_forStalePendingBackupBackup_returnsNoContent() throws Exception {
|
||||
void testPost_forStalePendingBackupBackup_returnsNoContent() throws Exception {
|
||||
setPendingBackup();
|
||||
clock.setTo(
|
||||
START_TIME
|
||||
|
@ -161,7 +162,7 @@ public class CheckBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_forCompleteBackup_enqueuesLoadTask() throws Exception {
|
||||
void testPost_forCompleteBackup_enqueuesLoadTask() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.run();
|
||||
assertLoadTaskEnqueued(
|
||||
|
@ -171,7 +172,7 @@ public class CheckBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_forCompleteBackup_withExtraKindsToLoad_enqueuesLoadTask() throws Exception {
|
||||
void testPost_forCompleteBackup_withExtraKindsToLoad_enqueuesLoadTask() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.kindsToLoadParam = "one,foo";
|
||||
|
||||
|
@ -183,7 +184,7 @@ public class CheckBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_forCompleteBackup_withEmptyKindsToLoad_skipsLoadTask() throws Exception {
|
||||
void testPost_forCompleteBackup_withEmptyKindsToLoad_skipsLoadTask() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.kindsToLoadParam = "";
|
||||
|
||||
|
@ -191,8 +192,9 @@ public class CheckBackupActionTest {
|
|||
assertNoTasksEnqueued("export-snapshot");
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testPost_forBadBackup_returnsBadRequest() throws Exception {
|
||||
void testPost_forBadBackup_returnsBadRequest() throws Exception {
|
||||
setBackupNotFound();
|
||||
|
||||
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
|
||||
|
@ -200,7 +202,7 @@ public class CheckBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGet_returnsInformation() throws Exception {
|
||||
void testGet_returnsInformation() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.requestMethod = Method.GET;
|
||||
|
||||
|
@ -212,8 +214,9 @@ public class CheckBackupActionTest {
|
|||
.trim());
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
public void testGet_forBadBackup_returnsError() throws Exception {
|
||||
void testGet_forBadBackup_returnsError() throws Exception {
|
||||
setBackupNotFound();
|
||||
action.requestMethod = Method.GET;
|
||||
|
||||
|
|
|
@ -29,13 +29,10 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.re2j.Pattern;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ExportConstants}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExportConstantsTest {
|
||||
class ExportConstantsTest {
|
||||
|
||||
private static final String GOLDEN_BACKUP_KINDS_FILENAME = "backup_kinds.txt";
|
||||
|
||||
|
@ -53,17 +50,17 @@ public class ExportConstantsTest {
|
|||
"");
|
||||
|
||||
@Test
|
||||
public void testBackupKinds_matchGoldenBackupKindsFile() {
|
||||
void testBackupKinds_matchGoldenBackupKindsFile() {
|
||||
checkKindsMatchGoldenFile("backed-up", GOLDEN_BACKUP_KINDS_FILENAME, getBackupKinds());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReportingKinds_matchGoldenReportingKindsFile() {
|
||||
void testReportingKinds_matchGoldenReportingKindsFile() {
|
||||
checkKindsMatchGoldenFile("reporting", GOLDEN_REPORTING_KINDS_FILENAME, getReportingKinds());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReportingKinds_areSubsetOfBackupKinds() {
|
||||
void testReportingKinds_areSubsetOfBackupKinds() {
|
||||
assertThat(getBackupKinds()).containsAtLeastElementsIn(getReportingKinds());
|
||||
}
|
||||
|
||||
|
|
|
@ -42,23 +42,20 @@ import google.registry.testing.FakeResponse;
|
|||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import java.io.FileNotFoundException;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Unit tests for {@link ExportDomainListsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainListsAction> {
|
||||
class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainListsAction> {
|
||||
|
||||
private GcsService gcsService;
|
||||
private DriveConnection driveConnection = mock(DriveConnection.class);
|
||||
private ArgumentCaptor<byte[]> bytesExportedToDrive = ArgumentCaptor.forClass(byte[].class);
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("tld");
|
||||
createTld("testtld");
|
||||
persistResource(Registry.get("tld").asBuilder().setDriveFolderId("brouhaha").build());
|
||||
|
@ -90,7 +87,7 @@ public class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainL
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_writesLinkToMapreduceConsoleToResponse() throws Exception {
|
||||
void test_writesLinkToMapreduceConsoleToResponse() throws Exception {
|
||||
runMapreduce();
|
||||
assertThat(response.getPayload())
|
||||
.startsWith(
|
||||
|
@ -99,7 +96,7 @@ public class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainL
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_outputsOnlyActiveDomains() throws Exception {
|
||||
void test_outputsOnlyActiveDomains() throws Exception {
|
||||
persistActiveDomain("onetwo.tld");
|
||||
persistActiveDomain("rudnitzky.tld");
|
||||
persistDeletedDomain("mortuary.tld", DateTime.parse("2001-03-14T10:11:12Z"));
|
||||
|
@ -113,7 +110,7 @@ public class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainL
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_outputsOnlyDomainsOnRealTlds() throws Exception {
|
||||
void test_outputsOnlyDomainsOnRealTlds() throws Exception {
|
||||
persistActiveDomain("onetwo.tld");
|
||||
persistActiveDomain("rudnitzky.tld");
|
||||
persistActiveDomain("wontgo.testtld");
|
||||
|
@ -134,7 +131,7 @@ public class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainL
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_outputsDomainsFromDifferentTldsToMultipleFiles() throws Exception {
|
||||
void test_outputsDomainsFromDifferentTldsToMultipleFiles() throws Exception {
|
||||
createTld("tldtwo");
|
||||
persistResource(Registry.get("tldtwo").asBuilder().setDriveFolderId("hooray").build());
|
||||
|
||||
|
|
|
@ -43,14 +43,12 @@ import google.registry.request.Response;
|
|||
import google.registry.storage.drive.DriveConnection;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import java.io.IOException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
/** Unit tests for {@link ExportPremiumTermsAction}. */
|
||||
public class ExportPremiumTermsActionTest {
|
||||
|
||||
private static final String DISCLAIMER_WITH_NEWLINE = "# Premium Terms Export Disclaimer\n";
|
||||
|
@ -59,7 +57,7 @@ public class ExportPremiumTermsActionTest {
|
|||
private static final String EXPECTED_FILE_CONTENT =
|
||||
DISCLAIMER_WITH_NEWLINE + "0,USD 549.00\n" + "2048,USD 549.00\n";
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
private final DriveConnection driveConnection = mock(DriveConnection.class);
|
||||
|
@ -74,8 +72,8 @@ public class ExportPremiumTermsActionTest {
|
|||
action.run();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
createTld("tld");
|
||||
PremiumList pl = new PremiumList.Builder().setName("pl-name").build();
|
||||
savePremiumListAndEntries(pl, PREMIUM_NAMES);
|
||||
|
@ -90,7 +88,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_exportPremiumTerms_success() throws IOException {
|
||||
void test_exportPremiumTerms_success() throws IOException {
|
||||
runAction("tld");
|
||||
|
||||
verify(driveConnection)
|
||||
|
@ -108,7 +106,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_exportPremiumTerms_success_emptyPremiumList() throws IOException {
|
||||
void test_exportPremiumTerms_success_emptyPremiumList() throws IOException {
|
||||
PremiumList pl = new PremiumList.Builder().setName("pl-name").build();
|
||||
savePremiumListAndEntries(pl, ImmutableList.of());
|
||||
runAction("tld");
|
||||
|
@ -128,7 +126,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_exportPremiumTerms_doNothing_listNotConfigured() {
|
||||
void test_exportPremiumTerms_doNothing_listNotConfigured() {
|
||||
persistResource(Registry.get("tld").asBuilder().setPremiumList(null).build());
|
||||
runAction("tld");
|
||||
|
||||
|
@ -140,7 +138,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testExportPremiumTerms_doNothing_driveIdNotConfiguredInTld() {
|
||||
void testExportPremiumTerms_doNothing_driveIdNotConfiguredInTld() {
|
||||
persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build());
|
||||
runAction("tld");
|
||||
|
||||
|
@ -153,7 +151,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_exportPremiumTerms_failure_noSuchTld() {
|
||||
void test_exportPremiumTerms_failure_noSuchTld() {
|
||||
deleteTld("tld");
|
||||
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
||||
|
||||
|
@ -165,7 +163,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_exportPremiumTerms_failure_noPremiumList() {
|
||||
void test_exportPremiumTerms_failure_noPremiumList() {
|
||||
deletePremiumList(new PremiumList.Builder().setName("pl-name").build());
|
||||
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
||||
|
||||
|
@ -177,7 +175,7 @@ public class ExportPremiumTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testExportPremiumTerms_failure_driveIdThrowsException() throws IOException {
|
||||
void testExportPremiumTerms_failure_driveIdThrowsException() throws IOException {
|
||||
persistResource(Registry.get("tld").asBuilder().setDriveFolderId("bad_folder_id").build());
|
||||
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
||||
|
||||
|
|
|
@ -38,17 +38,14 @@ import google.registry.request.Response;
|
|||
import google.registry.storage.drive.DriveConnection;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import java.io.IOException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ExportReservedTermsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExportReservedTermsActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
private final DriveConnection driveConnection = mock(DriveConnection.class);
|
||||
|
@ -63,8 +60,8 @@ public class ExportReservedTermsActionTest {
|
|||
action.run();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
ReservedList rl = persistReservedList(
|
||||
"tld-reserved",
|
||||
"lol,FULLY_BLOCKED",
|
||||
|
@ -81,7 +78,7 @@ public class ExportReservedTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_uploadFileToDrive_succeeds() throws Exception {
|
||||
void test_uploadFileToDrive_succeeds() throws Exception {
|
||||
runAction("tld");
|
||||
byte[] expected = "# This is a disclaimer.\ncat\nlol\n".getBytes(UTF_8);
|
||||
verify(driveConnection)
|
||||
|
@ -91,7 +88,7 @@ public class ExportReservedTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_uploadFileToDrive_doesNothingIfReservedListsNotConfigured() {
|
||||
void test_uploadFileToDrive_doesNothingIfReservedListsNotConfigured() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
|
@ -104,7 +101,7 @@ public class ExportReservedTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_uploadFileToDrive_doesNothingWhenDriveFolderIdIsNull() {
|
||||
void test_uploadFileToDrive_doesNothingWhenDriveFolderIdIsNull() {
|
||||
persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build());
|
||||
runAction("tld");
|
||||
verify(response).setStatus(SC_OK);
|
||||
|
@ -113,7 +110,7 @@ public class ExportReservedTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_uploadFileToDrive_failsWhenDriveCannotBeReached() throws Exception {
|
||||
void test_uploadFileToDrive_failsWhenDriveCannotBeReached() throws Exception {
|
||||
when(driveConnection.createOrUpdateFile(
|
||||
anyString(),
|
||||
any(MediaType.class),
|
||||
|
@ -125,7 +122,7 @@ public class ExportReservedTermsActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_uploadFileToDrive_failsWhenTldDoesntExist() {
|
||||
void test_uploadFileToDrive_failsWhenTldDoesntExist() {
|
||||
RuntimeException thrown = assertThrows(RuntimeException.class, () -> runAction("fakeTld"));
|
||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||
assertThat(thrown)
|
||||
|
|
|
@ -22,20 +22,17 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ExportUtils}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExportUtilsTest {
|
||||
class ExportUtilsTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Test
|
||||
public void test_exportReservedTerms() {
|
||||
void test_exportReservedTerms() {
|
||||
ReservedList rl1 = persistReservedList(
|
||||
"tld-reserved1",
|
||||
"lol,FULLY_BLOCKED",
|
||||
|
|
|
@ -45,10 +45,8 @@ import google.registry.testing.FakeSleeper;
|
|||
import google.registry.testing.InjectRule;
|
||||
import google.registry.util.Retrier;
|
||||
import java.io.IOException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SyncGroupMembersAction}.
|
||||
|
@ -56,14 +54,12 @@ import org.junit.runners.JUnit4;
|
|||
* <p>Note that this relies on the registrars NewRegistrar and TheRegistrar created by default in
|
||||
* {@link AppEngineRule}.
|
||||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class SyncGroupMembersActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
private final DirectoryGroupsConnection connection = mock(DirectoryGroupsConnection.class);
|
||||
private final Response response = mock(Response.class);
|
||||
|
@ -78,7 +74,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_getGroupEmailAddressForContactType_convertsToLowercase() {
|
||||
void test_getGroupEmailAddressForContactType_convertsToLowercase() {
|
||||
assertThat(getGroupEmailAddressForContactType(
|
||||
"SomeRegistrar",
|
||||
RegistrarContact.Type.ADMIN,
|
||||
|
@ -87,7 +83,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_getGroupEmailAddressForContactType_convertsNonAlphanumericChars() {
|
||||
void test_getGroupEmailAddressForContactType_convertsNonAlphanumericChars() {
|
||||
assertThat(getGroupEmailAddressForContactType(
|
||||
"Weird.ಠ_ಠRegistrar",
|
||||
MARKETING,
|
||||
|
@ -96,7 +92,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_noneModified() {
|
||||
void test_doPost_noneModified() {
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
|
||||
persistResource(
|
||||
|
@ -109,7 +105,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_syncsNewContact() throws Exception {
|
||||
void test_doPost_syncsNewContact() throws Exception {
|
||||
runAction();
|
||||
verify(connection).addMemberToGroup(
|
||||
"newregistrar-primary-contacts@domain-registry.example",
|
||||
|
@ -121,7 +117,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_removesOldContact() throws Exception {
|
||||
void test_doPost_removesOldContact() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
runAction();
|
||||
|
@ -132,7 +128,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_removesAllContactsFromGroup() throws Exception {
|
||||
void test_doPost_removesAllContactsFromGroup() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
ofy().deleteWithoutBackup()
|
||||
|
@ -148,7 +144,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_addsAndRemovesContacts_acrossMultipleRegistrars() throws Exception {
|
||||
void test_doPost_addsAndRemovesContacts_acrossMultipleRegistrars() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
when(connection.getMembersOfGroup("newregistrar-marketing-contacts@domain-registry.example"))
|
||||
|
@ -196,7 +192,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_gracefullyHandlesExceptionForSingleRegistrar() throws Exception {
|
||||
void test_doPost_gracefullyHandlesExceptionForSingleRegistrar() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of());
|
||||
when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example"))
|
||||
|
@ -215,7 +211,7 @@ public class SyncGroupMembersActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_doPost_retriesOnTransientException() throws Exception {
|
||||
void test_doPost_retriesOnTransientException() throws Exception {
|
||||
doThrow(IOException.class)
|
||||
.doNothing()
|
||||
.when(connection)
|
||||
|
|
|
@ -40,22 +40,18 @@ import google.registry.request.HttpException.InternalServerErrorException;
|
|||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import java.io.IOException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
/** Unit tests for {@link UpdateSnapshotViewAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class UpdateSnapshotViewActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
||||
|
||||
private final CheckedBigquery checkedBigquery = mock(CheckedBigquery.class);
|
||||
private final Bigquery bigquery = mock(Bigquery.class);
|
||||
private final Bigquery.Datasets bigqueryDatasets = mock(Bigquery.Datasets.class);
|
||||
|
@ -66,8 +62,8 @@ public class UpdateSnapshotViewActionTest {
|
|||
|
||||
private UpdateSnapshotViewAction action;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
when(checkedBigquery.ensureDataSetExists(anyString(), anyString())).thenReturn(bigquery);
|
||||
when(bigquery.datasets()).thenReturn(bigqueryDatasets);
|
||||
when(bigqueryDatasets.insert(anyString(), any(Dataset.class)))
|
||||
|
@ -86,7 +82,7 @@ public class UpdateSnapshotViewActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_createViewUpdateTask() {
|
||||
void testSuccess_createViewUpdateTask() {
|
||||
getQueue(QUEUE)
|
||||
.add(
|
||||
createViewUpdateTask(
|
||||
|
@ -103,7 +99,7 @@ public class UpdateSnapshotViewActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_doPost() throws Exception {
|
||||
void testSuccess_doPost() throws Exception {
|
||||
action.run();
|
||||
|
||||
InOrder factoryOrder = inOrder(checkedBigquery);
|
||||
|
@ -126,7 +122,7 @@ public class UpdateSnapshotViewActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_bigqueryConnectionThrowsError() throws Exception {
|
||||
void testFailure_bigqueryConnectionThrowsError() throws Exception {
|
||||
when(bigqueryTables.update(anyString(), anyString(), anyString(), any(Table.class)))
|
||||
.thenThrow(new IOException("I'm sorry Dave, I can't let you do that"));
|
||||
InternalServerErrorException thrown =
|
||||
|
|
|
@ -49,21 +49,17 @@ import google.registry.testing.AppEngineRule;
|
|||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Unit tests for {@link UploadDatastoreBackupAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class UploadDatastoreBackupActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
||||
|
||||
private final CheckedBigquery checkedBigquery = mock(CheckedBigquery.class);
|
||||
private final Bigquery bigquery = mock(Bigquery.class);
|
||||
private final Bigquery.Jobs bigqueryJobs = mock(Bigquery.Jobs.class);
|
||||
|
@ -74,8 +70,8 @@ public class UploadDatastoreBackupActionTest {
|
|||
private final BigqueryPollJobEnqueuer bigqueryPollEnqueuer = mock(BigqueryPollJobEnqueuer.class);
|
||||
private UploadDatastoreBackupAction action;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
when(checkedBigquery.ensureDataSetExists("Project-Id", BACKUP_DATASET)).thenReturn(bigquery);
|
||||
when(bigquery.jobs()).thenReturn(bigqueryJobs);
|
||||
when(bigqueryJobs.insert(eq("Project-Id"), any(Job.class))).thenReturn(bigqueryJobsInsert);
|
||||
|
@ -92,7 +88,7 @@ public class UploadDatastoreBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_enqueueLoadTask() {
|
||||
void testSuccess_enqueueLoadTask() {
|
||||
enqueueUploadBackupTask("id12345", "gs://bucket/path", ImmutableSet.of("one", "two", "three"));
|
||||
assertTasksEnqueued(
|
||||
QUEUE,
|
||||
|
@ -105,7 +101,7 @@ public class UploadDatastoreBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_doPost() throws Exception {
|
||||
void testSuccess_doPost() throws Exception {
|
||||
action.run();
|
||||
|
||||
// Verify that checkedBigquery was called in a way that would create the dataset if it didn't
|
||||
|
@ -187,7 +183,7 @@ public class UploadDatastoreBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_doPost_bigqueryThrowsException() throws Exception {
|
||||
void testFailure_doPost_bigqueryThrowsException() throws Exception {
|
||||
when(bigqueryJobsInsert.execute()).thenThrow(new IOException("The Internet has gone missing"));
|
||||
InternalServerErrorException thrown =
|
||||
assertThrows(InternalServerErrorException.class, action::run);
|
||||
|
@ -197,7 +193,7 @@ public class UploadDatastoreBackupActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testgetBackupInfoFileForKind() {
|
||||
void testgetBackupInfoFileForKind() {
|
||||
assertThat(
|
||||
getBackupInfoFileForKind(
|
||||
"gs://BucketName/2018-11-11T00:00:00_12345", "AllocationToken"))
|
||||
|
|
|
@ -29,25 +29,20 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link DatastoreAdmin}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class DatastoreAdminTest {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DatastoreAdminTest {
|
||||
|
||||
private static final String AUTH_HEADER_PREFIX = "Bearer ";
|
||||
private static final String ACCESS_TOKEN = "MyAccessToken";
|
||||
private static final ImmutableList<String> KINDS =
|
||||
ImmutableList.of("Registry", "Registrar", "DomainBase");
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
|
||||
private DatastoreAdmin datastoreAdmin;
|
||||
|
||||
private static HttpRequest simulateSendRequest(HttpRequest httpRequest) {
|
||||
|
@ -75,8 +70,8 @@ public class DatastoreAdminTest {
|
|||
return Optional.of(outputStream.toString(StandardCharsets.UTF_8.name()));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Date oneHourLater = new Date(System.currentTimeMillis() + 3_600_000);
|
||||
GoogleCredentials googleCredentials = GoogleCredentials
|
||||
.create(new AccessToken(ACCESS_TOKEN, oneHourLater));
|
||||
|
@ -92,7 +87,7 @@ public class DatastoreAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testExport() throws IOException {
|
||||
void testExport() throws IOException {
|
||||
DatastoreAdmin.Export export = datastoreAdmin.export("gs://mybucket/path", KINDS);
|
||||
HttpRequest httpRequest = export.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
|
@ -109,7 +104,7 @@ public class DatastoreAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetOperation() throws IOException {
|
||||
void testGetOperation() throws IOException {
|
||||
DatastoreAdmin.Get get =
|
||||
datastoreAdmin.get("projects/MyCloudProject/operations/ASAzNjMwOTEyNjUJ");
|
||||
HttpRequest httpRequest = get.buildHttpRequest();
|
||||
|
@ -124,7 +119,7 @@ public class DatastoreAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testListOperations_all() throws IOException {
|
||||
void testListOperations_all() throws IOException {
|
||||
DatastoreAdmin.ListOperations listOperations = datastoreAdmin.listAll();
|
||||
HttpRequest httpRequest = listOperations.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
|
@ -137,7 +132,7 @@ public class DatastoreAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testListOperations_filterByStartTime() throws IOException {
|
||||
void testListOperations_filterByStartTime() throws IOException {
|
||||
DatastoreAdmin.ListOperations listOperations =
|
||||
datastoreAdmin.list("metadata.common.startTime>\"2018-10-31T00:00:00.0Z\"");
|
||||
HttpRequest httpRequest = listOperations.buildHttpRequest();
|
||||
|
@ -153,7 +148,7 @@ public class DatastoreAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testListOperations_filterByState() throws IOException {
|
||||
void testListOperations_filterByState() throws IOException {
|
||||
// TODO(weiminyu): consider adding a method to DatastoreAdmin to support query by state.
|
||||
DatastoreAdmin.ListOperations listOperations =
|
||||
datastoreAdmin.list("metadata.common.state=PROCESSING");
|
||||
|
|
|
@ -22,23 +22,20 @@ import com.google.api.client.json.jackson2.JacksonFactory;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import java.io.IOException;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for the instantiation, marshalling and unmarshalling of {@link EntityFilter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EntityFilterTest {
|
||||
class EntityFilterTest {
|
||||
|
||||
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
|
||||
@Test
|
||||
public void testEntityFilter_create_nullKinds() {
|
||||
void testEntityFilter_create_nullKinds() {
|
||||
assertThrows(NullPointerException.class, () -> new EntityFilter(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityFilter_marshall() throws IOException {
|
||||
void testEntityFilter_marshall() throws IOException {
|
||||
EntityFilter entityFilter =
|
||||
new EntityFilter(ImmutableList.of("Registry", "Registrar", "DomainBase"));
|
||||
assertThat(JSON_FACTORY.toString(entityFilter))
|
||||
|
@ -46,7 +43,7 @@ public class EntityFilterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEntityFilter_unmarshall() throws IOException {
|
||||
void testEntityFilter_unmarshall() throws IOException {
|
||||
EntityFilter entityFilter = loadJson("entity_filter.json", EntityFilter.class);
|
||||
assertThat(entityFilter.getKinds())
|
||||
.containsExactly("Registry", "Registrar", "DomainBase")
|
||||
|
@ -54,13 +51,13 @@ public class EntityFilterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEntityFilter_unmarshall_noKinds() throws IOException {
|
||||
void testEntityFilter_unmarshall_noKinds() throws IOException {
|
||||
EntityFilter entityFilter = JSON_FACTORY.fromString("{}", EntityFilter.class);
|
||||
assertThat(entityFilter.getKinds()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityFilter_unmarshall_emptyKinds() throws IOException {
|
||||
void testEntityFilter_unmarshall_emptyKinds() throws IOException {
|
||||
EntityFilter entityFilter = JSON_FACTORY.fromString("{ \"kinds\" : [] }", EntityFilter.class);
|
||||
assertThat(entityFilter.getKinds()).isEmpty();
|
||||
}
|
||||
|
|
|
@ -27,17 +27,15 @@ import google.registry.testing.TestDataHelper;
|
|||
import java.io.IOException;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for unmarshalling {@link Operation} and its member types. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class OperationTest {
|
||||
class OperationTest {
|
||||
|
||||
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
|
||||
@Test
|
||||
public void testCommonMetadata_unmarshall() throws IOException {
|
||||
void testCommonMetadata_unmarshall() throws IOException {
|
||||
CommonMetadata commonMetadata = loadJson("common_metadata.json", CommonMetadata.class);
|
||||
assertThat(commonMetadata.getState()).isEqualTo("SUCCESSFUL");
|
||||
assertThat(commonMetadata.getOperationType()).isEqualTo("EXPORT_ENTITIES");
|
||||
|
@ -47,14 +45,14 @@ public class OperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProgress_unmarshall() throws IOException {
|
||||
void testProgress_unmarshall() throws IOException {
|
||||
Progress progress = loadJson("progress.json", Progress.class);
|
||||
assertThat(progress.getWorkCompleted()).isEqualTo(51797);
|
||||
assertThat(progress.getWorkEstimated()).isEqualTo(54513);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetadata_unmarshall() throws IOException {
|
||||
void testMetadata_unmarshall() throws IOException {
|
||||
Metadata metadata = loadJson("metadata.json", Metadata.class);
|
||||
assertThat(metadata.getCommonMetadata().getOperationType()).isEqualTo("EXPORT_ENTITIES");
|
||||
assertThat(metadata.getCommonMetadata().getState()).isEqualTo("SUCCESSFUL");
|
||||
|
@ -67,7 +65,7 @@ public class OperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperation_unmarshall() throws IOException {
|
||||
void testOperation_unmarshall() throws IOException {
|
||||
Operation operation = loadJson("operation.json", Operation.class);
|
||||
assertThat(operation.getName())
|
||||
.startsWith("projects/domain-registry-alpha/operations/ASAzNjMwOTEyNjUJ");
|
||||
|
@ -86,7 +84,7 @@ public class OperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationList_unmarshall() throws IOException {
|
||||
void testOperationList_unmarshall() throws IOException {
|
||||
Operation.OperationList operationList =
|
||||
loadJson("operation_list.json", Operation.OperationList.class);
|
||||
assertThat(operationList.toList()).hasSize(2);
|
||||
|
|
|
@ -33,14 +33,12 @@ import com.google.common.collect.ImmutableMap;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link SheetSynchronizer}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class SheetSynchronizerTest {
|
||||
class SheetSynchronizerTest {
|
||||
|
||||
private final SheetSynchronizer sheetSynchronizer = new SheetSynchronizer();
|
||||
private final Sheets sheetsService = mock(Sheets.class);
|
||||
private final Sheets.Spreadsheets spreadsheets = mock(Sheets.Spreadsheets.class);
|
||||
|
@ -56,8 +54,8 @@ public class SheetSynchronizerTest {
|
|||
private List<List<Object>> existingSheet;
|
||||
private ImmutableList<ImmutableMap<String, String>> data;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
sheetSynchronizer.sheetsService = sheetsService;
|
||||
when(sheetsService.spreadsheets()).thenReturn(spreadsheets);
|
||||
when(spreadsheets.values()).thenReturn(values);
|
||||
|
@ -88,7 +86,7 @@ public class SheetSynchronizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronize_dataAndSheetEmpty_doNothing() throws Exception {
|
||||
void testSynchronize_dataAndSheetEmpty_doNothing() throws Exception {
|
||||
existingSheet.add(createRow("a", "b"));
|
||||
sheetSynchronizer.synchronize("aSheetId", data);
|
||||
verifyNoInteractions(appendReq);
|
||||
|
@ -97,7 +95,7 @@ public class SheetSynchronizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronize_differentValues_updatesValues() throws Exception {
|
||||
void testSynchronize_differentValues_updatesValues() throws Exception {
|
||||
existingSheet.add(createRow("a", "b"));
|
||||
existingSheet.add(createRow("diffVal1l", "diffVal2"));
|
||||
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2"));
|
||||
|
@ -116,7 +114,7 @@ public class SheetSynchronizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronize_unknownFields_doesntUpdate() throws Exception {
|
||||
void testSynchronize_unknownFields_doesntUpdate() throws Exception {
|
||||
existingSheet.add(createRow("a", "c", "b"));
|
||||
existingSheet.add(createRow("diffVal1", "sameVal", "diffVal2"));
|
||||
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2", "d", "val3"));
|
||||
|
@ -135,7 +133,7 @@ public class SheetSynchronizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronize_notFullRow_getsPadded() throws Exception {
|
||||
void testSynchronize_notFullRow_getsPadded() throws Exception {
|
||||
existingSheet.add(createRow("a", "c", "b"));
|
||||
existingSheet.add(createRow("diffVal1", "diffVal2"));
|
||||
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "paddedVal", "d", "val3"));
|
||||
|
@ -154,12 +152,12 @@ public class SheetSynchronizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronize_moreData_appendsValues() throws Exception {
|
||||
void testSynchronize_moreData_appendsValues() throws Exception {
|
||||
existingSheet.add(createRow("a", "b"));
|
||||
existingSheet.add(createRow("diffVal1", "diffVal2"));
|
||||
data = ImmutableList.of(
|
||||
ImmutableMap.of("a", "val1", "b", "val2"),
|
||||
ImmutableMap.of("a", "val3", "b", "val4"));
|
||||
data =
|
||||
ImmutableList.of(
|
||||
ImmutableMap.of("a", "val1", "b", "val2"), ImmutableMap.of("a", "val3", "b", "val4"));
|
||||
sheetSynchronizer.synchronize("aSheetId", data);
|
||||
|
||||
verifyNoInteractions(clearReq);
|
||||
|
@ -168,8 +166,7 @@ public class SheetSynchronizerTest {
|
|||
List<List<Object>> updatedVals = newArrayList();
|
||||
updatedVals.add(createRow("val1", "val2"));
|
||||
expectedRequest.setData(
|
||||
newArrayList(
|
||||
new ValueRange().setRange("Registrars!A2").setValues(updatedVals)));
|
||||
newArrayList(new ValueRange().setRange("Registrars!A2").setValues(updatedVals)));
|
||||
expectedRequest.setValueInputOption("RAW");
|
||||
verify(values).batchUpdate("aSheetId", expectedRequest);
|
||||
|
||||
|
@ -180,7 +177,7 @@ public class SheetSynchronizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronize_lessData_clearsValues() throws Exception {
|
||||
void testSynchronize_lessData_clearsValues() throws Exception {
|
||||
existingSheet.add(createRow("a", "b"));
|
||||
existingSheet.add(createRow("val1", "val2"));
|
||||
existingSheet.add(createRow("diffVal3", "diffVal4"));
|
||||
|
|
|
@ -29,17 +29,14 @@ import google.registry.testing.FakeResponse;
|
|||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link SyncRegistrarsSheetAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class SyncRegistrarsSheetActionTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
|
@ -54,8 +51,8 @@ public class SyncRegistrarsSheetActionTest {
|
|||
action.run();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
action = new SyncRegistrarsSheetAction();
|
||||
action.response = response;
|
||||
action.syncRegistrarsSheet = syncRegistrarsSheet;
|
||||
|
@ -64,14 +61,14 @@ public class SyncRegistrarsSheetActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_withoutParamsOrSystemProperty_dropsTask() {
|
||||
void testPost_withoutParamsOrSystemProperty_dropsTask() {
|
||||
runAction(null, null);
|
||||
assertThat(response.getPayload()).startsWith("MISSINGNO");
|
||||
verifyNoInteractions(syncRegistrarsSheet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_withoutParams_runsSyncWithDefaultIdAndChecksIfModified() throws Exception {
|
||||
void testPost_withoutParams_runsSyncWithDefaultIdAndChecksIfModified() throws Exception {
|
||||
when(syncRegistrarsSheet.wereRegistrarsModified()).thenReturn(true);
|
||||
runAction("jazz", null);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
|
@ -83,7 +80,7 @@ public class SyncRegistrarsSheetActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_noModificationsToRegistrarEntities_doesNothing() {
|
||||
void testPost_noModificationsToRegistrarEntities_doesNothing() {
|
||||
when(syncRegistrarsSheet.wereRegistrarsModified()).thenReturn(false);
|
||||
runAction("NewRegistrar", null);
|
||||
assertThat(response.getPayload()).startsWith("NOTMODIFIED");
|
||||
|
@ -92,7 +89,7 @@ public class SyncRegistrarsSheetActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_overrideId_runsSyncWithCustomIdAndDoesNotCheckModified() throws Exception {
|
||||
void testPost_overrideId_runsSyncWithCustomIdAndDoesNotCheckModified() throws Exception {
|
||||
runAction(null, "foobar");
|
||||
assertThat(response.getPayload()).startsWith("OK");
|
||||
verify(syncRegistrarsSheet).run(eq("foobar"));
|
||||
|
@ -100,7 +97,7 @@ public class SyncRegistrarsSheetActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPost_failToAquireLock_servletDoesNothingAndReturns() {
|
||||
void testPost_failToAquireLock_servletDoesNothingAndReturns() {
|
||||
action.lockHandler = new FakeLockHandler(false);
|
||||
runAction(null, "foobar");
|
||||
assertThat(response.getPayload()).startsWith("LOCKED");
|
||||
|
|
|
@ -43,27 +43,23 @@ import google.registry.testing.DatastoreHelper;
|
|||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link SyncRegistrarsSheet}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SyncRegistrarsSheetTest {
|
||||
|
||||
@Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Captor private ArgumentCaptor<ImmutableList<ImmutableMap<String, String>>> rowsCaptor;
|
||||
@Mock private SheetSynchronizer sheetSynchronizer;
|
||||
|
@ -77,8 +73,8 @@ public class SyncRegistrarsSheetTest {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
createTld("example");
|
||||
// Remove Registrar entities created by AppEngineRule.
|
||||
|
@ -86,12 +82,12 @@ public class SyncRegistrarsSheetTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_wereRegistrarsModified_noRegistrars_returnsFalse() {
|
||||
void test_wereRegistrarsModified_noRegistrars_returnsFalse() {
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_wereRegistrarsModified_atDifferentCursorTimes() {
|
||||
void test_wereRegistrarsModified_atDifferentCursorTimes() {
|
||||
persistNewRegistrar("SomeRegistrar", "Some Registrar Inc.", Registrar.Type.REAL, 8L);
|
||||
persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.nowUtc().minusHours(1)));
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isTrue();
|
||||
|
@ -100,7 +96,7 @@ public class SyncRegistrarsSheetTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun() throws Exception {
|
||||
void testRun() throws Exception {
|
||||
DateTime beforeExecution = clock.nowUtc();
|
||||
persistResource(new Registrar.Builder()
|
||||
.setClientId("anotherregistrar")
|
||||
|
@ -329,7 +325,7 @@ public class SyncRegistrarsSheetTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_missingValues_stillWorks() throws Exception {
|
||||
void testRun_missingValues_stillWorks() throws Exception {
|
||||
persistNewRegistrar("SomeRegistrar", "Some Registrar", Registrar.Type.REAL, 8L);
|
||||
|
||||
newSyncRegistrarsSheet().run("foobar");
|
||||
|
|
|
@ -50,15 +50,11 @@ import java.util.Optional;
|
|||
import javax.annotation.Nullable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
@ -86,19 +82,16 @@ public abstract class MapreduceTestCase<T> {
|
|||
private final PipelineServlet pipelineServlet = new PipelineServlet();
|
||||
private LocalTaskQueue taskQueue;
|
||||
|
||||
@RegisterExtension @Rule
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withLocalModules().withTaskQueue().build();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
|
||||
private AppEngineServiceUtils appEngineServiceUtils;
|
||||
|
||||
@Mock ModulesService modulesService;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
public void beforeEachMapreduceTestCase() {
|
||||
taskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue();
|
||||
ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate();
|
||||
// Creating files is not allowed in some test execution environments, so don't.
|
||||
|
|
|
@ -45,18 +45,15 @@ import java.util.Map;
|
|||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests for {@link GenerateZoneFilesAction}.*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAction> {
|
||||
/** Tests for {@link GenerateZoneFilesAction}. */
|
||||
class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAction> {
|
||||
|
||||
private final GcsService gcsService = createGcsService();
|
||||
|
||||
@Test
|
||||
public void testGenerate() throws Exception {
|
||||
void testGenerate() throws Exception {
|
||||
DateTime now = DateTime.now(DateTimeZone.UTC).withTimeAtStartOfDay();
|
||||
createTlds("tld", "com");
|
||||
|
||||
|
|
|
@ -41,15 +41,12 @@ import google.registry.model.ofy.CommitLogMutation;
|
|||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests for {@link KillAllCommitLogsAction}.*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class KillAllCommitLogsActionTest extends MapreduceTestCase<KillAllCommitLogsAction> {
|
||||
/** Tests for {@link KillAllCommitLogsAction}. */
|
||||
class KillAllCommitLogsActionTest extends MapreduceTestCase<KillAllCommitLogsAction> {
|
||||
|
||||
static final ImmutableList<Class<? extends ImmutableObject>> AFFECTED_TYPES =
|
||||
private static final ImmutableList<Class<? extends ImmutableObject>> AFFECTED_TYPES =
|
||||
ImmutableList.of(
|
||||
CommitLogBucket.class,
|
||||
CommitLogCheckpoint.class,
|
||||
|
@ -66,7 +63,7 @@ public class KillAllCommitLogsActionTest extends MapreduceTestCase<KillAllCommit
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testKill() throws Exception {
|
||||
void testKill() throws Exception {
|
||||
int nextContactId = 5432;
|
||||
for (String tld : asList("tld1", "tld2")) {
|
||||
createTld(tld);
|
||||
|
|
|
@ -53,15 +53,12 @@ import google.registry.testing.mapreduce.MapreduceTestCase;
|
|||
import java.util.stream.Stream;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests for {@link KillAllEppResourcesAction}.*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class KillAllEppResourcesActionTest extends MapreduceTestCase<KillAllEppResourcesAction> {
|
||||
/** Tests for {@link KillAllEppResourcesAction}. */
|
||||
class KillAllEppResourcesActionTest extends MapreduceTestCase<KillAllEppResourcesAction> {
|
||||
|
||||
static final ImmutableSet<String> AFFECTED_KINDS =
|
||||
private static final ImmutableSet<String> AFFECTED_KINDS =
|
||||
Stream.of(
|
||||
EppResourceIndex.class,
|
||||
ForeignKeyContactIndex.class,
|
||||
|
@ -86,7 +83,7 @@ public class KillAllEppResourcesActionTest extends MapreduceTestCase<KillAllEppR
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testKill() throws Exception {
|
||||
void testKill() throws Exception {
|
||||
createTld("tld1");
|
||||
createTld("tld2");
|
||||
for (EppResource resource : asList(
|
||||
|
|
|
@ -35,26 +35,23 @@ import google.registry.tools.server.RefreshDnsForAllDomainsAction.RefreshDnsForA
|
|||
import java.util.Random;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Unit tests for {@link RefreshDnsForAllDomainsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RefreshDnsForAllDomainsActionTest
|
||||
extends MapreduceTestCase<RefreshDnsForAllDomainsAction> {
|
||||
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
private final DnsQueue dnsQueue = mock(DnsQueue.class);
|
||||
private DnsQueue origDnsQueue;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
origDnsQueue = RefreshDnsForAllDomainsActionMapper.setDnsQueueForTest(dnsQueue);
|
||||
|
||||
action = new RefreshDnsForAllDomainsAction();
|
||||
|
@ -67,8 +64,8 @@ public class RefreshDnsForAllDomainsActionTest
|
|||
createTld("bar");
|
||||
}
|
||||
|
||||
@After
|
||||
public void restoreDnsQueue() {
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
assertThat(RefreshDnsForAllDomainsActionMapper.setDnsQueueForTest(origDnsQueue))
|
||||
.isEqualTo(dnsQueue);
|
||||
}
|
||||
|
@ -79,7 +76,7 @@ public class RefreshDnsForAllDomainsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_runAction_successfullyEnqueuesDnsRefreshes() throws Exception {
|
||||
void test_runAction_successfullyEnqueuesDnsRefreshes() throws Exception {
|
||||
persistActiveDomain("foo.bar");
|
||||
persistActiveDomain("low.bar");
|
||||
action.tlds = ImmutableSet.of("bar");
|
||||
|
@ -89,7 +86,7 @@ public class RefreshDnsForAllDomainsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_runAction_smearsOutDnsRefreshes() throws Exception {
|
||||
void test_runAction_smearsOutDnsRefreshes() throws Exception {
|
||||
persistActiveDomain("foo.bar");
|
||||
persistActiveDomain("low.bar");
|
||||
action.tlds = ImmutableSet.of("bar");
|
||||
|
@ -102,7 +99,7 @@ public class RefreshDnsForAllDomainsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_runAction_doesntRefreshDeletedDomain() throws Exception {
|
||||
void test_runAction_doesntRefreshDeletedDomain() throws Exception {
|
||||
persistActiveDomain("foo.bar");
|
||||
persistDeletedDomain("deleted.bar", DateTime.now(UTC).minusYears(1));
|
||||
action.tlds = ImmutableSet.of("bar");
|
||||
|
@ -112,7 +109,7 @@ public class RefreshDnsForAllDomainsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_runAction_ignoresDomainsOnOtherTlds() throws Exception {
|
||||
void test_runAction_ignoresDomainsOnOtherTlds() throws Exception {
|
||||
createTld("baz");
|
||||
persistActiveDomain("foo.bar");
|
||||
persistActiveDomain("low.bar");
|
||||
|
@ -125,7 +122,7 @@ public class RefreshDnsForAllDomainsActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_smearMinutesMustBeSpecified() {
|
||||
void test_smearMinutesMustBeSpecified() {
|
||||
action.tlds = ImmutableSet.of("bar");
|
||||
action.smearMinutes = 0;
|
||||
IllegalArgumentException thrown =
|
||||
|
|
|
@ -28,21 +28,17 @@ import google.registry.model.domain.DomainBase;
|
|||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ResaveAllHistoryEntriesAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ResaveAllHistoryEntriesActionTest
|
||||
extends MapreduceTestCase<ResaveAllHistoryEntriesAction> {
|
||||
class ResaveAllHistoryEntriesActionTest extends MapreduceTestCase<ResaveAllHistoryEntriesAction> {
|
||||
|
||||
private static final DatastoreService datastoreService =
|
||||
DatastoreServiceFactory.getDatastoreService();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
action = new ResaveAllHistoryEntriesAction();
|
||||
action.mrRunner = makeDefaultRunner();
|
||||
action.response = new FakeResponse();
|
||||
|
@ -54,7 +50,7 @@ public class ResaveAllHistoryEntriesActionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_mapreduceSuccessfullyResavesEntity() throws Exception {
|
||||
void test_mapreduceSuccessfullyResavesEntity() throws Exception {
|
||||
createTld("tld");
|
||||
DomainBase domain = persistActiveDomain("test.tld");
|
||||
ContactResource contact = persistActiveContact("humanBeing");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue