Cut RegistryCursor over to global cursors

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=125797729
This commit is contained in:
ctingue 2016-06-24 11:12:46 -07:00 committed by Ben McIlwain
parent 6fa1c2d91c
commit 14522eac0c
18 changed files with 195 additions and 152 deletions

View file

@ -23,9 +23,9 @@ import static org.joda.time.Duration.standardSeconds;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
import google.registry.model.registry.RegistryCursor;
import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.model.server.Lock;
import google.registry.rde.EscrowTaskRunner.EscrowTask;
import google.registry.request.HttpException.NoContentException;
@ -77,13 +77,13 @@ public class EscrowTaskRunnerTest {
public void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource(
RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ")));
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
ofy().clearSessionCache();
assertThat(RegistryCursor.load(registry, CursorType.RDE_STAGING))
.hasValue(DateTime.parse("2006-06-07TZ"));
Cursor cursor = ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, registry)).now();
assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-06-07TZ"));
}
@Test
@ -92,15 +92,16 @@ public class EscrowTaskRunnerTest {
runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
assertThat(RegistryCursor.load(Registry.get("lol"), CursorType.RDE_STAGING))
.hasValue(DateTime.parse("2006-06-07TZ"));
Cursor cursor =
ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get("lol"))).now();
assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-06-07TZ"));
}
@Test
public void testRun_cursorInTheFuture_doesNothing() throws Exception {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource(
RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ")));
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry));
thrown.expect(NoContentException.class, "Already completed");
runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
@ -112,7 +113,7 @@ public class EscrowTaskRunnerTest {
thrown.expect(ServiceUnavailableException.class, "Lock in use: " + lockName);
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource(
RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ")));
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
Lock.executeWithLocks(
new Callable<Void>() {
@Override