mirror of
https://github.com/google/nomulus.git
synced 2025-05-11 09:18:22 +02:00
62 lines
2.3 KiB
Java
62 lines
2.3 KiB
Java
package google.registry.export;
|
|
|
|
import static com.google.common.truth.Truth.assertThat;
|
|
import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_KINDS_TO_LOAD_PARAM;
|
|
import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_NAME_PARAM;
|
|
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
import com.google.common.base.Joiner;
|
|
import google.registry.testing.AppEngineRule;
|
|
import google.registry.testing.FakeClock;
|
|
import google.registry.testing.FakeResponse;
|
|
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.mockito.Mock;
|
|
import org.mockito.runners.MockitoJUnitRunner;
|
|
|
|
/** Unit tests for {@link ExportSnapshotAction}. */
|
|
@RunWith(MockitoJUnitRunner.class)
|
|
public class ExportSnapshotActionTest {
|
|
|
|
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
|
|
|
|
@Mock private DatastoreBackupService backupService;
|
|
|
|
private final FakeResponse response = new FakeResponse();
|
|
private final FakeClock clock = new FakeClock(DateTime.parse("2014-08-01T01:02:03Z"));
|
|
private final ExportSnapshotAction action = new ExportSnapshotAction();
|
|
|
|
@Before
|
|
public void before() throws Exception {
|
|
action.clock = clock;
|
|
action.backupService = backupService;
|
|
action.response = response;
|
|
}
|
|
|
|
@Test
|
|
public void testPost_launchesBackup_andEnqueuesPollTask() throws Exception {
|
|
action.run();
|
|
verify(backupService)
|
|
.launchNewBackup(
|
|
ExportSnapshotAction.QUEUE,
|
|
"auto_snapshot_20140801_010203",
|
|
"domain-registry-snapshots",
|
|
ExportConstants.getBackupKinds());
|
|
assertTasksEnqueued(
|
|
CheckSnapshotAction.QUEUE,
|
|
new TaskMatcher()
|
|
.url(CheckSnapshotAction.PATH)
|
|
.param(CHECK_SNAPSHOT_NAME_PARAM, "auto_snapshot_20140801_010203")
|
|
.param(
|
|
CHECK_SNAPSHOT_KINDS_TO_LOAD_PARAM,
|
|
Joiner.on(",").join(ExportConstants.getReportingKinds()))
|
|
.method("POST"));
|
|
assertThat(response.getPayload())
|
|
.isEqualTo("Datastore backup started with name: auto_snapshot_20140801_010203");
|
|
}
|
|
}
|