JAL-2316 More unit testing and adjustments
[jalview.git] / test / jalview / urls / UrlLinkTableModelTest.java
index bf13784..1304d1a 100644 (file)
@@ -21,9 +21,9 @@
 
 package jalview.urls;
 
-import static jalview.util.UrlConstants.DB_ACCESSION;
 import static jalview.util.UrlConstants.DELIM;
 import static jalview.util.UrlConstants.SEP;
+import static jalview.util.UrlConstants.SEQUENCE_ID;
 
 import jalview.util.MessageManager;
 
@@ -94,7 +94,7 @@ public class UrlLinkTableModelTest {
     provlist.add(idprov);
     provlist.add(cprov);
 
-    prov = new UrlProvider("MIR:00000005", provlist);
+    prov = new UrlProvider("TEST2", provlist);
   }
 
   /*
@@ -124,7 +124,7 @@ public class UrlLinkTableModelTest {
       {
         count++;
         String defaultName = (String) m.getValueAt(row, nameCol);
-        Assert.assertEquals(defaultName, "UniProt Knowledgebase");
+        Assert.assertEquals(defaultName, "TEST2");
       }
     }
     Assert.assertEquals(count, 1);
@@ -229,17 +229,17 @@ public class UrlLinkTableModelTest {
       isDefault = (boolean) m.getValueAt(olddefault, 3);
     }
 
-    // set new values, one in each row - uneditable
+    // set new values, one in each row
     m.setValueAt("namechanged", 6, 0);
     m.setValueAt("urlchanged", 7, 1);
     m.setValueAt(false, 8, 2);
-    m.setValueAt(true, 9, 3);
+    m.setValueAt(true, 6, 3);
 
     // check values updated in table
     Assert.assertEquals(m.getValueAt(6, 0), "namechanged");
     Assert.assertEquals(m.getValueAt(7, 1), "urlchanged");
     Assert.assertFalse((boolean) m.getValueAt(8, 2));
-    Assert.assertTrue((boolean) m.getValueAt(9, 3));
+    Assert.assertTrue((boolean) m.getValueAt(6, 3));
     Assert.assertFalse((boolean) m.getValueAt(olddefault, 3));
 
     // check default row is exactly one row still
@@ -249,7 +249,7 @@ public class UrlLinkTableModelTest {
 
       // if isDefault is true, row is 9
       // if isDefault is false, row is not 9
-      Assert.assertFalse(isDefault && !(row == 9));
+      Assert.assertFalse(isDefault && !(row == 6));
     }
 
     // check table updated
@@ -257,8 +257,8 @@ public class UrlLinkTableModelTest {
     Assert.assertTrue(prov.writeUrlsAsString(true).contains(m.getValueAt(7,0) + SEP + "urlchanged"));
     Assert.assertTrue(prov.writeUrlsAsString(false).contains(
             (String) m.getValueAt(8, 0)));
-    Assert.assertEquals(prov.getDefaultUrl("seqid"), m.getValueAt(9, 1)
-            .toString().replace(DELIM + DB_ACCESSION + DELIM, "seqid"));
+    Assert.assertEquals(prov.getDefaultUrl("seqid"), m.getValueAt(6, 1)
+            .toString().replace(DELIM + SEQUENCE_ID + DELIM, "seqid"));
 
   }
 
@@ -275,7 +275,15 @@ public class UrlLinkTableModelTest {
       Assert.assertFalse(m.isCellEditable(row, 0));
       Assert.assertFalse(m.isCellEditable(row, 1));
       Assert.assertTrue(m.isCellEditable(row, 2));
-      Assert.assertTrue(m.isCellEditable(row, 3));
+
+      if ((row == 4) || (row == 6) || (row == 7))
+      {
+        Assert.assertTrue(m.isCellEditable(row, 3));
+      }
+      else
+      {
+        Assert.assertFalse(m.isCellEditable(row, 3));
+      }
     }
   }
 }