PubMedXMLFetcher { public Collection<BibliographicReference> retrieveByHTTP( Collection<Integer> pubMedIds ) throws IOException { StringBuilder buf = new StringBuilder(); for ( Integer integer : pubMedIds ) { buf.append( integer ).append( "," ); } URL toBeGotten = new URL( uri + StringUtils.chomp( buf.toString() ) ); log.debug( "Fetching " + toBeGotten ); PubMedXMLParser pmxp = new PubMedXMLParser(); return pmxp.parse( toBeGotten.openStream() ); } PubMedXMLFetcher(); Collection<BibliographicReference> retrieveByHTTP( Collection<Integer> pubMedIds ); BibliographicReference retrieveByHTTP( int pubMedId );  }
@Test public final void testRetrieveByHTTP() { try { BibliographicReference br = pmf.retrieveByHTTP( 15173114 ); assertNotNull( br ); assertEquals( "Lee, Homin K; Hsu, Amy K; Sajdak, Jon; Qin, Jie; Pavlidis, Paul", br.getAuthorList() ); assertEquals( "Genome Res", br.getPublication() ); assertEquals( "Coexpression analysis of human genes across many microarray data sets.", br.getTitle() ); SimpleDateFormat f = new SimpleDateFormat( "mm/HH/MM/dd/yyyy" ); assertEquals( "00/00/06/01/2004", f.format( br.getPublicationDate() ) ); } catch ( RuntimeException e ) { this.checkCause( e ); } }
@Test public final void testRetrieveByHTTP2() { try { BibliographicReference br = pmf.retrieveByHTTP( 24850731 ); assertNotNull( br ); assertEquals( "Iwata-Yoshikawa, Naoko; Uda, Akihiko; Suzuki, Tadaki; Tsunetsugu-Yokota, Yasuko; Sato, Yuko; " + "Morikawa, Shigeru; Tashiro, Masato; Sata, Tetsutaro; Hasegawa, Hideki; Nagata, Noriyo", br.getAuthorList() ); assertEquals( "J Virol", br.getPublication() ); } catch ( RuntimeException e ) { this.checkCause( e ); } }
@Test public final void testRetrieveByHTTPBookshelf() { try { BibliographicReference br = pmf.retrieveByHTTP( 23865096 ); assertNotNull( br ); assertEquals( "Tatton-Brown, Katrina; Rahman, Nazneen", br.getAuthorList() ); assertEquals( "GeneReviews", br.getPublication().substring( 0, "GeneReviews".length() ) ); assertEquals( "EZH2-Related Overgrowth", br.getTitle() ); SimpleDateFormat f = new SimpleDateFormat( "yyyy" ); assertEquals( "2013", f.format( br.getPublicationDate() ) ); } catch ( RuntimeException e ) { this.checkCause( e ); } }
@Test public final void testRetrieveByHTTPNotFound() { try { BibliographicReference br = pmf.retrieveByHTTP( 1517311444 ); assertNull( br ); } catch ( RuntimeException e ) { this.checkCause( e ); } }