Fix tests for switch of @SitePath from File to Path

While the main code got switched to use @SitePath's Path in

  934cda804fe3ff62ba9689cb154f7d82de970263

switching it also for the tests got overlooked. Hence, tests have been
failing since. We now also switch the tests to use Path for the
injection to make tests pass again

Change-Id: I903b98cc89f6490d7aa4a723bb763b121134a471
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java
index f8e4f15..74992ee 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java
@@ -30,6 +30,9 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -38,7 +41,7 @@
 public class RuleBaseTest extends LoggingMockingTestCase {
   private Injector injector;
 
-  private File sitePath;
+  private Path sitePath;
   private Rule.Factory ruleFactory;
   private Condition.Factory conditionFactory;
   private ActionRequest.Factory actionRequestFactory;
@@ -366,8 +369,9 @@
       default:
         fail("Unknown ruleBaseKind");
     }
-    File ruleBaseFile = new File(sitePath, "etc" + File.separatorChar + "its" +
-        File.separator + baseName + ".config");
+    File ruleBaseFile = new File(sitePath.toFile(),
+        "etc" + File.separatorChar + "its" + File.separator +
+        baseName + ".config");
 
     File ruleBaseParentFile = ruleBaseFile.getParentFile();
     if (!ruleBaseParentFile.exists()) {
@@ -389,16 +393,15 @@
 
   public void tearDown() throws Exception {
     if (cleanupSitePath) {
-      if (sitePath.exists()) {
-        FileUtils.delete(sitePath, FileUtils.RECURSIVE);
+      if (Files.exists(sitePath)) {
+        FileUtils.delete(sitePath.toFile(), FileUtils.RECURSIVE);
       }
     }
     super.tearDown();
   }
 
-  private File randomTargetFile() {
-    final File t = new File("target");
-    return new File(t, "random-name-" + UUID.randomUUID().toString());
+  private Path randomTargetPath() {
+    return Paths.get("target", "random-name-" + UUID.randomUUID().toString());
   }
 
   private class TestModule extends FactoryModule {
@@ -408,12 +411,12 @@
       bind(String.class).annotatedWith(PluginName.class)
           .toInstance("ItsTestName");
 
-      sitePath = randomTargetFile();
+      sitePath = randomTargetPath();
       assertFalse("sitePath already (" + sitePath + ") already exists",
-          sitePath.exists());
+          Files.exists(sitePath));
       cleanupSitePath = true;
 
-      bind(File.class).annotatedWith(SitePath.class).toInstance(sitePath);
+      bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
 
       ruleFactory = createMock(Rule.Factory.class);
       bind(Rule.Factory.class).toInstance(ruleFactory);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java
index edc41ed..a6aafa5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java
@@ -43,6 +43,9 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.lang.reflect.InvocationTargetException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.UUID;
@@ -50,7 +53,7 @@
 public class AddVelocityCommentTest extends LoggingMockingTestCase {
   private Injector injector;
 
-  private File sitePath;
+  private Path sitePath;
   private ItsFacade its;
   private RuntimeInstance velocityRuntime;
 
@@ -354,8 +357,8 @@
   }
 
   private void injectTestTemplate(String template) throws IOException {
-    File templateParentFile = new File(sitePath, "etc" + File.separatorChar + "its" +
-        File.separator + "templates");
+    File templateParentFile = new File(sitePath.toFile(), "etc" +
+        File.separatorChar + "its" + File.separator + "templates");
     assertTrue("Failed to create parent (" + templateParentFile + ") for " +
         "rule base", templateParentFile.mkdirs());
     File templateFile = new File(templateParentFile, "test-template.vm");
@@ -375,27 +378,26 @@
 
   public void tearDown() throws Exception {
     if (cleanupSitePath) {
-      if (sitePath.exists()) {
-        FileUtils.delete(sitePath, FileUtils.RECURSIVE);
+      if (Files.exists(sitePath)) {
+        FileUtils.delete(sitePath.toFile(), FileUtils.RECURSIVE);
       }
     }
     super.tearDown();
   }
 
-  private File randomTargetFile() {
-    final File t = new File("target");
-    return new File(t, "random-name-" + UUID.randomUUID().toString());
+  private Path randomTargetPath() {
+    return Paths.get("target", "random-name-" + UUID.randomUUID().toString());
   }
 
   private class TestModule extends FactoryModule {
     @Override
     protected void configure() {
-      sitePath = randomTargetFile();
+      sitePath = randomTargetPath();
       assertFalse("sitePath already (" + sitePath + ") already exists",
-          sitePath.exists());
+          Files.exists(sitePath));
       cleanupSitePath = true;
 
-      bind(File.class).annotatedWith(SitePath.class).toInstance(sitePath);
+      bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
 
       its = createMock(ItsFacade.class);
       bind(ItsFacade.class).toInstance(its);