GoogleMetadata { public List<String> getPDFURL() { return metadataMappings.get(PDF); } GoogleMetadata(Context context, Item item); static void logConfiguration(); Collection<Entry<String, String>> getMappings(); List<Element> disseminateList(); List<String> getTitle(); List<String> getJournalTitle(); List<String> getPublisher(); List<String> getAuthors(); List<String> getDate(); List<String> getVolume(); List<String> getIssue(); List<String> getFirstpage(); List<String> getLastpage(); List<String> getDOI(); List<String> getPmid(); List<String> getAbstractHTMLURL(); List<String> getFulltextHTMLURL(); List<String> getPDFURL(); List<String> getISSN(); List<String> getISBN(); List<String> getLanguage(); List<String> getKeywords(); List<String> getConference(); List<String> getDissertationName(); List<String> getDissertationInstitution(); List<String> getPatentNumber(); List<String> getPatentCountry(); List<String> getTechnicalReportNumber(); List<String> getTechnicalReportInstitution();  }
@Test public void testGetPDFURLWithUndefinedMimeTypes() throws Exception { context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL");; Bitstream b = bitstreamService.create(context, new ByteArrayInputStream("12".getBytes(Charsets.UTF_8))); b.setName(context, "small"); b.setFormat(context, bitstreamFormatService.create(context)); b.getFormat(context).setMIMEType("unknown type 1"); bundleService.addBitstream(context, bundle, b); Bitstream b2 = bitstreamService.create(context, new ByteArrayInputStream("12121212".getBytes(Charsets.UTF_8))); b2.setName(context, "medium"); b2.setFormat(context, bitstreamFormatService.create(context)); b2.getFormat(context).setMIMEType("unknown type 2"); bundleService.addBitstream(context, bundle, b2); Bitstream b3 = bitstreamService.create(context, new ByteArrayInputStream("12121212121212".getBytes(Charsets.UTF_8))); b3.setName(context, "large"); b3.setFormat(context, bitstreamFormatService.create(context)); b3.getFormat(context).setMIMEType("unknown type 3"); bundleService.addBitstream(context, bundle, b3); context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); String[] urlSplitted = gm.getPDFURL().get(0).split("/"); assertEquals("large", urlSplitted[urlSplitted.length - 1]); }
@Test public void testGetPDFURLWithNoBitstreams() throws Exception { context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL");; context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); assertEquals(0, gm.getPDFURL().size()); }
@Test public void testGetPDFURLWithEmptyBitstreams() throws Exception{ context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL");; Bitstream b = bitstreamService.create(context, new ByteArrayInputStream("".getBytes(Charsets.UTF_8))); b.setName(context,"small"); b.setFormat(context, bitstreamFormatService.create(context)); b.getFormat(context).setMIMEType("unknown type 1"); bundleService.addBitstream(context, bundle, b); Bitstream b2 = bitstreamService.create(context, new ByteArrayInputStream("".getBytes(Charsets.UTF_8))); b2.setName(context, "medium"); b2.setFormat(context, bitstreamFormatService.create(context)); b2.getFormat(context).setMIMEType("unknown type 2"); bundleService.addBitstream(context, bundle, b2); Bitstream b3 = bitstreamService.create(context, new ByteArrayInputStream("".getBytes(Charsets.UTF_8))); b3.setName(context, "large"); b3.setFormat(context, bitstreamFormatService.create(context)); b3.getFormat(context).setMIMEType("unknown type 3"); bundleService.addBitstream(context, bundle, b3); context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); String[] urlSplitted = gm.getPDFURL().get(0).split("/"); assertEquals("small", urlSplitted[urlSplitted.length - 1]); }
@Test public void testGetPDFURLDifferentMimeTypes() throws Exception { context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL"); Bitstream b = bitstreamService.create(context, new ByteArrayInputStream("Bitstream 1".getBytes(Charsets.UTF_8))); b.setName(context, "Word"); b.setFormat(context, bitstreamFormatService.create(context)); b.getFormat(context).setMIMEType("application/msword"); bundleService.addBitstream(context, bundle, b); Bitstream b2 = bitstreamService.create(context, new ByteArrayInputStream("Bitstream 2".getBytes(Charsets.UTF_8))); b2.setName(context, "Pdf"); b2.setFormat(context, bitstreamFormatService.create(context)); b2.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b2); Bitstream b3 = bitstreamService.create(context, new ByteArrayInputStream("Bitstream 3".getBytes(Charsets.UTF_8))); b3.setName(context, "Rtf"); b3.setFormat(context, bitstreamFormatService.create(context)); b3.getFormat(context).setMIMEType("text/richtext"); bundleService.addBitstream(context, bundle, b3); context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); String[] urlSplitted = gm.getPDFURL().get(0).split("/"); assertEquals("Pdf", urlSplitted[urlSplitted.length - 1]); }
@Test public void testGetPDFURLSameMimeTypes() throws Exception { context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL");; Bitstream b = bitstreamService.create(context, new ByteArrayInputStream("123456789".getBytes(Charsets.UTF_8))); b.setName(context, "size9"); b.setFormat(context, bitstreamFormatService.create(context)); b.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b); Bitstream b2 = bitstreamService.create(context, new ByteArrayInputStream("1".getBytes(Charsets.UTF_8))); b2.setName(context, "size1"); b2.setFormat(context, bitstreamFormatService.create(context)); b2.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b2); Bitstream b3 = bitstreamService.create(context, new ByteArrayInputStream("12345".getBytes(Charsets.UTF_8))); b3.setName(context, "size5"); b3.setFormat(context, bitstreamFormatService.create(context)); b3.getFormat(context).setMIMEType("text/richtext"); bundleService.addBitstream(context, bundle, b3); context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); String[] urlSplitted = gm.getPDFURL().get(0).split("/"); assertEquals("size9", urlSplitted[urlSplitted.length - 1]); }
@Test public void testGetPDFURLSameMimeTypesSameSize() throws Exception { context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL");; Bitstream b = bitstreamService.create(context, new ByteArrayInputStream("1".getBytes(Charsets.UTF_8))); b.setName(context, "first"); b.setFormat(context, bitstreamFormatService.create(context)); b.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b); Bitstream b2 = bitstreamService.create(context, new ByteArrayInputStream("1".getBytes(Charsets.UTF_8))); b2.setName(context, "second"); b2.setFormat(context, bitstreamFormatService.create(context)); b2.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b2); Bitstream b3 = bitstreamService.create(context, new ByteArrayInputStream("1".getBytes(Charsets.UTF_8))); b3.setName(context, "third"); b3.setFormat(context, bitstreamFormatService.create(context)); b3.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b3); context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); String[] urlSplitted = gm.getPDFURL().get(0).split("/"); assertEquals("first", urlSplitted[urlSplitted.length - 1]); }
@Test public void testGetPDFURLWithPrimaryBitstream() throws Exception { context.turnOffAuthorisationSystem(); Bundle bundle = ContentServiceFactory.getInstance().getBundleService().create(context, it, "ORIGINAL");; Bitstream b = bitstreamService.create(context, new ByteArrayInputStream("Larger file than primary".getBytes(Charsets.UTF_8))); b.setName(context, "first"); b.setFormat(context, bitstreamFormatService.create(context)); b.getFormat(context).setMIMEType("unknown"); bundleService.addBitstream(context, bundle, b); Bitstream b2 = bitstreamService.create(context, new ByteArrayInputStream("Bitstream with more prioritized mimetype than primary".getBytes(Charsets.UTF_8))); b2.setName(context, "second"); b2.setFormat(context, bitstreamFormatService.create(context)); b2.getFormat(context).setMIMEType("application/pdf"); bundleService.addBitstream(context, bundle, b2); Bitstream b3 = bitstreamService.create(context, new ByteArrayInputStream("1".getBytes(Charsets.UTF_8))); b3.setName(context, "primary"); b3.setFormat(context, bitstreamFormatService.create(context)); b3.getFormat(context).setMIMEType("Primary"); bundleService.addBitstream(context, bundle, b3); bundle.setPrimaryBitstreamID(b3); context.restoreAuthSystemState(); context.commit(); GoogleMetadata gm = new GoogleMetadata(this.context, it); String[] urlSplitted = gm.getPDFURL().get(0).split("/"); assertEquals("primary", urlSplitted[urlSplitted.length - 1]); }