MongoReader extends BaleenCollectionReader { @Override public boolean doHasNext() throws IOException, CollectionException { getNewIds(); return !queue.isEmpty(); }  @Override boolean doHasNext(); static final String KEY_MONGO; static final String PARAM_COLLECTION; static final String PARAM_ID_FIELD; static final String PARAM_CONTENT_FIELD; static final String PARAM_DELETE_SOURCE; }
@Test public void test() throws Exception { BaleenCollectionReader bcr = getCollectionReader( MONGO, erd, "collection", COLLECTION, "idField", "_id", "contentField", CONTENT, "contentExtractor", "PlainTextContentExtractor"); bcr.initialize(); SharedFongoResource sfr = (SharedFongoResource) bcr.getUimaContext().getResourceObject(MONGO); createContent(sfr); assertTrue(bcr.doHasNext()); bcr.getNext(jCas); assertEquals("Hello World", jCas.getDocumentText().trim()); assertEquals(1, JCasUtil.select(jCas, Metadata.class).size()); jCas.reset(); assertTrue(bcr.doHasNext()); bcr.getNext(jCas); assertEquals("Hello Test", jCas.getDocumentText().trim()); assertEquals(1, JCasUtil.select(jCas, Metadata.class).size()); jCas.reset(); assertTrue(bcr.doHasNext()); bcr.getNext(jCas); assertEquals(TEXT, jCas.getDocumentText().trim()); assertEquals(5, JCasUtil.select(jCas, Metadata.class).size()); List<Metadata> metadata = JCasUtil.select(jCas, Metadata.class).stream() .filter(m -> !m.getKey().equalsIgnoreCase("baleen:content-extractor")) .sorted((a, b) -> a.getKey().compareTo(b.getKey())) .collect(Collectors.toList()); assertEquals("key1", metadata.get(0).getKey()); assertEquals("key2", metadata.get(1).getKey()); assertEquals("key3", metadata.get(2).getKey()); assertEquals("key3", metadata.get(3).getKey()); assertEquals("foo", metadata.get(0).getValue()); assertEquals("bar", metadata.get(1).getValue()); assertEquals("howdy", metadata.get(2).getValue()); assertEquals("hey", metadata.get(3).getValue()); jCas.reset(); assertFalse(bcr.doHasNext()); bcr.close(); }