org.ambraproject.service.crossref.CrossRefLookupServiceImplTest.java Source code

Java tutorial

Introduction

Here is the source code for org.ambraproject.service.crossref.CrossRefLookupServiceImplTest.java

Source

/*
 * Copyright (c) 2006-2014 by Public Library of Science
 *
 * http://plos.org
 * http://ambraproject.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ambraproject.service.crossref;

import org.ambraproject.util.DocumentBuilderFactoryCreator;
import org.ambraproject.views.CrossRefSearch;
import org.apache.commons.httpclient.HttpClientMock;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.Document;

import java.io.File;

import static org.testng.Assert.*;

/**
 * @author Dragisa Krsmanovic
 * @author Joe Osowski
 */
public class CrossRefLookupServiceImplTest {

    @DataProvider(name = "expectedCrossRefSeaches")
    public Object[][] expectedCrossRefSeaches() {
        /**
         * These search strings where auto generated by the populateCitationDoiFromCrossRef.py script
         */
        return new Object[][] { { new String[] {
                "A. Dona, I. S. Arvanitoyannis, \"Health risks of genetically modified foods\", Crit Rev Food Sci Nutr, vol. 49, pp. 164-175, 2009",
                "E. Schnepf, N. Crickmore, J. Van Rie, D. Lereclus, J. Baum, \"Bacillus thuringiensis and its pesticidal crystal proteins\", Microbiol Rev, vol. 62, pp. 775-806, 1998",
                "M. Hill, K. Launis, C. Bowman, K. McPherson, J. Dawson, \"Biolistic introduction of a synthetic Bt gene into elite maize\", Euphytica, vol. 85, pp. 119-123, 1995",
                "F. S. Betz, B. G. Hammond, R. L. Fuchs, \"Safety and advantages of Bacillus thuringiensis-protected plants to control insect pests\", Regul Toxicol Pharmacol, vol. 32, pp. 156-173, 2000",
                "V. E. Prescott, S. P. Hogan, \"Genetically modified plants and food hypersensitivity diseases: Usage and implications of experimental models for risk assessment\", Pharmacol Ther, vol. 111, pp. 374-383, 2006",
                "J. M. Wal, P. A. Hepburn, L. J. Lea, R. W. R. Crevel, \"Post-market surveillance of GM foods: applicability and limitations of schemes used with pharmaceuticals and some non-GM novel foods\", Regul Toxicol Pharmacol, vol. 38, pp. 98-104, 2003",
                "EFSA, \"Safety and nutritional assessment of GM plants and derived food and feed: The role of animal feeding trials\", Food Chem Toxicol, vol. 46, pp. S2-S70, 2008",
                "J. Poole, H. Claman, \"Immunology of pregnancy\", Clin Rev Allergy Immunol, vol. 26, pp. 161-170, 2004",
                "C. L. Butts, E. M. Sternberg, \"Neuroendocrine factors alter host defense by modulating immune function\", Cell Immunol, vol. 252, pp. 7-15, 2008",
                "EFSA, \"Scientific opinion of the panel on genetically modified organisms on applications (EFSA-GMO-RX-MON810) for the renewal of authorisation for the continued marketing of (1) existing food and food ingredients produced from genetically modified insect resistant maize MON810; (2) feed consisting of and/or containing maize MON810, including the use of seed for cultivation; and of (3) food and feed additives, and feed materials produced from maize MON810, all under Regulation (EC) No 1829/2003 from Monsanto\", The EFSA Journal, vol. 1149, pp. 1-85, 2009",
                "J. L. Domingo, J. Gin Bordonaba, \"A literature review on the safety assessment of genetically modified plants\", Environ Int, vol. 37, pp. 734-742, 2011",
                "C. Snell, A. Bernheim, J. -. B. Berge, M. Kuntz, G. Pascal, \"Assessment of the health impact of GM plant diets in long-term and multigenerational animal feeding trials: A literature review\", Food Chem Toxicol, vol. 50, pp. 1134-1148, 2012",
                "P. J. Moughan, M. J. Birtles, P. D. Cranwell, W. C. Smith, M. Pedraza, \"The piglet as a model animal for studying aspects of digestion and absorption in milk-fed human infants\", World Rev Nutr Diet, vol. 67, pp. 40-113, 1992",
                "T. T. Kararli, \"Comparison of the gastrointestinal anatomy, physiology, and biochemistry of humans and commonly used laboratory animals\", Biopharm Drug Dispos, vol. 16, pp. 351-380, 1995",
                "M. C. Walsh, S. G. Buzoianu, G. E. Gardiner, J. P. Cassidy, M. C. Rea, \"Effects of short-term feeding of Bt MON810 maize on growth performance, organ morphology and function in pigs\", Br J Nutr, vol. 107, pp. 364-371, 2012",
                "M. C. Walsh, G. E. Gardiner, O. M. Hart, P. G. Lawlor, M. Daly, \"Predominance of a bacteriocin-producing Lactobacillus salivarius component of a five-strain probiotic in the porcine ileum and effects on host immune phenotype\", FEMS Microbiol Ecol, vol. 64, pp. 317-327, 2008",
                "M. C. Walsh, S. G. Buzoianu, M. C. Rea, O. O'Donovan, E. Gelencsr, \"Effects of feeding Bt MON810 maize to pigs for 110 days on peripheral immune response and digestive fate of the cry1ab gene and truncated Bt toxin\", PLoS ONE, vol. 7, pp. e36141, 2012",
                "P. A. Pappas, V. DePuy, \"An overview of non-parametric tests in SAS: when, why, and how\", SESUG 2004: The Proceedings of the SouthEast SAS Users Group, Nashville,TN, vol. 2004, pp. TU04, 2004",
                "R. Mundry, J. Fischer, \"Use of statistical programs for nonparametric tests of small samples often leads to incorrect P values: examples from Animal Behaviour\", Anim Behav, vol. 56, pp. 256-259, 1998",
                "J. de Vendmois, D. Cellier, C. Vlot, E. Clair, R. Mesnage, \"Debate on GMOs health risks after statistical findings in regulatory tests. Int J Biol Sci\", vol. 6, pp. 590-598, 2010",
                "EFSA, \"Guidance for risk assessment of food and feed from genetically modified plants\", The EFSA Journal, vol. 9, pp. 2150, 2011",
                "R. M. Helm, G. T. Furuta, J. S. Stanley, J. Ye, G. Cockrell, \"A neonatal swine model for peanut allergy\", J Allergy Clin Immunol, vol. 109, pp. 136-142, 2002",
                "M. Bailey, K. Haverson, \"The postnatal development of the mucosal immune system and mucosal tolerance in domestic animals\", Vet Res, vol. 37, pp. 443-453, 2006",
                "R. M. Helm, A. W. Burks, \"Mechanisms of food allergy\", Curr Opin Immunol, vol. 12, pp. 647-653, 2000",
                "E. H. Chowdhury, H. Kuribara, A. Hino, P. Sultana, O. Mikami, \"Detection of corn intrinsic and recombinant DNA fragments and Cry1Ab protein in the gastrointestinal contents of pigs fed genetically modified corn Bt11\", J Anim Sci, vol. 81, pp. 2546-2551, 2003",
                "R. Einspanier, B. Lutz, S. Rief, O. Berezina, V. Zverlov, \"Tracing residual recombinant feed molecules during digestion and rumen bacterial diversity in cattle fed transgene maize\", Eur Food Res Technol, vol. 218, pp. 269-273, 2004",
                "B. Lutz, S. Wiedemann, R. Einspanier, J. Mayer, C. Albrecht, \"Degradation of Cry1Ab protein from genetically modified maize in the bovine gastrointestinal tract\", J Agric Food Chem, vol. 53, pp. 1453-1456, 2005",
                "S. Wiedemann, B. Lutz, C. Albrecht, R. Kuehn, B. Killermann, \"Fate of genetically modified maize and conventional rapeseed, and endozoochory in wild boar (Sus scrofa)\", Mamm Biol, vol. 74, pp. 191-197, 2009",
                "N. R. J. Reddy, P. Borgs, B. N. Wilkie, \"Cytokine mRNA expression in leukocytes of efferent lymph from stimulated lymph nodes in pigs\", Vet Immunol Immunopathol, vol. 74, pp. 31-46, 2000",
                "M. P. Murtaugh, D. L. Foss, \"Inflammatory cytokines and antigen presenting cell activation\", Vet Immunol Immunopathol, vol. 87, pp. 109-121, 2002",
                "A. Finamore, M. Roselli, S. Britti, G. Monastra, R. Ambra, \"Intestinal and peripheral immune response to MON810 maize ingestion in weaning and old mice\", J Agric Food Chem, vol. 56, pp. 11533-11539, 2008",
                "E. Barros, S. Lezar, M. J. Anttonen, J. P. van Dijk, R. M. Rhlig, \"Comparison of two GM maize varieties with a near-isogenic non-GM variety using transcriptomics, proteomics and metabolomics\", Plant Biotechnol J, vol. 8, pp. 436-451, 2010",
                "R. Batista, M. Oliveira, \"Plant natural variability may affect safety assessment data\", Regulatory Toxicology and Pharmacology, vol. 58, pp. S8-S12, 2010",
                "Ct Fonseca, S. Planchon, J. Renaut, M. M. Oliveira, R. Batista, \"Characterization of maize allergens - MON810 vs. its non-transgenic counterpart\", J Proteomics, vol. 75, pp. 2027-2037, 2012",
                "S. E. Shoelson, J. Lee, A. B. Goldfine, \"Inflammation and insulin resistance\", J Clin Invest, vol. 116, pp. 1793-1801, 2006",
                "M. Szczepanik, \"Interplay between Helicobacter pylori and the immune system. Clinical implications\", J Physiol Pharmacol, vol. 57, pp. 15-27, 2006",
                "I. Mukhopadhya, R. Hansen, E. M. El-Omar, G. L. Hold, \"IBD-what role do Proteobacteria play\", Nat Rev Gastroenterol Hepatol, vol. 9, pp. 219-230, 2012",
                "A. K. Egeli, T. Framstad, H. Morberg, \"Clinical biochemistry, haematology and body weight in piglets\", Acta Vet Scand, vol. 39, pp. 381-393, 1998",
                "M. Trabalza-Marinucci, G. Brandi, C. Rondini, L. Avellini, C. Giammarini, \"A three-year longitudinal study on the effects of a diet containing genetically modified Bt176 maize on the health status and performance of sheep\", Livest Sci, vol. 113, pp. 178-190, 2008",
                "K. Adel-Patient, V. D. Guimaraes, A. Paris, M. -. F. Drumare, S. Ah-Leung, \"Immunological and metabolomic impacts of administration of Cry1Ab protein and MON 810 maize in mouse\", PLoS ONE, vol. 6, pp. e16346, 2011",
                "H. Takeshita, K. Mogi, T. Yasuda, T. Nakajima, Y. Nakashima, \"Mammalian deoxyribonucleases I are classified into three types: pancreas, parotid, and pancreas-parotid (mixed), based on differences in their tissue concentrations\", Biochem Biophys Res Commun, vol. 269, pp. 481-484, 2000",
                "R. Einspanier, A. Klotz, J. Kraft, K. Aulrich, R. Poser, \"The fate of forage plant DNA in farm animals: a collaborative case-study investigating cattle and chicken fed recombinant plant material\", Eur Food Res Technol, vol. 212, pp. 129-134, 2001",
                "R. Mazza, M. Soave, M. Morlacchini, G. Piva, A. Marocco, \"Assessing the transfer of genetically modified DNA from feed to animal tissues\", Transgenic Res, vol. 14, pp. 775-784, 2005",
                "J. K. Patterson, X. G. Lei, D. D. Miller, \"The pig as an experimental model for elucidating the mechanisms governing dietary influence on mineral absorption\", Exp Biol Med, vol. 233, pp. 651-664, 2008",
                "S. B. Lehrer, S. McClain, \"Utility of animal models for predicting human allergenicity\", Regul Toxicol Pharmacol, vol. 54, pp. S46-S51, 2009",
                "M. Bailey, \"The mucosal immune system: Recent developments and future directions in the pig\", Dev Comp Immunol, vol. 33, pp. 375-383, 2009",
                "H. -. J. Rothktter, \"Anatomical particularities of the porcine immune system - A physician's view\", Dev Comp Immunol, vol. 33, pp. 267-272, 2009" } } };
    }

    @Test(dataProvider = "expectedCrossRefSeaches")
    public void testCrossRefQueryBuilder(String[] searches) throws Exception {
        Document article = DocumentBuilderFactoryCreator.createFactory().newDocumentBuilder()
                .parse(new File(ClassLoader.getSystemResource("articles/pone.0047851.xml").toURI()));

        CrossRefLookupServiceImpl service = new CrossRefLookupServiceImpl();
        CrossRefSearch crossRefSearches[] = service.getCrossRefSearchTerms(article);

        assertEquals(crossRefSearches.length, searches.length);

        String[] results = new String[crossRefSearches.length];

        for (int a = 0; a < crossRefSearches.length; a++) {
            results[a] = crossRefSearches[a].buildQuery();
        }

        assertEqualsNoOrder(results, searches);
    }

    @Test
    public void testFindArticles() throws Exception {
        CrossRefLookupServiceImpl service = new CrossRefLookupServiceImpl();

        HttpClientMock mockHttpClient = new HttpClientMock(200,
                "{ \"results\": [ { \"text\": \"Cope ED,Synopsis of the families of Vertebrata;American Naturalist;23;"
                        + "849-887\", \"match\": true, \"doi\": \"10.1086/275018\", \"score\": 2.6771188 } ], \"query_ok\": true }");
        service.setHttpClient(mockHttpClient);
        service.setCrossRefUrl("http://bleh.bleh");

        String doi = service.findDoi("Synopsis of the families of Vertebrata");
        assertEquals(doi, "10.1086/275018");
    }

    @Test
    public void testPunctuationCharacters() throws Exception {
        CrossRefLookupServiceImpl service = new CrossRefLookupServiceImpl();

        HttpClientMock mockHttpClient = new HttpClientMock(200,
                "{ \"results\": [ {  \"text\": \"Young GC,Placoderms (armored fish): dominant vertebrates of the "
                        + "Devonian Period;Annual Review of Earth and Planetary Sciences;38;523-550\", \"match\": true, \"doi\": "
                        + "\"10.1146/annurev-earth-040809-152507\", \"score\": \"4.767027\" } ], \"query_ok\": true }");
        service.setHttpClient(mockHttpClient);
        service.setCrossRefUrl("http://bleh.bleh");

        String doi = service.findDoi("Proc; Natl/ Acad? Sci: USA & Canada\n a = b");
        assertEquals(doi, "10.1146/annurev-earth-040809-152507");
    }
}