smiklosovic commented on code in PR #2983:
URL: https://github.com/apache/cassandra/pull/2983#discussion_r1428950180


##########
test/unit/org/apache/cassandra/service/StartupChecksTest.java:
##########
@@ -204,6 +216,104 @@ List<TableGCPeriod> getTablesGcPeriods(String 
userKeyspace)
         verifyFailure(startupChecks, "Invalid tables: abc.def");
     }
 
+    private <R> void withPathOverriddingFileSystem(Map<String, String> 
pathOverrides, Callable<? extends R> callable) throws Exception
+    {
+        Map<String, FileStore> fileStores = 
Set.copyOf(pathOverrides.values()).stream().collect(Collectors.toMap(s -> s, s 
-> {
+            FileStore fs = mock(FileStore.class);
+            when(fs.type()).thenReturn(s);
+            return fs;
+        }));
+        FileSystem savedFileSystem = File.unsafeGetFilesystem();
+        try
+        {
+            ForwardingFileSystemProvider fsp = new 
ForwardingFileSystemProvider(savedFileSystem.provider())
+            {
+                @Override
+                public FileStore getFileStore(Path path) throws IOException
+                {
+                    String override = pathOverrides.get(path.toString());
+                    if (override != null)
+                        return fileStores.get(override);
+
+                    return super.getFileStore(path);
+                }
+            };
+
+            ForwardingFileSystem fs = new 
ForwardingFileSystem(File.unsafeGetFilesystem())

Review Comment:
   can't we use `savedFileSystem` as constructor argument here?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to