From fe1ad77383dc1c8addc6ebe163ec32a2baf58223 Mon Sep 17 00:00:00 2001 From: Arnaldo Date: Thu, 25 Mar 2021 15:47:13 +0100 Subject: [PATCH] Added (and passed !)all the FTS tests from test.fts.core --- .../threedbeacons/TDBeaconsFTSRestClientTest.java | 149 ++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java index 3c0d616..fad7750 100644 --- a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java +++ b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java @@ -4,7 +4,9 @@ import static org.testng.AssertJUnit.assertTrue; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.testng.Assert; import org.testng.annotations.AfterMethod; @@ -13,6 +15,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import jalview.fts.api.FTSDataColumnI; +import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI; import jalview.fts.core.FTSRestClient; import jalview.fts.core.FTSRestRequest; import jalview.fts.core.FTSRestResponse; @@ -66,6 +69,7 @@ public class TDBeaconsFTSRestClientTest .isEmpty()); Assert.assertEquals(ftsRestClient .getAllDefaultDisplayedFTSDataColumns().size(), 3); + // currently 3, may change -> change this test and the nexts accordingly } @Test(groups = { "Functional" }) @@ -90,6 +94,151 @@ public class TDBeaconsFTSRestClientTest } } + @Test(groups = { "Functional" }) + public void getDataColumnsFieldsAsCommaDelimitedString() + { + Collection wantedFields = ftsRestClient + .getAllDefaultDisplayedFTSDataColumns(); + String actual = ftsRestClient + .getDataColumnsFieldsAsCommaDelimitedString(wantedFields); + Assert.assertEquals(actual, + "id,uniprot_accession,entry name"); + } + + @Test(groups = { "Functional" }) + public void getAllFTSDataColumns() + { + Collection allFields = ftsRestClient + .getAllFTSDataColumns(); + Assert.assertNotNull(allFields); + //System.out.println(allFields.size()); + Assert.assertEquals(allFields.size(), 3); + } + + @Test(groups = { "Functional" }) + public void getSearchableDataColumns() + { + Collection searchableFields = ftsRestClient + .getSearchableDataColumns(); + Assert.assertNotNull(searchableFields); + //System.out.println(searchableFields.size()); + Assert.assertEquals(searchableFields.size(), 1); //only 1, as of first 3DB test + } + + @Test(groups = { "Functional" }) + public void getPrimaryKeyColumn() + { + FTSDataColumnI expectedPKColumn; + try + { + expectedPKColumn = ftsRestClient + .getDataColumnByNameOrCode("Uniprot Id"); + Assert.assertNotNull(ftsRestClient.getPrimaryKeyColumn()); + Assert.assertEquals(ftsRestClient.getPrimaryKeyColumn(), + expectedPKColumn); + } catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Exception thrown while testing..."); + } + } + + @Test(groups = { "Functional" }) + public void getDataColumnByNameOrCode() + { + try + { + FTSDataColumnI foundDataCol = ftsRestClient + .getDataColumnByNameOrCode("uniprot_accession"); + Assert.assertNotNull(foundDataCol); + Assert.assertEquals(foundDataCol.getName(), "UniProt Accession"); + } catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Exception thrown while testing..."); + } + } + + @Test(groups = { "Functional" }) + public void getDataColumnGroupById() + { + FTSDataColumnGroupI foundDataColGroup; + try + { + foundDataColGroup = ftsRestClient.getDataColumnGroupById("g2"); + Assert.assertNotNull(foundDataColGroup); + Assert.assertEquals(foundDataColGroup.getName(), "Name"); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + @Test(groups = { "Functional" }) + public void getDefaultResponsePageSize() + { + int defaultResSize = ftsRestClient.getDefaultResponsePageSize(); + Assert.assertEquals(defaultResSize, 100); //why 100 or 500 ? pdb is 100, uniprot 500 + } + + @Test(groups = { "Functional" }) + public void getColumnMinWidthTest() + { + try + { + FTSDataColumnI foundDataCol = ftsRestClient + .getDataColumnByNameOrCode("uniprot_accession"); + Assert.assertNotNull(foundDataCol); + int actualColMinWidth = foundDataCol.getMinWidth(); + Assert.assertEquals(actualColMinWidth, 50); + } catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Exception thrown while testing..."); + } + } + // could add test for MaxWidth & PreferedWith + + @Test(groups = { "Functional" }) + public void getColumnClassTest() + { + try + { + FTSDataColumnI foundDataCol = ftsRestClient + .getDataColumnByNameOrCode("uniprot_accession"); + Assert.assertNotNull(foundDataCol); + Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(), + String.class); + foundDataCol = ftsRestClient.getDataColumnByNameOrCode("id"); + Assert.assertNotNull(foundDataCol); + Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(), + String.class); + } catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Exception thrown while testing..."); + } + } + + @Test(groups = { "Functional" }) + public void coverageForEqualsAndHashFunction() + { + Set uniqueSet = new HashSet(); + Collection searchableCols = ftsRestClient + .getSearchableDataColumns(); + System.out.println(searchableCols); + for (FTSDataColumnI foundCol : searchableCols) + { + System.out.println(foundCol.toString()); + uniqueSet.add(foundCol); + uniqueSet.add(foundCol); + } + Assert.assertTrue(!uniqueSet.isEmpty()); + //Assert.assertEquals(uniqueSet.size(), 22); -> 1 or 2 currently for 3DB + } + + + @Test(groups = { "External", "Network" }) public void executeRequestTest() { -- 1.7.10.2