@Test
public void testWrite() throws IOException
{

    Mapping mapping = configuration.getMappings().get(1);
    Dataset<Row> data;
    
    loader.setConfiguration(configuration);
    loader.loadSourceFiles(mapping);
    loader.setDf(loader.loadDf(getClass().getResourceAsStream("write.sql")));
    
    loader.write("testwrite");
    
    data = loader.getSparkSession().read().format("com.databricks.spark.csv").option("header", "true").option("inferSchema", "false").option("nullValue", "").option("treatEmptyValuesAsNulls","true").load(configuration.getFileSystem() + "://" + configuration.getSourceBucket() + "/stage/testwrite.csv" );
    
    assertEquals("Doctor A", data.first().get(0));
    assertEquals("1", data.first().get(1));
    assertEquals("ED", data.first().get(2));
    assertEquals("Patient 2", data.first().get(3));
    
    FileUtils.deleteDirectory(new File("/tmp/testwrite.csv"));
}