You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/05/19 15:35:37 UTC

[GitHub] [nifi] pgyori commented on a change in pull request #4272: NIFI-7336: Add tests for DeleteAzureDataLakeStorage

pgyori commented on a change in pull request #4272:
URL: https://github.com/apache/nifi/pull/4272#discussion_r427399115



##########
File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/azure/storage/ITDeleteAzureDataLakeStorage.java
##########
@@ -16,44 +16,388 @@
  */
 package org.apache.nifi.processors.azure.storage;
 
+import com.azure.storage.file.datalake.DataLakeDirectoryClient;
+import com.azure.storage.file.datalake.DataLakeFileClient;
+import com.azure.storage.file.datalake.models.DataLakeStorageException;
 import org.apache.nifi.processor.Processor;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.provenance.ProvenanceEventType;
 import org.apache.nifi.util.MockFlowFile;
-import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.List;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
-public class ITDeleteAzureDataLakeStorage extends AbstractAzureBlobStorageIT {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ITDeleteAzureDataLakeStorage extends AbstractAzureDataLakeStorageIT {
 
     @Override
     protected Class<? extends Processor> getProcessorClass() {
         return DeleteAzureDataLakeStorage.class;
     }
 
-    @Before
-    public void setUp() {
-        runner.setProperty(DeleteAzureDataLakeStorage.FILE, TEST_FILE_NAME);
+    @Test
+    public void testDeleteFileFromRoot() {
+        // GIVEN
+        String directory= "";
+        String filename = "testFile.txt";
+        String fileContent = "AzureFileContent";
+        String inputFlowFileContent = "InputFlowFileContent";
+
+        uploadFile(directory, filename, fileContent);
+
+        // WHEN
+        // THEN
+        testSuccessfulDelete(fileSystemName, directory, filename, inputFlowFileContent, inputFlowFileContent);
+    }
+
+    @Test
+    public void testDeleteFileFromDirectory() {
+        // GIVEN
+        String directory = "TestDirectory";
+        String filename = "testFile.txt";
+        String fileContent = "AzureFileContent";
+        String inputFlowFileContent = "InputFlowFileContent";
+
+        createDirectoryAndUploadFile(directory, filename, fileContent);
+
+        // WHEN
+        // THEN
+        testSuccessfulDelete(fileSystemName, directory, filename, inputFlowFileContent, inputFlowFileContent);
+    }
+
+    @Test
+    public void testDeleteFileFromDeepDirectory() {
+        // GIVEN
+        String directory= "Directory01/Directory02/Directory03/Directory04/Directory05/Directory06/Directory07/"
+                + "Directory08/Directory09/Directory10/Directory11/Directory12/Directory13/Directory14/Directory15/"
+                + "Directory16/Directory17/Directory18/Directory19/Directory20/TestDirectory";
+        String filename = "testFile.txt";
+        String fileContent = "AzureFileContent";
+        String inputFlowFileContent = "InputFlowFileContent";
+
+        createDirectoryAndUploadFile(directory, filename, fileContent);
+
+        // WHEN
+        // THEN
+        testSuccessfulDelete(fileSystemName, directory, filename, inputFlowFileContent, inputFlowFileContent);
+    }
+
+    @Test
+    public void testDeleteFileWithWhitespaceInFilename() {
+        // GIVEN
+        String directory= "TestDirectory";
+        String filename = "A test file.txt";
+        String fileContent = "AzureFileContent";
+        String inputFlowFileContent = "InputFlowFileContent";
+
+        createDirectoryAndUploadFile(directory, filename, fileContent);
+
+        // WHEN
+        // THEN
+        testSuccessfulDelete(fileSystemName, directory, filename, inputFlowFileContent, inputFlowFileContent);
+    }
+
+    @Test
+    public void testDeleteFileWithWhitespaceInDirectoryName() {
+        // GIVEN
+        String directory= "A Test Directory";
+        String filename = "testFile.txt";
+        String fileContent = "AzureFileContent";
+        String inputFlowFileContent = "InputFlowFileContent";
+
+        createDirectoryAndUploadFile(directory, filename, fileContent);
+
+        // WHEN
+        // THEN
+        testSuccessfulDelete(fileSystemName, directory, filename, inputFlowFileContent, inputFlowFileContent);
+    }
+
+    @Test
+    public void testDeleteEmptyDirectory() {
+        // GIVEN
+        String parentDirectory = "ParentDirectory";
+        String childDirectory = "ChildDirectory";
+        String inputFlowFileContent = "InputFlowFileContent";
+
+        fileSystemClient.createDirectory(parentDirectory + "/" + childDirectory);
+
+        // WHEN
+        // THEN
+        testSuccessfulDelete(fileSystemName, parentDirectory, childDirectory, inputFlowFileContent, inputFlowFileContent);
+    }
+
+    @Test
+    public void testDeleteFileCaseSensitiveFilename() {

Review comment:
       Thank you for the info! I rebased the branch, and fixed the failing test case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org