JAL-3438 spotless for 2.11.2.0
[jalview.git] / test / jalview / util / QuickSortTest.java
index f976955..bf9d16b 100644 (file)
@@ -23,13 +23,24 @@ package jalview.util;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 
+import jalview.gui.JvOptionPane;
+
 import java.util.Arrays;
 import java.util.Random;
 
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 public class QuickSortTest
 {
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
   private static final String c1 = "Blue";
 
   private static final String c2 = "Yellow";
@@ -109,8 +120,9 @@ public class QuickSortTest
     String[] values = new String[] { "JOHN", "henry", "lucy", "henry",
         "ALISON" };
     QuickSort.sort(values, things);
-    assertTrue(Arrays.equals(new String[] { "lucy", "henry", "henry",
-        "JOHN", "ALISON" }, values));
+    assertTrue(
+            Arrays.equals(new String[]
+            { "lucy", "henry", "henry", "JOHN", "ALISON" }, values));
     assertTrue(Arrays.equals(new Object[] { c3, c2, c4, c1, c5 }, things));
   }
 
@@ -125,8 +137,9 @@ public class QuickSortTest
     QuickSort.sort(values, letters);
     assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4, 4 }, values));
     // this fails - do we care?
-    assertTrue(Arrays.equals(new Object[] { "Z", "Y", "A", "X", "B" },
-            letters));
+    assertTrue(
+            Arrays.equals(new Object[]
+            { "Z", "Y", "A", "X", "B" }, letters));
   }
 
   /**
@@ -183,10 +196,9 @@ public class QuickSortTest
       QuickSort.sort(counts, residues);
     }
     long elapsed = System.currentTimeMillis() - start;
-    System.out
-            .println(String
-                    .format("Time for %d optimised sorts of mostly zeros array length %d was %dms",
-                            iterations, counts.length, elapsed));
+    System.out.println(String.format(
+            "Time for %d optimised sorts of mostly zeros array length %d was %dms",
+            iterations, counts.length, elapsed));
 
     /*
      * time it using unoptimised external sort
@@ -201,10 +213,9 @@ public class QuickSortTest
       QuickSort.charSortByFloat(counts, residues, true);
     }
     elapsed = System.currentTimeMillis() - start;
-    System.out
-            .println(String
-                    .format("Time for %d external sorts of mostly zeros array length %d was %dms",
-                            iterations, counts.length, elapsed));
+    System.out.println(String.format(
+            "Time for %d external sorts of mostly zeros array length %d was %dms",
+            iterations, counts.length, elapsed));
 
     /*
      * optimised external sort, well-filled array
@@ -223,10 +234,9 @@ public class QuickSortTest
       QuickSort.sort(counts, residues);
     }
     elapsed = System.currentTimeMillis() - start;
-    System.out
-            .println(String
-                    .format("Time for %d optimised sorts of non-zeros array length %d was %dms",
-                            iterations, counts.length, elapsed));
+    System.out.println(String.format(
+            "Time for %d optimised sorts of non-zeros array length %d was %dms",
+            iterations, counts.length, elapsed));
 
     /*
      * time unoptimised external sort, filled array
@@ -238,10 +248,9 @@ public class QuickSortTest
       QuickSort.charSortByFloat(counts, residues, true);
     }
     elapsed = System.currentTimeMillis() - start;
-    System.out
-            .println(String
-                    .format("Time for %d external sorts of non-zeros array length %d was %dms",
-                            iterations, counts.length, elapsed));
+    System.out.println(String.format(
+            "Time for %d external sorts of non-zeros array length %d was %dms",
+            iterations, counts.length, elapsed));
   }
 
   /**
@@ -346,16 +355,18 @@ public class QuickSortTest
      * sort descending
      */
     QuickSort.sortByString(values, things, false);
-    assertTrue(Arrays.equals(new String[] { "lucy", "henry", "henry",
-        "JOHN", "ALISON" }, values));
+    assertTrue(
+            Arrays.equals(new String[]
+            { "lucy", "henry", "henry", "JOHN", "ALISON" }, values));
     assertTrue(Arrays.equals(new Object[] { c3, c2, c4, c1, c5 }, things));
 
     /*
      * resort ascending
      */
     QuickSort.sortByString(values, things, true);
-    assertTrue(Arrays.equals(new String[] { "ALISON", "JOHN", "henry",
-        "henry", "lucy" }, values));
+    assertTrue(
+            Arrays.equals(new String[]
+            { "ALISON", "JOHN", "henry", "henry", "lucy" }, values));
     // sort is stable: c2/c4 do not swap order
     assertTrue(Arrays.equals(new Object[] { c5, c1, c2, c4, c3 }, things));
   }