use of org.ambraproject.rhino.service.impl.SolrIndexServiceImpl in project rhino by PLOS.
the class SolrIndexServiceTest method testPublication.
@Test(enabled = false)
public void testPublication() throws Exception {
Archive archive = Archive.readZipFileIntoMemory(new File(TEST_DATA_DIR + "pone.0056489.zip"));
// Article article = articleCrudService.writeArchive(archive,
// Optional.empty(), DoiBasedCrudService.WriteMode.CREATE_ONLY, OptionalInt.empty());
Article article = new Article();
ArticleIdentifier articleId = ArticleIdentifier.create(article.getDoi());
SolrIndexServiceImpl impl = (SolrIndexServiceImpl) solrIndexService;
DummyMessageSender dummySender = (DummyMessageSender) impl.messageSender;
assertEquals(dummySender.messagesSent.size(), 5);
List<String> solrMessages = dummySender.messagesSent.get("activemq:fake.indexing.queue");
assertEquals(solrMessages.size(), 1);
XMLUnit.compareXML(IOUtils.toString(new FileInputStream(TEST_DATA_DIR + "pone.0056489_solr_decorated.xml")), solrMessages.get(0));
String expectedSyndication = "<ambraMessage><doi>info:doi/10.1371/journal.pone.0056489</doi><archive>pone.0056489.zip</archive></ambraMessage>";
List<String> crossRefMessages = dummySender.messagesSent.get("activemq:fake.crossref.queue");
assertEquals(crossRefMessages.size(), 1);
XMLUnit.compareXML(expectedSyndication, crossRefMessages.get(0));
List<String> pmcMessages = dummySender.messagesSent.get("activemq:fake.pmc.queue");
assertEquals(pmcMessages.size(), 1);
XMLUnit.compareXML(expectedSyndication, pmcMessages.get(0));
List<String> pubmedMessages = dummySender.messagesSent.get("activemq:fake.pubmed.queue");
assertEquals(pubmedMessages.size(), 1);
XMLUnit.compareXML(expectedSyndication, pubmedMessages.get(0));
solrIndexService.removeSolrIndex(articleId);
assertEquals(dummySender.messagesSent.size(), 6);
List<String> deletionMessages = dummySender.messagesSent.get("activemq:fake.delete.queue");
assertEquals(deletionMessages.size(), 1);
assertEquals(deletionMessages.get(0), article.getDoi());
}
Aggregations