use of com.google.cloud.teleport.spanner.ExportTransform.BuildTableManifests in project DataflowTemplates by GoogleCloudPlatform.
the class ExportTransformTest method buildTableManifests.
@Test
public void buildTableManifests() throws Exception {
Path f1 = Files.createTempFile("table1-file", "1");
Path f2 = Files.createTempFile("table1-file", "2");
Path f3 = Files.createTempFile("table2-file", "1");
// Create the expected manifest string.
TableManifest.Builder builder = TableManifest.newBuilder();
builder.addFilesBuilder().setName(f1.getFileName().toString()).setMd5("1B2M2Y8AsgTpgAmY7PhCfg==");
builder.addFilesBuilder().setName(f2.getFileName().toString()).setMd5("1B2M2Y8AsgTpgAmY7PhCfg==");
String manifest1 = JsonFormat.printer().print(builder.build());
builder = TableManifest.newBuilder();
builder.addFilesBuilder().setName(f3.getFileName().toString()).setMd5("1B2M2Y8AsgTpgAmY7PhCfg==");
String manifest2 = JsonFormat.printer().print(builder.build());
final Map<String, Iterable<String>> tablesAndFiles = ImmutableMap.of("table1", ImmutableList.of(f1.toString(), f2.toString()), "table2", ImmutableList.of(f3.toString()));
// Execute the transform.
PCollection<KV<String, String>> tableManifests = pipeline.apply("Create", Create.of(tablesAndFiles)).apply("Build table manifest", ParDo.of(new BuildTableManifests()));
PAssert.that(tableManifests).containsInAnyOrder(KV.of("table1", manifest1), KV.of("table2", manifest2));
pipeline.run();
}
Aggregations