@BeforeClass public static void before() throws Exception { conn = getTestConn("MongoTest"); // write one test document into Mongo JCas jCas = UimaTests.getTokenizedTestCas(); BiolexiconDictTerm b = new BiolexiconDictTerm(jCas, 0, 11); b.setEntityId("theId"); b.addToIndexes(); Header h = new Header(jCas); h.setDocId("17"); h.addToIndexes(); JcasPipelineBuilder p = new JcasPipelineBuilder(jCas); p.add(MongoWriter.class, BlueUima.PARAM_DB_CONNECTION, conn); p.process(); }
@Test public void testRead() throws Exception { // read List<JCas> l = asList(createReader(MongoCollectionReader.class, BlueUima.PARAM_DB_CONNECTION, conn)); assertEquals(1, l.size()); JCas jCas = l.get(0); assertEquals(UimaTests.TEST_SENTENCE, jCas.getDocumentText()); for (Annotation a : JCasUtil.select(jCas, Annotation.class)) { System.out.println(a); } BiolexiconDictTerm b = selectSingle(jCas, BiolexiconDictTerm.class); assertNotNull(b); assertEquals("theId", b.getEntityId()); Header h = selectSingle(jCas, Header.class); assertNotNull(h); assertEquals("17", h.getDocId()); }