### Question:
AbstractHiveDataSetProvider implements DataSetProvider<T> { @Override public final void write(@Nonnull final KyloCatalogClient<T> client, @Nonnull final DataSetOptions options, @Nonnull final T dataSet) { final String tableName = DataSetUtil.getOptionOrThrow(options, KyloCatalogConstants.PATH_OPTION, "Table name must be defined as path"); addJars(client, options.getJars()); final DataFrameWriter writer = SparkUtil.prepareDataFrameWriter(getDataFrameWriter(dataSet, options), options, null); writer.insertInto(tableName); }  @Override final boolean supportsFormat(@Nonnull final String format); @Nonnull @Override final T read(@Nonnull final KyloCatalogClient<T> client, @Nonnull final DataSetOptions options); @Override final void write(@Nonnull final KyloCatalogClient<T> client, @Nonnull final DataSetOptions options, @Nonnull final T dataSet);  }### Answer:
@Test public void write() { writer = createDataFrameWriter(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) { final InsertIntoTable plan = invocation.getArgumentAt(0, InsertIntoTable.class); final UnresolvedRelation relation = (UnresolvedRelation) plan.table(); Assert.assertEquals("default", relation.tableIdentifier().database().get()); Assert.assertEquals("mytable", relation.tableIdentifier().table()); return null; } }); final DataSetOptions options = new DataSetOptions(); options.addJar("http: options.setOption(KyloCatalogConstants.PATH_OPTION, "default.mytable"); final MockHiveDataSetProvider provider = new MockHiveDataSetProvider(); provider.write(Mockito.mock(KyloCatalogClient.class), options, Mockito.mock(DataFrame.class)); Mockito.verify(sqlContext).sql("ADD JAR http: Mockito.verify(sqlContext).executePlan(Mockito.any(LogicalPlan.class)); }
@Test(expected = MissingOptionException.class) public void writeWithoutPath() { final MockHiveDataSetProvider provider = new MockHiveDataSetProvider(); provider.write(Mockito.mock(KyloCatalogClient.class), new DataSetOptions(), Mockito.mock(DataFrame.class)); }