This is an automated email from the ASF dual-hosted git repository.

tpalfy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 5f8c4851cc NIFI-14554 Added More Metadata Attributes to Google Drive 
Processors (part 3)
5f8c4851cc is described below

commit 5f8c4851cc7a9ca1701ef458e97eff3092ce37c7
Author: Peter Turcsanyi <[email protected]>
AuthorDate: Fri May 9 14:01:11 2025 +0200

    NIFI-14554 Added More Metadata Attributes to Google Drive Processors (part 
3)
    
    This closes #9952.
    
    Signed-off-by: Tamas Palfy <[email protected]>
---
 .../processors/gcp/drive/FetchGoogleDrive.java     |  52 +++++--
 .../gcp/drive/GoogleDriveAttributes.java           |   6 +
 .../processors/gcp/drive/GoogleDriveFileInfo.java  |  30 ++++
 .../processors/gcp/drive/GoogleDriveTrait.java     |  67 +++++++++
 .../nifi/processors/gcp/drive/ListGoogleDrive.java |  56 +++-----
 .../gcp/drive/AbstractGoogleDriveTest.java         |  23 +---
 .../processors/gcp/drive/FetchGoogleDriveTest.java | 153 ++++++++++++++++++---
 .../gcp/drive/ListGoogleDriveSimpleTest.java       |  26 +++-
 .../gcp/drive/ListGoogleDriveTestRunnerTest.java   |  21 ++-
 9 files changed, 352 insertions(+), 82 deletions(-)

diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
index 1039f692e4..58df4aed9a 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
@@ -70,11 +70,20 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID_DESC;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_ID;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MIME_TYPE_DESC;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME_DESC;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_ID;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_ID_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_NAME;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_NAME_DESC;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE_DESC;
@@ -105,6 +114,10 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_VIE
         @WritesAttribute(attribute = LAST_MODIFYING_USER, description = 
LAST_MODIFYING_USER_DESC),
         @WritesAttribute(attribute = WEB_VIEW_LINK, description = 
WEB_VIEW_LINK_DESC),
         @WritesAttribute(attribute = WEB_CONTENT_LINK, description = 
WEB_CONTENT_LINK_DESC),
+        @WritesAttribute(attribute = PARENT_FOLDER_ID, description = 
PARENT_FOLDER_ID_DESC),
+        @WritesAttribute(attribute = PARENT_FOLDER_NAME, description = 
PARENT_FOLDER_NAME_DESC),
+        @WritesAttribute(attribute = SHARED_DRIVE_ID, description = 
SHARED_DRIVE_ID_DESC),
+        @WritesAttribute(attribute = SHARED_DRIVE_NAME, description = 
SHARED_DRIVE_NAME_DESC),
         @WritesAttribute(attribute = ERROR_CODE, description = 
ERROR_CODE_DESC),
         @WritesAttribute(attribute = ERROR_MESSAGE, description = 
ERROR_MESSAGE_DESC)
 })
@@ -137,6 +150,9 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_VIE
 )
 public class FetchGoogleDrive extends AbstractProcessor implements 
GoogleDriveTrait {
 
+    static final String FILE_METADATA_FIELDS_BASIC = "id, name, createdTime, 
modifiedTime, mimeType, size, exportLinks";
+    static final String FILE_METADATA_FIELDS_EXTENDED = 
FILE_METADATA_FIELDS_BASIC + ", owners, lastModifyingUser, webViewLink, 
webContentLink, parents";
+
     private static final long EXPORT_SIZE_LIMIT = 10_000_000;
     private static final String EXPORT_SIZE_ERROR = "exportSizeLimitExceeded";
 
@@ -305,12 +321,30 @@ public class FetchGoogleDrive extends AbstractProcessor 
implements GoogleDriveTr
 
         final long startNanos = System.nanoTime();
         try {
-            final File fileMetadata = fetchFileMetadata(fileId);
-            final Map<String, String> attributeMap = 
createGoogleDriveFileInfoBuilder(fileMetadata)
-                    
.owner(Optional.ofNullable(fileMetadata.getOwners()).filter(owners -> 
!owners.isEmpty()).map(List::getFirst).map(User::getDisplayName).orElse(null))
-                    
.lastModifyingUser(Optional.ofNullable(fileMetadata.getLastModifyingUser()).map(User::getDisplayName).orElse(null))
-                    .webViewLink(fileMetadata.getWebViewLink())
-                    .webContentLink(fileMetadata.getWebContentLink())
+            final boolean listedFile = 
flowFile.getAttributes().containsKey(LISTED_FOLDER_ID);
+
+            final File fileMetadata = fetchFileMetadata(fileId, listedFile ? 
FILE_METADATA_FIELDS_BASIC : FILE_METADATA_FIELDS_EXTENDED);
+            final GoogleDriveFileInfo.Builder fileInfoBuilder = 
createGoogleDriveFileInfoBuilder(fileMetadata);
+
+            if (!listedFile) {
+                fileInfoBuilder
+                        
.owner(Optional.ofNullable(fileMetadata.getOwners()).filter(owners -> 
!owners.isEmpty()).map(List::getFirst).map(User::getDisplayName).orElse(null))
+                        
.lastModifyingUser(Optional.ofNullable(fileMetadata.getLastModifyingUser()).map(User::getDisplayName).orElse(null))
+                        .webViewLink(fileMetadata.getWebViewLink())
+                        .webContentLink(fileMetadata.getWebContentLink());
+
+                Optional.ofNullable(fileMetadata.getParents())
+                        .filter(parents -> !parents.isEmpty())
+                        .map(List::getFirst)
+                        .map(folderId -> getFolderDetails(driveService, 
folderId))
+                        .ifPresent(folderDetails -> fileInfoBuilder
+                                .parentFolderId(folderDetails.getFolderId())
+                                
.parentFolderName(folderDetails.getFolderName())
+                                
.sharedDriveId(folderDetails.getSharedDriveId())
+                                
.sharedDriveName(folderDetails.getSharedDriveName()));
+            }
+
+            final Map<String, String> attributeMap = fileInfoBuilder
                     .build()
                     .toAttributeMap();
 
@@ -374,7 +408,7 @@ public class FetchGoogleDrive extends AbstractProcessor 
implements GoogleDriveTr
 
         final String fileExtension = fileExtensions.get(exportMimeType);
         if (fileExtension != null) {
-            attributeMap.put(CoreAttributes.FILENAME.key(), 
flowFile.getAttribute(CoreAttributes.FILENAME.key()) + fileExtension);
+            attributeMap.put(CoreAttributes.FILENAME.key(), 
attributeMap.get(CoreAttributes.FILENAME.key()) + fileExtension);
         }
 
         if (fileMetadata.getSize() == null || fileMetadata.getSize() < 
EXPORT_SIZE_LIMIT) {
@@ -423,12 +457,12 @@ public class FetchGoogleDrive extends AbstractProcessor 
implements GoogleDriveTr
         return exportLink;
     }
 
-    private File fetchFileMetadata(final String fileId) throws IOException {
+    private File fetchFileMetadata(final String fileId, final String fields) 
throws IOException {
         return driveService
                 .files()
                 .get(fileId)
                 .setSupportsAllDrives(true)
-                .setFields("id, name, createdTime, modifiedTime, mimeType, 
size, exportLinks, owners, lastModifyingUser, webViewLink, webContentLink")
+                .setFields(fields)
                 .execute();
     }
 
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
index 740ab9e353..38cda7a46d 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
@@ -75,6 +75,12 @@ public class GoogleDriveAttributes {
     public static final String LISTED_FOLDER_NAME = "drive.listed.folder.name";
     public static final String LISTED_FOLDER_NAME_DESC = "The name of the base 
folder that was listed";
 
+    public static final String SHARED_DRIVE_ID = "drive.shared.drive.id";
+    public static final String SHARED_DRIVE_ID_DESC = "The id of the shared 
drive (if the file is located on a shared drive)";
+
+    public static final String SHARED_DRIVE_NAME = "drive.shared.drive.name";
+    public static final String SHARED_DRIVE_NAME_DESC = "The name of the 
shared drive (if the file is located on a shared drive)";
+
     public static final String ERROR_MESSAGE = "error.message";
     public static final String ERROR_MESSAGE_DESC = "The error message 
returned by Google Drive";
 
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
index 846ef07226..fa23966578 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
@@ -43,6 +43,8 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_ID;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_NAME;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.TIMESTAMP;
@@ -72,6 +74,8 @@ public class GoogleDriveFileInfo implements ListableEntity {
         recordFields.add(new RecordField(PARENT_FOLDER_NAME, 
RecordFieldType.STRING.getDataType(), true));
         recordFields.add(new RecordField(LISTED_FOLDER_ID, 
RecordFieldType.STRING.getDataType(), true));
         recordFields.add(new RecordField(LISTED_FOLDER_NAME, 
RecordFieldType.STRING.getDataType(), true));
+        recordFields.add(new RecordField(SHARED_DRIVE_ID, 
RecordFieldType.STRING.getDataType(), true));
+        recordFields.add(new RecordField(SHARED_DRIVE_NAME, 
RecordFieldType.STRING.getDataType(), true));
 
         SCHEMA = new SimpleRecordSchema(recordFields);
     }
@@ -94,6 +98,8 @@ public class GoogleDriveFileInfo implements ListableEntity {
     private final String parentFolderName;
     private final String listedFolderId;
     private final String listedFolderName;
+    private final String sharedDriveId;
+    private final String sharedDriveName;
 
     public String getId() {
         return id;
@@ -155,6 +161,14 @@ public class GoogleDriveFileInfo implements ListableEntity 
{
         return listedFolderName;
     }
 
+    public String getSharedDriveId() {
+        return sharedDriveId;
+    }
+
+    public String getSharedDriveName() {
+        return sharedDriveName;
+    }
+
     @Override
     public Record toRecord() {
         return new MapRecord(SCHEMA, toMap());
@@ -180,6 +194,8 @@ public class GoogleDriveFileInfo implements ListableEntity {
         values.put(PARENT_FOLDER_NAME, getParentFolderName());
         values.put(LISTED_FOLDER_ID, getListedFolderId());
         values.put(LISTED_FOLDER_NAME, getListedFolderName());
+        values.put(SHARED_DRIVE_ID, getSharedDriveId());
+        values.put(SHARED_DRIVE_NAME, getSharedDriveName());
 
         return values;
     }
@@ -214,6 +230,8 @@ public class GoogleDriveFileInfo implements ListableEntity {
         private String parentFolderName;
         private String listedFolderId;
         private String listedFolderName;
+        private String sharedDriveId;
+        private String sharedDriveName;
 
         public Builder id(String id) {
             this.id = id;
@@ -295,6 +313,16 @@ public class GoogleDriveFileInfo implements ListableEntity 
{
             return this;
         }
 
+        public Builder sharedDriveId(String sharedDriveId) {
+            this.sharedDriveId = sharedDriveId;
+            return this;
+        }
+
+        public Builder sharedDriveName(String sharedDriveName) {
+            this.sharedDriveName = sharedDriveName;
+            return this;
+        }
+
         public GoogleDriveFileInfo build() {
             return new GoogleDriveFileInfo(this);
         }
@@ -348,6 +376,8 @@ public class GoogleDriveFileInfo implements ListableEntity {
         this.parentFolderName = builder.parentFolderName;
         this.listedFolderId = builder.listedFolderId;
         this.listedFolderName = builder.listedFolderName;
+        this.sharedDriveId = builder.sharedDriveId;
+        this.sharedDriveName = builder.sharedDriveName;
     }
 
     @Override
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveTrait.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveTrait.java
index 02fa6a6bd1..d8f030feed 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveTrait.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveTrait.java
@@ -33,6 +33,7 @@ import org.apache.nifi.components.PropertyDescriptor;
 import org.apache.nifi.expression.ExpressionLanguageScope;
 import org.apache.nifi.gcp.credentials.service.GCPCredentialsService;
 import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.processor.util.StandardValidators;
 import org.apache.nifi.processors.gcp.util.GoogleUtils;
 
@@ -124,4 +125,70 @@ public interface GoogleDriveTrait {
                 
.modifiedTime(Optional.ofNullable(file.getModifiedTime()).map(DateTime::getValue).orElse(0L))
                 .mimeType(file.getMimeType());
     }
+
+    default FolderDetails getFolderDetails(final Drive driveService, final 
String folderId) {
+        try {
+            final File folder = driveService
+                    .files()
+                    .get(folderId)
+                    .setSupportsAllDrives(true)
+                    .setFields("name, driveId")
+                    .execute();
+
+            final String sharedDriveId = folder.getDriveId();
+            final String sharedDriveName;
+            if (sharedDriveId != null) {
+                sharedDriveName = driveService
+                        .drives()
+                        .get(sharedDriveId)
+                        .setFields("name")
+                        .execute()
+                        .getName();
+            } else {
+                sharedDriveName = null;
+            }
+
+            final String folderName;
+            if (folderId.equals(sharedDriveId)) {
+                // if folderId points to a Shared Drive root, files() returns 
"Drive" for the name and the result of drives() contains the real name
+                folderName = sharedDriveName;
+            } else {
+                folderName = folder.getName();
+            }
+
+            return new FolderDetails(folderId, folderName, sharedDriveId, 
sharedDriveName);
+        } catch (IOException ioe) {
+            throw new ProcessException("Error while retrieving folder 
metadata", ioe);
+        }
+    }
+
+    class FolderDetails {
+        private final String folderId;
+        private final String folderName;
+        private final String sharedDriveId;
+        private final String sharedDriveName;
+
+        FolderDetails(String folderId, String folderName, String 
sharedDriveId, String sharedDriveName) {
+            this.folderId = folderId;
+            this.folderName = folderName;
+            this.sharedDriveId = sharedDriveId;
+            this.sharedDriveName = sharedDriveName;
+        }
+
+        public String getFolderId() {
+            return folderId;
+        }
+
+        public String getFolderName() {
+            return folderName;
+        }
+
+        public String getSharedDriveId() {
+            return sharedDriveId;
+        }
+
+        public String getSharedDriveName() {
+            return sharedDriveName;
+        }
+    }
 }
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
index fb6563fde3..2a0df50f8d 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
@@ -72,7 +72,9 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID_DESC
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER_DESC;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_ID;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_ID_DESC;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_NAME;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_NAME_DESC;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MIME_TYPE_DESC;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME_DESC;
@@ -84,6 +86,10 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME_DESC;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_ID;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_ID_DESC;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_NAME;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_NAME_DESC;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE_DESC;
@@ -122,8 +128,10 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_VIE
         @WritesAttribute(attribute = WEB_CONTENT_LINK, description = 
WEB_CONTENT_LINK_DESC),
         @WritesAttribute(attribute = PARENT_FOLDER_ID, description = 
PARENT_FOLDER_ID_DESC),
         @WritesAttribute(attribute = PARENT_FOLDER_NAME, description = 
PARENT_FOLDER_NAME_DESC),
-        @WritesAttribute(attribute = LISTED_FOLDER_ID, description = 
WEB_CONTENT_LINK_DESC),
-        @WritesAttribute(attribute = LISTED_FOLDER_NAME, description = 
WEB_CONTENT_LINK_DESC)})
+        @WritesAttribute(attribute = LISTED_FOLDER_ID, description = 
LISTED_FOLDER_ID_DESC),
+        @WritesAttribute(attribute = LISTED_FOLDER_NAME, description = 
LISTED_FOLDER_NAME_DESC),
+        @WritesAttribute(attribute = SHARED_DRIVE_ID, description = 
SHARED_DRIVE_ID_DESC),
+        @WritesAttribute(attribute = SHARED_DRIVE_NAME, description = 
SHARED_DRIVE_NAME_DESC)})
 @Stateful(scopes = {Scope.CLUSTER}, description = "The processor stores 
necessary data to be able to keep track what files have been listed already." +
         " What exactly needs to be stored depends on the 'Listing Strategy'." +
         " State is stored across the cluster so that this Processor can be run 
on Primary Node only and if a new Primary Node is selected, the new node can 
pick up" +
@@ -199,9 +207,6 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
 
     private volatile Drive driveService;
 
-    private volatile String listedFolderId;
-    private volatile String listedFolderName;
-
     @Override
     protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
         return PROPERTY_DESCRIPTORS;
@@ -220,15 +225,12 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
     }
 
     @OnScheduled
-    public void onScheduled(final ProcessContext context) throws IOException {
+    public void onScheduled(final ProcessContext context) {
         final ProxyConfiguration proxyConfiguration = 
ProxyConfiguration.getConfiguration(context);
 
         HttpTransport httpTransport = new 
ProxyAwareTransportFactory(proxyConfiguration).create();
 
         driveService = createDriveService(context, httpTransport, 
DriveScopes.DRIVE, DriveScopes.DRIVE_METADATA_READONLY);
-
-        listedFolderId = 
context.getProperty(FOLDER_ID).evaluateAttributeExpressions().getValue();
-        listedFolderName = getFolderName(listedFolderId);
     }
 
     @Override
@@ -271,6 +273,7 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
     ) throws IOException {
         final List<GoogleDriveFileInfo> listing = new ArrayList<>();
 
+        final String folderId = 
context.getProperty(FOLDER_ID).evaluateAttributeExpressions().getValue();
         final Boolean recursive = 
context.getProperty(RECURSIVE_SEARCH).asBoolean();
         final Long minAge = 
context.getProperty(MIN_AGE).asTimePeriod(TimeUnit.MILLISECONDS);
 
@@ -298,9 +301,10 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
 
         final String queryTemplate = queryTemplateBuilder.toString();
 
-        final String listedFolderPath = urlEncode(listedFolderName);
+        final FolderDetails folderDetails = getFolderDetails(driveService, 
folderId);
+        final String folderPath = urlEncode(folderDetails.getFolderName());
 
-        queryFolder(listedFolderId, listedFolderName, listedFolderPath, 
queryTemplate, recursive, listing);
+        queryFolder(folderDetails.getFolderId(), 
folderDetails.getFolderName(), folderPath, queryTemplate, recursive, 
folderDetails, listing);
 
         return listing;
     }
@@ -310,33 +314,13 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
         return performListing(context, null, 
ListingMode.CONFIGURATION_VERIFICATION).size();
     }
 
-    private String getFolderName(final String folderId) throws IOException {
-        final File folder = driveService
-                .files()
-                .get(folderId)
-                .setSupportsAllDrives(true)
-                .setFields("name, driveId")
-                .execute();
-
-        if (folderId.equals(folder.getDriveId())) {
-            // if folderId points to a Shared Drive root, files() returns 
"Drive" for the name and drives() needs to be used to get the real name
-            return driveService
-                    .drives()
-                    .get(folderId)
-                    .setFields("name")
-                    .execute()
-                    .getName();
-        } else {
-            return folder.getName();
-        }
-    }
-
     private void queryFolder(
             final String folderId,
             final String folderName,
             final String folderPath,
             final String queryTemplate,
             final boolean recursive,
+            final FolderDetails listedFolderDetails,
             final List<GoogleDriveFileInfo> listing
     ) throws IOException {
         final List<File> subfolders = new ArrayList<>();
@@ -366,8 +350,10 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
                             .webContentLink(file.getWebContentLink())
                             .parentFolderId(folderId)
                             .parentFolderName(folderName)
-                            .listedFolderId(listedFolderId)
-                            .listedFolderName(listedFolderName);
+                            .listedFolderId(listedFolderDetails.getFolderId())
+                            
.listedFolderName(listedFolderDetails.getFolderName())
+                            
.sharedDriveId(listedFolderDetails.getSharedDriveId())
+                            
.sharedDriveName(listedFolderDetails.getSharedDriveName());
 
                     listing.add(builder.build());
                 }
@@ -378,7 +364,7 @@ public class ListGoogleDrive extends 
AbstractListProcessor<GoogleDriveFileInfo>
 
         for (final File subfolder : subfolders) {
             final String subfolderPath = folderPath + "/" + 
urlEncode(subfolder.getName());
-            queryFolder(subfolder.getId(), subfolder.getName(), subfolderPath, 
queryTemplate, true, listing);
+            queryFolder(subfolder.getId(), subfolder.getName(), subfolderPath, 
queryTemplate, true, listedFolderDetails, listing);
         }
     }
 
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/AbstractGoogleDriveTest.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/AbstractGoogleDriveTest.java
index 4c4cecdc50..d0e484f1da 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/AbstractGoogleDriveTest.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/AbstractGoogleDriveTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.nifi.processors.gcp.drive;
 
-import static java.util.Collections.singletonList;
 import static java.util.stream.Collectors.toSet;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -47,9 +46,7 @@ public class AbstractGoogleDriveTest {
     public static final String CONTENT = "1234567890";
     public static final String TEST_FILENAME = "testFile";
     public static final String TEST_FILE_ID = "fileId";
-    public static final String SUBFOLDER_NAME = "subFolderName";
     public static final String SHARED_FOLDER_ID = "sharedFolderId";
-    public static final String SUBFOLDER_ID = "subFolderId";
     public static final long TEST_SIZE = 42;
     public static final long CREATED_TIME = 1659707000;
     public static final long MODIFIED_TIME = 1659708000;
@@ -98,18 +95,12 @@ public class AbstractGoogleDriveTest {
     }
 
     protected File createFile() {
-        return createFile(TEST_FILE_ID, TEST_FILENAME, SUBFOLDER_ID, 
TEXT_TYPE);
-    }
-
-    protected File createFile(String id, String name, String parentId, String 
mimeType) {
-        File file = new File();
-        file.setId(id);
-        file.setName(name);
-        file.setParents(singletonList(parentId));
-        file.setCreatedTime(new DateTime(CREATED_TIME));
-        file.setModifiedTime(new DateTime(MODIFIED_TIME));
-        file.setSize(TEST_SIZE);
-        file.setMimeType(mimeType);
-        return file;
+        return new File()
+                .setId(TEST_FILE_ID)
+                .setName(TEST_FILENAME)
+                .setCreatedTime(new DateTime(CREATED_TIME))
+                .setModifiedTime(new DateTime(MODIFIED_TIME))
+                .setSize(TEST_SIZE)
+                .setMimeType(TEXT_TYPE);
     }
 }
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
index a41d102166..5f0ebd2ffc 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
@@ -17,6 +17,8 @@
 package org.apache.nifi.processors.gcp.drive;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import com.google.api.client.http.HttpTransport;
@@ -26,6 +28,10 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
+import com.google.api.services.drive.model.File;
+import com.google.api.services.drive.model.User;
+import org.apache.nifi.flowfile.FlowFile;
 import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.provenance.ProvenanceEventType;
 import org.apache.nifi.util.MockFlowFile;
@@ -33,11 +39,23 @@ import org.apache.nifi.util.TestRunners;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.NullSource;
+import org.junit.jupiter.params.provider.ValueSource;
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
 public class FetchGoogleDriveTest extends AbstractGoogleDriveTest {
 
+    private static final String TEST_OWNER = "user1";
+    private static final String TEST_LAST_MODIFYING_USER = "user2";
+    private static final String TEST_WEB_VIEW_LINK = "http://web.view";;
+    private static final String TEST_WEB_CONTENT_LINK = "http://web.content";;
+    private static final String TEST_PARENT_FOLDER_ID = "folder-id";
+    private static final String TEST_PARENT_FOLDER_NAME = "folder-name";
+    private static final String TEST_SHARED_DRIVE_ID = "drive-id";
+    private static final String TEST_SHARED_DRIVE_NAME = "drive-name";
+
     @BeforeEach
     protected void setUp() throws Exception {
         final FetchGoogleDrive testSubject = new FetchGoogleDrive() {
@@ -52,10 +70,12 @@ public class FetchGoogleDriveTest extends 
AbstractGoogleDriveTest {
     }
 
     @Test
-    void testFileFetchFileNameFromProperty() throws IOException {
+    void testFileFetchFileIdFromProperty() throws IOException {
         testRunner.setProperty(FetchGoogleDrive.FILE_ID, TEST_FILE_ID);
 
-        mockFileDownload(TEST_FILE_ID);
+        mockGetFileMetaDataExtended(TEST_FILE_ID);
+        mockFileDownloadSuccess(TEST_FILE_ID);
+
         runWithFlowFile();
 
         testRunner.assertAllFlowFilesTransferred(FetchGoogleDrive.REL_SUCCESS, 
1);
@@ -64,26 +84,88 @@ public class FetchGoogleDriveTest extends 
AbstractGoogleDriveTest {
     }
 
     @Test
-    void testFetchFileNameFromFlowFileAttribute() throws Exception {
+    void testFetchFileIdFromFlowFileAttribute() throws Exception {
         final MockFlowFile mockFlowFile = new MockFlowFile(0);
         final Map<String, String> attributes = new HashMap<>();
         attributes.put(GoogleDriveAttributes.ID, TEST_FILE_ID);
         mockFlowFile.putAttributes(attributes);
 
-        mockFileDownload(TEST_FILE_ID);
+        mockGetFileMetaDataExtended(TEST_FILE_ID);
+        mockFileDownloadSuccess(TEST_FILE_ID);
 
-        testRunner.enqueue(mockFlowFile);
-        testRunner.run();
+        runWithFlowFile(mockFlowFile);
 
         testRunner.assertAllFlowFilesTransferred(FetchGoogleDrive.REL_SUCCESS, 
1);
         assertFlowFileAttributes(FetchGoogleDrive.REL_SUCCESS);
         assertProvenanceEvent(ProvenanceEventType.FETCH);
     }
 
+    @ParameterizedTest
+    @NullSource
+    @ValueSource(strings = {TEST_SHARED_DRIVE_ID})
+    void testFileFetchByListResult(String driveId) throws IOException {
+        final MockFlowFile mockFlowFile = new MockFlowFile(0);
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put(GoogleDriveAttributes.ID, TEST_FILE_ID);
+        attributes.put(GoogleDriveAttributes.LISTED_FOLDER_ID, 
TEST_PARENT_FOLDER_ID);
+        attributes.put(GoogleDriveAttributes.OWNER, TEST_OWNER);
+        attributes.put(GoogleDriveAttributes.LAST_MODIFYING_USER, 
TEST_LAST_MODIFYING_USER);
+        attributes.put(GoogleDriveAttributes.WEB_VIEW_LINK, 
TEST_WEB_VIEW_LINK);
+        attributes.put(GoogleDriveAttributes.WEB_CONTENT_LINK, 
TEST_WEB_CONTENT_LINK);
+        attributes.put(GoogleDriveAttributes.PARENT_FOLDER_ID, 
TEST_PARENT_FOLDER_ID);
+        attributes.put(GoogleDriveAttributes.PARENT_FOLDER_NAME, 
TEST_PARENT_FOLDER_NAME);
+        attributes.put(GoogleDriveAttributes.SHARED_DRIVE_ID, driveId);
+        attributes.put(GoogleDriveAttributes.SHARED_DRIVE_NAME, driveId != 
null ? TEST_SHARED_DRIVE_NAME : null);
+        mockFlowFile.putAttributes(attributes);
+
+        mockGetFileMetaDataBasic(TEST_FILE_ID);
+        mockFileDownloadSuccess(TEST_FILE_ID);
+
+        runWithFlowFile(mockFlowFile);
+
+        assertFlowFile(driveId);
+        assertProvenanceEvent(ProvenanceEventType.FETCH);
+
+        verify(mockDriverService, never()).drives();
+    }
+
+    @ParameterizedTest
+    @NullSource
+    @ValueSource(strings = {TEST_SHARED_DRIVE_ID})
+    void testFileFetchByIdOnly(String driveId) throws IOException {
+        testRunner.setProperty(FetchGoogleDrive.FILE_ID, TEST_FILE_ID);
+
+        mockGetFileMetaDataExtended(TEST_FILE_ID, driveId);
+        mockFileDownloadSuccess(TEST_FILE_ID);
+
+        runWithFlowFile();
+
+        assertFlowFile(driveId);
+        assertProvenanceEvent(ProvenanceEventType.FETCH);
+    }
+
+    private void assertFlowFile(String driveId) {
+        testRunner.assertAllFlowFilesTransferred(FetchGoogleDrive.REL_SUCCESS, 
1);
+
+        assertFlowFileAttributes(FetchGoogleDrive.REL_SUCCESS);
+
+        final MockFlowFile flowFile = 
testRunner.getFlowFilesForRelationship(FetchGoogleDrive.REL_SUCCESS).getFirst();
+
+        flowFile.assertAttributeEquals(GoogleDriveAttributes.OWNER, 
TEST_OWNER);
+        
flowFile.assertAttributeEquals(GoogleDriveAttributes.LAST_MODIFYING_USER, 
TEST_LAST_MODIFYING_USER);
+        flowFile.assertAttributeEquals(GoogleDriveAttributes.WEB_VIEW_LINK, 
TEST_WEB_VIEW_LINK);
+        flowFile.assertAttributeEquals(GoogleDriveAttributes.WEB_CONTENT_LINK, 
TEST_WEB_CONTENT_LINK);
+        flowFile.assertAttributeEquals(GoogleDriveAttributes.PARENT_FOLDER_ID, 
TEST_PARENT_FOLDER_ID);
+        
flowFile.assertAttributeEquals(GoogleDriveAttributes.PARENT_FOLDER_NAME, 
TEST_PARENT_FOLDER_NAME);
+        flowFile.assertAttributeEquals(GoogleDriveAttributes.SHARED_DRIVE_ID, 
driveId);
+        
flowFile.assertAttributeEquals(GoogleDriveAttributes.SHARED_DRIVE_NAME, driveId 
!= null ? TEST_SHARED_DRIVE_NAME : null);
+    }
+
     @Test
     void testFileFetchError() throws Exception {
         testRunner.setProperty(FetchGoogleDrive.FILE_ID, TEST_FILE_ID);
 
+        mockGetFileMetaDataExtended(TEST_FILE_ID);
         mockFileDownloadError(TEST_FILE_ID, new RuntimeException("Error during 
download"));
 
         runWithFlowFile();
@@ -95,35 +177,74 @@ public class FetchGoogleDriveTest extends 
AbstractGoogleDriveTest {
         assertNoProvenanceEvent();
     }
 
-    private void mockFileDownload(String fileId) throws IOException {
+    private void mockFileDownloadSuccess(String fileId) throws IOException {
         when(mockDriverService.files()
                 .get(fileId)
                 .setSupportsAllDrives(true)
-                .executeMediaAsInputStream()).thenReturn(new 
ByteArrayInputStream(CONTENT.getBytes(UTF_8)));
+                .executeMediaAsInputStream())
+                .thenReturn(new ByteArrayInputStream(CONTENT.getBytes(UTF_8)));
+    }
 
+    private void mockFileDownloadError(String fileId, Exception exception) 
throws IOException {
         when(mockDriverService.files()
                 .get(fileId)
                 .setSupportsAllDrives(true)
-                .setFields("id, name, createdTime, modifiedTime, mimeType, 
size, exportLinks, owners, lastModifyingUser, webViewLink, webContentLink")
-                .execute()).thenReturn(createFile());
+                .executeMediaAsInputStream())
+                .thenThrow(exception);
     }
 
-    private void mockFileDownloadError(String fileId, Exception exception) 
throws IOException {
+    private void mockGetFileMetaDataBasic(String fileId) throws IOException {
         when(mockDriverService.files()
                 .get(fileId)
                 .setSupportsAllDrives(true)
-                .executeMediaAsInputStream())
-                .thenThrow(exception);
+                .setFields(FetchGoogleDrive.FILE_METADATA_FIELDS_BASIC)
+                .execute())
+                .thenReturn(createFile());
+    }
+
+    private void mockGetFileMetaDataExtended(String fileId) throws IOException 
{
+        mockGetFileMetaDataExtended(fileId, null);
+    }
 
+    private void mockGetFileMetaDataExtended(String fileId, String driveId) 
throws IOException {
         when(mockDriverService.files()
                 .get(fileId)
                 .setSupportsAllDrives(true)
-                .setFields("id, name, createdTime, modifiedTime, mimeType, 
size, exportLinks, owners, lastModifyingUser, webViewLink, webContentLink")
-                .execute()).thenReturn(createFile());
+                .setFields(FetchGoogleDrive.FILE_METADATA_FIELDS_EXTENDED)
+                .execute())
+                .thenReturn(createFile()
+                        .setOwners(List.of(new 
User().setDisplayName(TEST_OWNER)))
+                        .setLastModifyingUser(new 
User().setDisplayName(TEST_LAST_MODIFYING_USER))
+                        .setWebViewLink(TEST_WEB_VIEW_LINK)
+                        .setWebContentLink(TEST_WEB_CONTENT_LINK)
+                        .setParents(List.of(TEST_PARENT_FOLDER_ID)));
+
+        when(mockDriverService.files()
+                .get(TEST_PARENT_FOLDER_ID)
+                .setSupportsAllDrives(true)
+                .setFields("name, driveId")
+                .execute()
+        ).thenReturn(new File()
+                .setName(TEST_PARENT_FOLDER_NAME)
+                .setDriveId(driveId)
+        );
+
+        if (driveId != null) {
+            when(mockDriverService.drives()
+                    .get(driveId)
+                    .setFields("name")
+                    .execute()
+                    .getName()
+            ).thenReturn(TEST_SHARED_DRIVE_NAME);
+        }
     }
 
     private void runWithFlowFile() {
-        testRunner.enqueue(new MockFlowFile(0));
+        runWithFlowFile(new MockFlowFile(0));
+    }
+
+    private void runWithFlowFile(FlowFile flowFile) {
+        testRunner.enqueue(flowFile);
         testRunner.run();
     }
 }
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
index dae9e0425f..c16f9faddd 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
@@ -24,7 +24,9 @@ import com.google.api.services.drive.model.User;
 import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.util.EqualsWrapper;
 import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.NullSource;
+import org.junit.jupiter.params.provider.ValueSource;
 
 import java.io.IOException;
 import java.util.List;
@@ -65,8 +67,10 @@ public class ListGoogleDriveSimpleTest {
         };
     }
 
-    @Test
-    void testCreatedListableEntityContainsCorrectData() throws Exception {
+    @ParameterizedTest
+    @NullSource
+    @ValueSource(strings = {"drive_id"})
+    void testCreatedListableEntityContainsCorrectData(String driveId) throws 
Exception {
         // GIVEN
         Long minTimestamp = 0L;
         listingModeAsString = "EXECUTION";
@@ -74,6 +78,8 @@ public class ListGoogleDriveSimpleTest {
         String folderId = "folder_id";
         String folderName = "folder_name";
 
+        String driveName = driveId != null ? "drive_name" : null;
+
         String id = "id_1";
         String filename = "file_name_1";
         long size = 125L;
@@ -97,8 +103,16 @@ public class ListGoogleDriveSimpleTest {
                 .execute()
         ).thenReturn(new File()
                 .setName(folderName)
+                .setDriveId(driveId)
         );
 
+        when(mockDriverService.drives()
+                .get(driveId)
+                .setFields("name")
+                .execute()
+                .getName()
+        ).thenReturn(driveName);
+
         when(mockDriverService.files()
                 .list()
                 .setSupportsAllDrives(true)
@@ -141,6 +155,8 @@ public class ListGoogleDriveSimpleTest {
                         .parentFolderName(folderName)
                         .listedFolderId(folderId)
                         .listedFolderName(folderName)
+                        .sharedDriveId(driveId)
+                        .sharedDriveName(driveName)
                         .build()
         );
 
@@ -168,7 +184,9 @@ public class ListGoogleDriveSimpleTest {
                 GoogleDriveFileInfo::getParentFolderId,
                 GoogleDriveFileInfo::getParentFolderName,
                 GoogleDriveFileInfo::getListedFolderId,
-                GoogleDriveFileInfo::getListedFolderName
+                GoogleDriveFileInfo::getListedFolderName,
+                GoogleDriveFileInfo::getSharedDriveId,
+                GoogleDriveFileInfo::getSharedDriveName
         );
 
         List<EqualsWrapper<GoogleDriveFileInfo>> expectedWrapper = 
wrapList(expected, propertyProviders);
diff --git 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
index 71a9a8ddea..03b554e049 100644
--- 
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
+++ 
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
@@ -30,6 +30,8 @@ import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_ID;
+import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SHARED_DRIVE_NAME;
 import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
 import static 
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.TIMESTAMP;
@@ -74,6 +76,9 @@ public class ListGoogleDriveTestRunnerTest implements 
OutputChecker {
     private final String folderId = "folderId";
     private final String folderName = "folderName";
 
+    private final String driveId = "drive_id";
+    private final String driveName = "drive_name";
+
     @BeforeEach
     void setUp() throws Exception {
         mockDriverService = mock(Drive.class, Mockito.RETURNS_DEEP_STUBS);
@@ -85,8 +90,16 @@ public class ListGoogleDriveTestRunnerTest implements 
OutputChecker {
                 .execute()
         ).thenReturn(new File()
                 .setName(folderName)
+                .setDriveId(driveId)
         );
 
+        when(mockDriverService.drives()
+                .get(driveId)
+                .setFields("name")
+                .execute()
+                .getName()
+        ).thenReturn(driveName);
+
         testSubject = new ListGoogleDrive() {
             @Override
             protected List<GoogleDriveFileInfo> performListing(ProcessContext 
context, Long minTimestamp, ListingMode ignoredListingMode) throws IOException {
@@ -197,7 +210,9 @@ public class ListGoogleDriveTestRunnerTest implements 
OutputChecker {
                         "\"drive.parent.folder.id\":\"" + folderId + "\"," +
                         "\"drive.parent.folder.name\":\"" + folderName + "\"," 
+
                         "\"drive.listed.folder.id\":\"" + folderId + "\"," +
-                        "\"drive.listed.folder.name\":\"" + folderName + "\"" +
+                        "\"drive.listed.folder.name\":\"" + folderName + "\"," 
+
+                        "\"drive.shared.drive.id\":\"" + driveId + "\"," +
+                        "\"drive.shared.drive.name\":\"" + driveName + "\"" +
                         "}" +
                         "]");
 
@@ -262,6 +277,8 @@ public class ListGoogleDriveTestRunnerTest implements 
OutputChecker {
         inputFlowFileAttributes.put(GoogleDriveAttributes.PARENT_FOLDER_NAME, 
folderName);
         inputFlowFileAttributes.put(GoogleDriveAttributes.LISTED_FOLDER_ID, 
folderId);
         inputFlowFileAttributes.put(GoogleDriveAttributes.LISTED_FOLDER_NAME, 
folderName);
+        inputFlowFileAttributes.put(GoogleDriveAttributes.SHARED_DRIVE_ID, 
driveId);
+        inputFlowFileAttributes.put(GoogleDriveAttributes.SHARED_DRIVE_NAME, 
driveName);
 
         HashSet<Map<String, String>> expectedAttributes = new 
HashSet<>(singletonList(inputFlowFileAttributes));
 
@@ -307,6 +324,6 @@ public class ListGoogleDriveTestRunnerTest implements 
OutputChecker {
     @Override
     public Set<String> getCheckedAttributeNames() {
         return Set.of(ID, FILENAME, SIZE, SIZE_AVAILABLE, TIMESTAMP, 
CREATED_TIME, MODIFIED_TIME, MIME_TYPE, PATH, OWNER, LAST_MODIFYING_USER, 
WEB_VIEW_LINK, WEB_CONTENT_LINK,
-                PARENT_FOLDER_ID, PARENT_FOLDER_NAME, LISTED_FOLDER_ID, 
LISTED_FOLDER_NAME);
+                PARENT_FOLDER_ID, PARENT_FOLDER_NAME, LISTED_FOLDER_ID, 
LISTED_FOLDER_NAME, SHARED_DRIVE_ID, SHARED_DRIVE_NAME);
     }
 }


Reply via email to