Permalink
Browse files

Adding new tests for the configurations and for testing the publicati…

…on searcher.
  • Loading branch information...
1 parent 2ac539f commit 9ab6cb6aebe42ac9b001660438d9e52fa36133bb @eamonnmag eamonnmag committed Jul 14, 2011
View
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+rm -rf Configurations
+
+echo "Retreiving configuration from GitHub repo"
+mkdir Configurations
+cd Configurations
+wget https://github.com/downloads/ISA-tools/Configuration-Files/isaconfig-default_v2011-02-18.zip --no-check-certificate
+wget https://github.com/downloads/ISA-tools/Configuration-Files/isaconfig-default_v2011-02-18-MIMARKS-soil_v2011-02-18.zip --no-check-certificate
+wget https://github.com/downloads/ISA-tools/Configuration-Files/isaconfig-default_v2011-02-18-MIMARKS-water_v2011-02-18.zip --no-check-certificate
+wget https://github.com/downloads/ISA-tools/Configuration-Files/isaconfig-MISFISHIE-rodent-january-2011.zip --no-check-certificate
+
+echo "Unzipping files"
+
+unzip isaconfig-default_v2011-02-18.zip
+unzip isaconfig-default_v2011-02-18-MIMARKS-soil_v2011-02-18.zip
+unzip isaconfig-default_v2011-02-18-MIMARKS-water_v2011-02-18.zip
+unzip isaconfig-MISFISHIE-rodent-january-2011.zip
+
+echo "Cleaning up directory"
+rm -rf __*
+rm *.zip
+
+cd ../
+
+echo "Running tests"
+
+# now run tests
+mvn $MVNOPTS clean test
+
+echo "Testing completed successfully!"
+
@@ -13,14 +13,6 @@
import java.util.Map;
import java.util.Set;
-/**
- * Created by the ISA team
- *
- * @author Eamonn Maguire (eamonnmag@gmail.com)
- * <p/>
- * Date: 26/01/2011
- * Time: 18:39
- */
public class BioPortalAnnotatorResultHandler {
public SuccessDocument getDocument(String fileLocation) {
@@ -58,8 +50,6 @@ public SuccessDocument getDocument(String fileLocation) {
if (annotatorResult != null) {
- System.out.println("Original test to annotate: " + originalTextToAnnotate);
-
String originalTerm = originalTextToAnnotate.substring(annotatorResult.getStartIndex() - 1, annotatorResult.getEndIndex());
if (originalTerms.contains(originalTerm)) {
@@ -44,10 +44,9 @@ The ISA Team and the ISA software suite have been funded by the EU Carcinogenomi
import org.isatools.isacreator.model.StudyPublication;
import uk.ac.ebi.cdb.client.*;
+import javax.print.attribute.ResolutionSyntax;
import javax.xml.ws.WebServiceRef;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class CiteExploreClient {
@@ -74,55 +73,58 @@ private String formDOIQueryString(String doi) {
public Map<String, Publication> getPublication(SearchOption searchOption, String query, DataEntryForm parent) throws NoPublicationFoundException {
Map<String, Publication> publications = new HashMap<String, Publication>();
try {
- WSCitationImpl port = service.getWSCitationImplPort();
- String fullQueryString = searchOption == SearchOption.DOI ? formDOIQueryString(query) : formPubMedQueryString(query);
+ List<ResultBean> resultBeanCollection = searchForPublication(searchOption, query);
- ResultListBean resultListBean = port.searchCitations(fullQueryString, "all", 0, "");
+ for (ResultBean resultBean : resultBeanCollection) {
+ uk.ac.ebi.cdb.client.Citation citation = resultBean.getCitation();
- if (resultListBean.getHitCount() > 0) {
- List<ResultBean> resultBeanCollection = resultListBean.getResultBeanCollection();
- for (ResultBean resultBean : resultBeanCollection) {
- uk.ac.ebi.cdb.client.Citation citation = resultBean.getCitation();
-
-
- String authorList = "";
- for (Author author : citation.getAuthorCollection()) {
- authorList += author.getLastName() + " " + author.getInitials() + ",";
- }
- if (authorList.length() > 1) {
- authorList = authorList.substring(0, authorList.length() - 1);
- }
-
- String doi = "";
- for (FullTextURL ftURL : citation.getUrlCollection()) {
- if (ftURL.getUrl().contains("doi")) {
- doi = ftURL.getUrl();
- break;
- }
- }
+ String authorList = "";
+ for (Author author : citation.getAuthorCollection()) {
+ authorList += author.getLastName() + " " + author.getInitials() + ",";
+ }
+ if (authorList.length() > 1) {
+ authorList = authorList.substring(0, authorList.length() - 1);
+ }
- Publication pub;
- if (parent instanceof StudyDataEntry) {
- pub = new StudyPublication(citation.getExternalId(), doi, authorList, citation.getTitle().replaceAll("\\[|\\]", ""), "Published");
- } else {
- pub = new InvestigationPublication(citation.getExternalId(), doi, authorList, citation.getTitle().replaceAll("\\[|\\]", ""), "Published");
+ String doi = "";
+ for (FullTextURL ftURL : citation.getUrlCollection()) {
+ if (ftURL.getUrl().contains("doi")) {
+ doi = ftURL.getUrl();
+ break;
}
- pub.setAbstractText(citation.getAbstractText());
- publications.put(citation.getExternalId(), pub);
+ }
+ Publication pub;
+ if (parent instanceof StudyDataEntry) {
+ pub = new StudyPublication(citation.getExternalId(), doi, authorList, citation.getTitle().replaceAll("\\[|\\]", ""), "Published");
+ } else {
+ pub = new InvestigationPublication(citation.getExternalId(), doi, authorList, citation.getTitle().replaceAll("\\[|\\]", ""), "Published");
}
- } else {
- throw new NoPublicationFoundException(searchOption, query);
+ pub.setAbstractText(citation.getAbstractText());
+ publications.put(citation.getExternalId(), pub);
}
-
} catch (QueryException_Exception qex) {
System.out.printf("Caught QueryException_Exception: %s\n", qex.getFaultInfo().getMessage());
}
return publications;
}
+ public List<ResultBean> searchForPublication(SearchOption searchOption, String query) throws QueryException_Exception, NoPublicationFoundException {
+ WSCitationImpl port = service.getWSCitationImplPort();
+
+ String fullQueryString = searchOption == SearchOption.DOI ? formDOIQueryString(query) : formPubMedQueryString(query);
+
+ ResultListBean resultListBean = port.searchCitations(fullQueryString, "all", 0, "");
+
+ if (resultListBean.getHitCount() > 0) {
+ return resultListBean.getResultBeanCollection();
+ } else {
+ throw new NoPublicationFoundException(searchOption, query);
+ }
+ }
+
}
@@ -0,0 +1,38 @@
+package org.isatools.isacreator.configuration.io;
+
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertTrue;
+
+public class ConfigurationLoadTest {
+
+ @Test
+ public void configurationTestLoad() {
+ System.out.println("_____TESTING configurationTestLoad()");
+
+ File configurationDirectory = new File("Configurations");
+ if(configurationDirectory.exists() && configurationDirectory.isDirectory()) {
+
+ File[] configurationFiles = configurationDirectory.listFiles();
+
+ for(File file : configurationFiles) {
+
+ if(!file.isHidden() && !file.getName().startsWith(".")) {
+
+ ConfigXMLParser parser = new ConfigXMLParser(ConfigurationLoadingSource.ISACREATOR, file.getAbsolutePath());
+
+ System.out.println("___loading configuration " + file.getName().toLowerCase());
+
+ parser.loadConfiguration();
+
+ assertTrue("Oh, the configuration size is 0!", parser.getTables().size() > 0);
+
+ System.out.println("Configuration " + file.getName().toLowerCase() + " loaded successfully");
+ }
+ }
+ }
+ }
+
+}
@@ -0,0 +1,53 @@
+package org.isatools.isacreator.publicationlocator;
+
+import org.junit.Test;
+import uk.ac.ebi.cdb.client.Citation;
+import uk.ac.ebi.cdb.client.QueryException_Exception;
+import uk.ac.ebi.cdb.client.ResultBean;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Created by the ISA team
+ *
+ * @author Eamonn Maguire (eamonnmag@gmail.com)
+ * <p/>
+ * Date: 14/07/2011
+ * Time: 13:45
+ */
+public class CiteXploreTest {
+
+ @Test
+ public void testCiteXplorePubMed() {
+ runTest(SearchOption.PUBMED, "19815759");
+ }
+
+ @Test
+ public void testCiteXploreDOI() {
+ runTest(SearchOption.DOI, "10.1093/bioinformatics/btq415");
+ }
+
+ private void runTest(SearchOption searchOption, String query) {
+ CiteExploreClient publicationSearcher = new CiteExploreClient();
+
+ try {
+ List<ResultBean> result = publicationSearcher.searchForPublication(searchOption, query);
+ printResultBeans(result);
+ } catch (QueryException_Exception qex) {
+ System.out.printf("Caught QueryException_Exception: %s\n", qex.getFaultInfo().getMessage());
+ } catch (NoPublicationFoundException e) {
+ System.out.println("No publication found");
+ }
+ }
+
+ private void printResultBeans(Collection<ResultBean> resultBeans) {
+ for(ResultBean resultBean : resultBeans) {
+ Citation citation = resultBean.getCitation();
+
+ System.out.println("citation.getTitle() = " + citation.getTitle());
+ System.out.println("citation.getAbstractText() = " + citation.getAbstractText());
+ System.out.println("citation.getAffiliation() = " + citation.getAffiliation());
+ }
+ }
+}

0 comments on commit 9ab6cb6

Please sign in to comment.