@Override Tuple<WriteChannelConfiguration, String> parse(String... args) throws Exception { if (args.length == 4) { String dataset = args[0]; String table = args[1]; String format = args[2]; TableId tableId = TableId.of(dataset, table); WriteChannelConfiguration configuration = WriteChannelConfiguration.of(tableId, FormatOptions.of(format)); return Tuple.of(configuration, args[3]); } throw new IllegalArgumentException("Missing required arguments."); }
@Test public void testToBuilderIncomplete() { WriteChannelConfiguration configuration = WriteChannelConfiguration.of(TABLE_ID); compareLoadConfiguration(configuration, configuration.toBuilder().build()); }
@Test public void testOf() { WriteChannelConfiguration configuration = WriteChannelConfiguration.of(TABLE_ID); assertEquals(TABLE_ID, configuration.getDestinationTable()); configuration = WriteChannelConfiguration.of(TABLE_ID, CSV_OPTIONS); assertEquals(TABLE_ID, configuration.getDestinationTable()); assertEquals(FORMAT, configuration.getFormat()); assertEquals(CSV_OPTIONS, configuration.getCsvOptions()); }
@Test public void testSetProjectIdDoNotOverride() { WriteChannelConfiguration configuration = WriteChannelConfiguration.of(TABLE_ID).setProjectId("project"); configuration.setProjectId("different-project").toBuilder(); assertEquals("project", configuration.getDestinationTable().getProject()); }
@Test public void testToPbAndFromPb() { assertNull(LOAD_CONFIGURATION_CSV.toPb().getLoad().getSourceUris()); compareLoadConfiguration( LOAD_CONFIGURATION_CSV, WriteChannelConfiguration.fromPb(LOAD_CONFIGURATION_CSV.toPb())); WriteChannelConfiguration configuration = WriteChannelConfiguration.of(TABLE_ID); compareLoadConfiguration(configuration, WriteChannelConfiguration.fromPb(configuration.toPb())); }