@Test public void pickDocument_WITH_RESEARCH_ARTICLE() throws Exception { DocumentMetadata firstDocument = new DocumentMetadata("id-1", null, null, Lists.newArrayList()); DocumentMetadata secondDocument = new DocumentMetadata("id-2", null, "research-article", Lists.newArrayList()); DocumentMetadata thirdDocument = new DocumentMetadata("id-3", null, null, Lists.newArrayList()); Iterable<DocumentMetadata> documents = Lists.newArrayList(firstDocument, secondDocument, thirdDocument); DocumentMetadata retDocument = documentPickFunction.call(documents); assertEquals(secondDocument, retDocument); }
@Override public DocumentMetadata call(Iterable<DocumentMetadata> documents) throws Exception { Iterator<DocumentMetadata> it = documents.iterator(); DocumentMetadata current = null; while(it.hasNext()) { DocumentMetadata docMeta = it.next(); if (StringUtils.equals(docMeta.getPublicationTypeName(), "research-article")) { return docMeta; } current = docMeta; } return current; }
PickResearchArticleDocumentFunction implements Function<Iterable<DocumentMetadata>, DocumentMetadata> { @Override public DocumentMetadata call(Iterable<DocumentMetadata> documents) throws Exception { Iterator<DocumentMetadata> it = documents.iterator(); DocumentMetadata current = null; while(it.hasNext()) { DocumentMetadata docMeta = it.next(); if (StringUtils.equals(docMeta.getPublicationTypeName(), "research-article")) { return docMeta; } current = docMeta; } return current; } }
PickResearchArticleDocumentFunction implements Function<Iterable<DocumentMetadata>, DocumentMetadata> { @Override public DocumentMetadata call(Iterable<DocumentMetadata> documents) throws Exception { Iterator<DocumentMetadata> it = documents.iterator(); DocumentMetadata current = null; while(it.hasNext()) { DocumentMetadata docMeta = it.next(); if (StringUtils.equals(docMeta.getPublicationTypeName(), "research-article")) { return docMeta; } current = docMeta; } return current; }  }
PickResearchArticleDocumentFunction implements Function<Iterable<DocumentMetadata>, DocumentMetadata> { @Override public DocumentMetadata call(Iterable<DocumentMetadata> documents) throws Exception { Iterator<DocumentMetadata> it = documents.iterator(); DocumentMetadata current = null; while(it.hasNext()) { DocumentMetadata docMeta = it.next(); if (StringUtils.equals(docMeta.getPublicationTypeName(), "research-article")) { return docMeta; } current = docMeta; } return current; }  @Override DocumentMetadata call(Iterable<DocumentMetadata> documents); }
PickResearchArticleDocumentFunction implements Function<Iterable<DocumentMetadata>, DocumentMetadata> { @Override public DocumentMetadata call(Iterable<DocumentMetadata> documents) throws Exception { Iterator<DocumentMetadata> it = documents.iterator(); DocumentMetadata current = null; while(it.hasNext()) { DocumentMetadata docMeta = it.next(); if (StringUtils.equals(docMeta.getPublicationTypeName(), "research-article")) { return docMeta; } current = docMeta; } return current; }  @Override DocumentMetadata call(Iterable<DocumentMetadata> documents);  }