public static DocumentList wrap(Iterator<ODocument> docs) { DocumentList list = new DocumentList(); while (docs.hasNext()) { ODocument next = docs.next(); list.add(DBUtil.documentToModel(next)); } return list; }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList dl = new DocumentList(); Map<?, ?> config = (Map<?, ?>) model.get("config"); String tagPath = config.get(TAG_PATH.replace(".", "_")).toString(); for (String tag : db.getAllTags()) { Map<String, Object> newTag = new HashMap<>(); String tagName = tag; newTag.put("name", tagName); String uri = tagPath + FileUtil.URI_SEPARATOR_CHAR + tag + config.get(OUTPUT_EXTENSION.replace(".", "_")).toString(); newTag.put("uri", uri); newTag.put("tagged_posts", db.getPublishedPostsByTag(tagName)); newTag.put("tagged_documents", db.getPublishedDocumentsByTag(tagName)); dl.push(newTag); } return dl; }
@Override public DocumentList get(ContentStore db, Map model, String key) { // document types are pluralized in model, so unpluralize try { String type = DocumentTypeUtils.unpluralize(key); return db.getAllContent(type); } catch (UnsupportedOperationException e) { return new DocumentList(); } }
public DocumentList getPublishedDocumentsByTag(String tag) { final DocumentList documents = new DocumentList(); for (final String docType : DocumentTypes.getDocumentTypes()) { String statement = String.format(STATEMENT_GET_PUBLISHED_POST_BY_TYPE_AND_TAG, docType); DocumentList documentsByTag = query(statement, tag); documents.addAll(documentsByTag); } return documents; }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList publishedContent = new DocumentList(); String[] documentTypes = DocumentTypes.getDocumentTypes(); for (String docType : documentTypes) { DocumentList query = db.getPublishedContent(docType); publishedContent.addAll(query); } return publishedContent; }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList allContent = new DocumentList(); String[] documentTypes = DocumentTypes.getDocumentTypes(); for (String docType : documentTypes) { DocumentList query = db.getAllContent(docType); allContent.addAll(query); } return allContent; }
@Before public void setUp() { MockitoAnnotations.initMocks(this); documentsRenderer = new DocumentsRenderer(); db = mock(ContentStore.class); renderer = mock(Renderer.class); configuration = mock(JBakeConfiguration.class); emptyDocumentList = new DocumentList(); }
@Test public void shouldReturnCountOfProcessedDocuments() throws Exception { // given: DocumentTypes.addDocumentType("customType"); DocumentList documentList = new DocumentList(); documentList.add(emptyDocument()); documentList.add(emptyDocument()); // return empty DocumentList independent from DocumentType when(db.getUnrenderedContent(anyString())).thenReturn(emptyDocumentList); // return given DocumentList for DocumentType 'custom type' when(db.getUnrenderedContent("customType")).thenReturn(documentList); // when: int renderResponse = documentsRenderer.render(renderer, db, configuration); // then: assertThat(renderResponse).isEqualTo(2); }
@Test public void shouldThrowAnExceptionWithCollectedErrorMessages() throws Exception { String fakeExceptionMessage = "fake exception"; // expect exception.expect(RenderingException.class); exception.expectMessage(fakeExceptionMessage + "\n" + fakeExceptionMessage); // given DocumentTypes.addDocumentType("customType"); DocumentList documentList = new DocumentList(); HashMap<String, Object> document = emptyDocument(); HashMap<String, Object> document2 = emptyDocument(); documentList.add(document); documentList.add(document2); // throw an exception for every call of renderer's render method doThrow(new Exception(fakeExceptionMessage)).when(renderer).render(ArgumentMatchers.<String, Object>anyMap()); when(db.getUnrenderedContent(anyString())).thenReturn(emptyDocumentList); when(db.getUnrenderedContent("customType")).thenReturn(documentList); // when int renderResponse = documentsRenderer.render(renderer, db, configuration); // then assertThat(renderResponse).isEqualTo(2); }
String fourth = "Fourth Document"; DocumentList documents = new DocumentList(); documents.add(simpleDocument(fourth)); documents.add(simpleDocument(third));
import com.google.gdata.data.docs.DocumentListEntry; import com.google.gdata.data.docs.DocumentListFeed; public class Example { static public void main(String[] args) throws Exception { DocumentList docList = new DocumentList("document"); docList.login("********@gmail.com", "********"); DocumentListFeed feed = docList.getDocsListFeed("all"); for (final DocumentListEntry entry : feed.getEntries()) { System.out.println(entry.getTitle().getPlainText()); } } }
public static DocumentList wrap(Iterator<ODocument> docs) { DocumentList list = new DocumentList(); while (docs.hasNext()) { ODocument next = docs.next(); list.add(DBUtil.documentToModel(next)); } return list; }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList dl = new DocumentList(); Map<?, ?> config = (Map<?, ?>) model.get("config"); String tagPath = config.get(TAG_PATH.replace(".", "_")).toString(); for (String tag : db.getAllTags()) { Map<String, Object> newTag = new HashMap<>(); String tagName = tag; newTag.put("name", tagName); String uri = tagPath + FileUtil.URI_SEPARATOR_CHAR + tag + config.get(OUTPUT_EXTENSION.replace(".", "_")).toString(); newTag.put("uri", uri); newTag.put("tagged_posts", db.getPublishedPostsByTag(tagName)); newTag.put("tagged_documents", db.getPublishedDocumentsByTag(tagName)); dl.push(newTag); } return dl; }
@Override public DocumentList get(ContentStore db, Map model, String key) { // document types are pluralized in model, so unpluralize try { String type = DocumentTypeUtils.unpluralize(key); return db.getAllContent(type); } catch (UnsupportedOperationException e) { return new DocumentList(); } }
public DocumentList getPublishedDocumentsByTag(String tag) { final DocumentList documents = new DocumentList(); for (final String docType : DocumentTypes.getDocumentTypes()) { String statement = String.format(STATEMENT_GET_PUBLISHED_POST_BY_TYPE_AND_TAG, docType); DocumentList documentsByTag = query(statement, tag); documents.addAll(documentsByTag); } return documents; }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList publishedContent = new DocumentList(); String[] documentTypes = DocumentTypes.getDocumentTypes(); for (String docType : documentTypes) { DocumentList query = db.getPublishedContent(docType); publishedContent.addAll(query); } return publishedContent; }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList allContent = new DocumentList(); String[] documentTypes = DocumentTypes.getDocumentTypes(); for (String docType : documentTypes) { DocumentList query = db.getAllContent(docType); allContent.addAll(query); } return allContent; }