mirror of
https://github.com/google/nomulus.git
synced 2025-07-19 17:26:09 +02:00
Add mapper to import domains from RDE deposits
With some additional cleanup by Ben McIlwain. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146695665
This commit is contained in:
parent
d6e6e8a49c
commit
a904f2c6ee
37 changed files with 2916 additions and 268 deletions
|
@ -24,9 +24,11 @@ import com.google.common.io.ByteSource;
|
|||
import com.google.common.io.ByteStreams;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.xjc.JaxbFragment;
|
||||
import google.registry.xjc.rdehost.XjcRdeHost;
|
||||
import google.registry.xjc.rdehost.XjcRdeHostElement;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -54,21 +56,16 @@ public class RdeHostReaderTest {
|
|||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withDatastore()
|
||||
.build();
|
||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||
|
||||
@Rule
|
||||
public final ExceptionRule thrown = new ExceptionRule();
|
||||
@Rule public final ExceptionRule thrown = new ExceptionRule();
|
||||
|
||||
/** Reads at least one result at 0 offset 1 maxResults */
|
||||
@Test
|
||||
public void testZeroOffsetOneResult_readsOne() throws Exception {
|
||||
pushToGcs(DEPOSIT_1_HOST);
|
||||
RdeHostReader reader = getReader(0, 1);
|
||||
HostResource host1 = reader.next();
|
||||
checkHost(host1, "ns1.example1.test", "Hns1_example1_test-TEST");
|
||||
checkHost(reader.next(), "ns1.example1.test", "Hns1_example1_test-TEST");
|
||||
}
|
||||
|
||||
/** Reads at most one at 0 offset 1 maxResults */
|
||||
|
@ -178,8 +175,8 @@ public class RdeHostReaderTest {
|
|||
|
||||
private void pushToGcs(ByteSource source) throws IOException {
|
||||
try (OutputStream outStream =
|
||||
new GcsUtils(GCS_SERVICE, ConfigModule.provideGcsBufferSize())
|
||||
.openOutputStream(new GcsFilename(IMPORT_BUCKET_NAME, IMPORT_FILE_NAME));
|
||||
new GcsUtils(GCS_SERVICE, ConfigModule.provideGcsBufferSize())
|
||||
.openOutputStream(new GcsFilename(IMPORT_BUCKET_NAME, IMPORT_FILE_NAME));
|
||||
InputStream inStream = source.openStream()) {
|
||||
ByteStreams.copy(inStream, outStream);
|
||||
}
|
||||
|
@ -198,12 +195,13 @@ public class RdeHostReaderTest {
|
|||
}
|
||||
|
||||
/** Verifies that domain name and ROID match expected values */
|
||||
private void checkHost(HostResource host, String domainName, String repoId) {
|
||||
assertThat(host).isNotNull();
|
||||
assertThat(host.getFullyQualifiedHostName()).isEqualTo(domainName);
|
||||
assertThat(host.getRepoId()).isEqualTo(repoId);
|
||||
private void checkHost(
|
||||
JaxbFragment<XjcRdeHostElement> fragment, String domainName, String repoId) {
|
||||
assertThat(fragment).isNotNull();
|
||||
XjcRdeHost host = fragment.getInstance().getValue();
|
||||
assertThat(host.getName()).isEqualTo(domainName);
|
||||
assertThat(host.getRoid()).isEqualTo(repoId);
|
||||
}
|
||||
|
||||
/** Gets a new {@link RdeHostReader} with specified offset and maxResults */
|
||||
private RdeHostReader getReader(int offset, int maxResults) throws Exception {
|
||||
RdeHostReader reader =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue