Merge branch 'features/JAL-2110_crossRefDuplications' into merge_JAL-2110
[jalview.git] / test / jalview / gui / StructureChooserTest.java
index 1b00c4a..da2cde5 100644 (file)
@@ -60,7 +60,7 @@ public class StructureChooserTest
     seq.setPDBId(pdbIds);
   }
 
-  @AfterMethod
+  @AfterMethod(alwaysRun = true)
   public void tearDown() throws Exception
   {
     seq = null;
@@ -70,10 +70,16 @@ public class StructureChooserTest
   public void buildQueryTest()
   {
     String query = StructureChooser.buildQuery(seq);
-    System.out.println(">>>>>>>>>> query : " + query);
+    assertEquals("pdb_id:1tim", query);
+    System.out.println("seq >>>> " + seq);
+    seq.getAllPDBEntries().clear();
+    query = StructureChooser.buildQuery(seq);
     assertEquals(
-            "4kqy OR text:1tim OR text:XYZ_1 OR text:XYZ_2 OR text:XYZ_3 OR text:XYZ_4",
+            "text:XYZ_1 OR text:XYZ_2 OR text:XYZ_3 OR text:XYZ_4 OR text:4kqy",
             query);
+    seq.setDBRefs(null);
+    query = StructureChooser.buildQuery(seq);
+    assertEquals("text:4kqy", query);
   }
 
   @Test(groups = { "Functional" })
@@ -88,6 +94,13 @@ public class StructureChooserTest
 
     sc.setStructuresDiscovered(true);
     sc.populateFilterComboBox();
+    try
+    {
+      Thread.sleep(2000);
+    } catch (InterruptedException e)
+    {
+      e.printStackTrace();
+    }
     optionsSize = sc.getCmbFilterOption().getItemCount();
     assertTrue(optionsSize > 3); // if structures are found, filter options
                                  // should be populated
@@ -103,4 +116,22 @@ public class StructureChooserTest
     assertTrue(sc.getDiscoveredStructuresSet().size() > 0);
 
   }
+
+  @Test(groups = { "Functional" })
+  public void sanitizeSeqNameTest()
+  {
+    String name = "ab_cdEF|fwxyz012349";
+    assertEquals(name, StructureChooser.sanitizeSeqName(name));
+
+    // remove a [nn] substring
+    name = "abcde12[345]fg";
+    assertEquals("abcde12fg", StructureChooser.sanitizeSeqName(name));
+
+    // remove characters other than a-zA-Z0-9 | or _
+    name = "ab[cd],.\t£$*!- \\\"@:e";
+    assertEquals("abcde", StructureChooser.sanitizeSeqName(name));
+
+    name = "abcde12[345a]fg";
+    assertEquals("abcde12345afg", StructureChooser.sanitizeSeqName(name));
+  }
 }