AzureBlobAvroWriter implements AzureBlobWriter { @Override public void flush() throws IOException { synchronized (currentDataFileWriterLock) { currentBlobWriterComponents.dataFileWriter.flush(); } } AzureBlobAvroWriter(BlobContainerAsyncClient containerAsyncClient, String blobURLPrefix,
      Executor blobThreadPool, AzureBlobWriterMetrics metrics,
      BlobMetadataGeneratorFactory blobMetadataGeneratorFactory, Config blobMetadataGeneratorConfig, String streamName,
      int maxBlockFlushThresholdSize, long flushTimeoutMs, Compression compression, boolean useRandomStringInBlobName,
      long maxBlobSize, long maxRecordsPerBlob); @VisibleForTesting  AzureBlobAvroWriter(BlobContainerAsyncClient containerAsyncClient, AzureBlobWriterMetrics metrics,
      Executor blobThreadPool, int maxBlockFlushThresholdSize, int flushTimeoutMs, String blobURLPrefix,
      DataFileWriter<IndexedRecord> dataFileWriter,
      AzureBlobOutputStream azureBlobOutputStream, BlockBlobAsyncClient blockBlobAsyncClient,
      BlobMetadataGeneratorFactory blobMetadataGeneratorFactory, Config blobMetadataGeneratorConfig, String streamName,
      long maxBlobSize, long maxRecordsPerBlob, Compression compression, boolean useRandomStringInBlobName); @Override void write(OutgoingMessageEnvelope ome); @Override void flush(); @Override void close();  }
@Test public void testFlush() throws Exception { azureBlobAvroWriter.flush(); verify(mockDataFileWriter).flush(); }
@Test(expected = IOException.class) public void testFlushWhenDataFileWriterFails() throws Exception { doThrow(new IOException("Failed")).when(mockDataFileWriter).flush(); azureBlobAvroWriter.flush(); }
@Test public void testMultipleThreadWriteFlush() throws Exception { Thread t1 = writeInThread(ome, azureBlobAvroWriter, 10); Thread t2 = flushInThread(azureBlobAvroWriter); t1.start(); t2.start(); t1.join(60000); t2.join(60000); verify(mockDataFileWriter, times(10)).appendEncoded(ByteBuffer.wrap(encodedRecord)); verify(mockAzureBlobOutputStream, times(10)).incrementNumberOfRecordsInBlob(); verify(mockDataFileWriter).flush(); }