HBaseIO { public static Write write() { return new Write(null , ""); } private  HBaseIO(); static Read read(); @Experimental(Kind.SPLITTABLE_DO_FN) static ReadAll readAll(); static Write write();  }
@Test public void testWriteBuildsCorrectly() { HBaseIO.Write write = HBaseIO.write().withConfiguration(conf).withTableId("table"); assertEquals("table", write.getTableId()); assertNotNull("configuration", write.getConfiguration()); }
@Test public void testWriteBuildsCorrectlyInDifferentOrder() { HBaseIO.Write write = HBaseIO.write().withTableId("table").withConfiguration(conf); assertEquals("table", write.getTableId()); assertNotNull("configuration", write.getConfiguration()); }
@Test public void testWriteValidationFailsMissingTable() { HBaseIO.Write write = HBaseIO.write().withConfiguration(conf); thrown.expect(IllegalArgumentException.class); write.expand(null ); }
@Test public void testWriteValidationFailsMissingConfiguration() { HBaseIO.Write write = HBaseIO.write().withTableId("table"); thrown.expect(IllegalArgumentException.class); write.expand(null ); }
@Test public void testWriting() throws Exception { final String table = tmpTable.getName(); final String key = "key"; final String value = "value"; final int numMutations = 100; createTable(table); p.apply("multiple rows", Create.of(makeMutations(key, value, numMutations))) .apply("write", HBaseIO.write().withConfiguration(conf).withTableId(table)); p.run().waitUntilFinish(); List<Result> results = readTable(table, new Scan()); assertEquals(numMutations, results.size()); }
@Test public void testWritingFailsTableDoesNotExist() { final String table = tmpTable.getName(); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(String.format("Table %s does not exist", table)); p.apply(Create.empty(HBaseMutationCoder.of())) .apply("write", HBaseIO.write().withConfiguration(conf).withTableId(table)); }
@Test public void testWritingFailsBadElement() throws Exception { final String table = tmpTable.getName(); final String key = "KEY"; createTable(table); p.apply(Create.of(makeBadMutation(key))) .apply(HBaseIO.write().withConfiguration(conf).withTableId(table)); thrown.expect(Pipeline.PipelineExecutionException.class); thrown.expectCause(Matchers.instanceOf(IllegalArgumentException.class)); thrown.expectMessage("No columns to insert"); p.run().waitUntilFinish(); }
@Test public void testWritingDisplayData() { final String table = tmpTable.getName(); HBaseIO.Write write = HBaseIO.write().withTableId(table).withConfiguration(conf); DisplayData displayData = DisplayData.from(write); assertThat(displayData, hasDisplayItem("tableId", table)); }