Source:
public void testDownloadfromContainer() { System.out.print("download"); CloudBlobContainer container; try{ CloudStorageAccount account = new CloudStorageAccount(new StorageCredentialsAccountAndKey(testEnv.azureStorageAccountName, testEnv.azureStorageAccountKey1)); CloudBlobClient blobClient = account.createCloudBlobClient(); String containerName = "testdownload"+TestEnvironment.GenerateRandomString(15); File directory = new File(containerName); directory.mkdir(); container = blobClient.getContainerReference(containerName); container.deleteIfExists(); container.createIfNotExists(); for(int i=0; i<testEnv.TOTAL_FILES;i++){ testEnv.downloadFileList.add(new File(directory, "download"+UUID.randomUUID().toString()+".txt")); FileUtils.writeStringToFile(testEnv.downloadFileList.get(i), TestEnvironment.GenerateRandomString(15)); LOGGER.log(Level.INFO, testEnv.downloadFileList.get(i).getAbsolutePath()); CloudBlockBlob blob = container.getBlockBlobReference(testEnv.downloadFileList.get(i).getName()); blob.uploadText(TestEnvironment.GenerateRandomString(20), "UTF-8", AccessCondition.generateEmptyCondition(), null, null); } Run mockRun = mock(Run.class); Launcher mockLauncher = mock(Launcher.class); WAStorageClient mockStorageClient = spy(WAStorageClient.class); FilePath workspace= new FilePath(mockLauncher.getChannel(), FilenameUtils.getFullPathNoEndSeparator(testEnv.downloadFileList.get(0).getAbsolutePath())); int totalFiles = mockStorageClient.download(mockRun, mockLauncher, TaskListener.NULL, testEnv.sampleStorageAccount, "*.txt", ",archive.zip", "", false, workspace, containerName); assertEquals(testEnv.downloadFileList.size(),totalFiles); container.deleteIfExists(); }catch(Exception e){ LOGGER.log(Level.SEVERE, null, e); Assert.assertTrue(e.getMessage(), false); } }

Target:
public void testDownloadfromContainer() { System.out.print("download without zip and flatten directory"); try { LOGGER.log(Level.INFO, "container Namne for testDownloadfromContainer: "+testEnv.containerName); Run mockRun = mock(Run.class); Launcher mockLauncher = mock(Launcher.class); WAStorageClient mockStorageClient = spy(WAStorageClient.class); File downloaded = new File(new File(".").getAbsolutePath(), TestEnvironment.GenerateRandomString(5)); downloaded.mkdir(); FilePath workspace= new FilePath(downloaded.getAbsoluteFile()); int totalFiles = mockStorageClient.download(mockRun, mockLauncher, TaskListener.NULL, testEnv.sampleStorageAccount, "*.txt", ",archive.zip", "", false, workspace, testEnv.containerName); assertEquals(testEnv.downloadFileList.size(),totalFiles); File[] listofFiles = downloaded.listFiles(); assertEquals(testEnv.downloadFileList.size(),listofFiles.length); for(File each: listofFiles){ assertEquals(true, each.isFile()); String tempContent = FileUtils.readFileToString(each, "utf-8"); File tempFile = testEnv.downloadFileList.get(tempContent); assertEquals(each.getName(), tempFile.getName()); assertEquals(FileUtils.readFileToString(tempFile, "utf-8"), tempContent); each.delete(); } testEnv.container.deleteIfExists(); FileUtils.deleteDirectory(downloaded); }catch(Exception e){ LOGGER.log(Level.SEVERE, null, e); Assert.assertTrue(e.getMessage(), false); } }