private void createContent(SharedFongoResource sfr) { MongoDatabase db = sfr.getDB(); MongoCollection<Document> coll = db.getCollection(COLLECTION); coll.insertMany( Arrays.asList( new Document(CONTENT, "Hello World"), new Document(CONTENT, "Hello Test"), new Document(CONTENT, TEXT) .append("key1", "foo") .append("key2", "bar") .append("key3", Arrays.asList("howdy", "hey")))); } }
@BeforeClass public static void beforeClass() throws ResourceInitializationException { sfr = new SharedFongoResource(); MongoDatabase db = sfr.getDB(); MongoCollection<Document> coll = db.getCollection("gazetteer"); coll.insertMany( Arrays.asList( new Document(VALUE, EN_HELLO2), new Document(VALUE, Arrays.asList("hi", EN_HELLO, "heya")), new Document(VALUE, Arrays.asList("konnichiwa", JP_HELLO)).append(LANGUAGE, "jp"), new Document(VALUE, Arrays.asList(DE_HELLO)) .append(LANGUAGE, "de") .append(TRANSLATION, "good day"), new Document(VALUE, Arrays.asList("hej")).append(LANGUAGE, "se"))); }
@Before public void setUp() throws ResourceInitializationException { fongo = new SharedFongoResource(); history = new MongoHistory(fongo); history.initialize(new CustomResourceSpecifier_impl(), Maps.newHashMap()); history.afterResourcesInitialized(); }
fongo.getDatabase(BALEEN).getCollection(fongoCollection).insertOne(data); } else { getMonitor().error("Unsupported type"); throw new ResourceInitializationException();
@Before public void beforeMongoRecordConsumerTest() throws ResourceInitializationException, ResourceAccessException { mongoExternalResourceDescription = ExternalResourceFactory.createExternalResourceDescription( MONGO, SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]"); analysisEngine = getAnalysisEngine("mongo", mongoExternalResourceDescription, "collection", "test"); SharedFongoResource sfr = (SharedFongoResource) analysisEngine.getUimaContext().getResourceObject(MONGO); recordsCollection = sfr.getDB().getCollection("records"); }
@Test public void test() throws ResourceInitializationException, AnalysisEngineProcessException, IOException, ResourceAccessException { final File file = File.createTempFile("test", "uimt"); Files.asCharSink(file, StandardCharsets.UTF_8) .write("Type,SubType\nMOVEMENT,went,source,target,went,VERB,gone"); final AnalysisEngine ae = create(UploadInteractionsToMongo.class, "mongo", fongoErd, "input", file); execute(ae); final SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject("mongo"); final MongoCollection<Document> relationTypes = sfr.getDB().getCollection("relationTypes"); assertTrue(relationTypes.count() > 0); final MongoCollection<Document> interactions = sfr.getDB().getCollection("interactions"); assertTrue(interactions.count() > 0); } }
private void createAnalysisEngine(String textBlockType) throws ResourceInitializationException, ResourceAccessException { AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription( MongoEvents.class, MONGO, erd, "collection", "test", MongoEvents.PARAM_TEXT_BLOCK_EXTRACTED_FROM, textBlockType, MongoEvents.PARAM_OUTPUT_HISTORY, true); ae = AnalysisEngineFactory.createEngine(aed); ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); events = sfr.getDB().getCollection("test"); assertEquals(0L, events.count()); } }
@Before public void setUp() throws ResourceInitializationException, ResourceAccessException { // Create a description of an external resource - a fongo instance, in the same way we would // have created a shared mongo resource ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription( MONGO, SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]"); // Create the analysis engine AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription( MongoRelations.class, MONGO, erd, "collection", "test"); ae = AnalysisEngineFactory.createEngine(aed); ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); relations = sfr.getDB().getCollection("test"); // Ensure we start with no data! assertEquals(0L, relations.count()); }
@Test public void testMalformedDocuments() { MongoCollection<Document> collection = fongo.getDB().getCollection(HISTORY2);
(SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); final MongoDatabase db = sfr.getDB(); documentCollection = db.getCollection(Mongo.DEFAULT_DOCUMENTS_COLLECTION); entityCollection = db.getCollection(Mongo.DEFAULT_ENTITY_COLLECTION);
facts = sfr.getDB().getCollection(RENOUN_FACTS);
try { sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); output = sfr.getDB().getCollection("renoun_patterns"); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e);
final MongoCollection<Document> collection = sfr.getDB().getCollection("test"); Assert.assertEquals(1, collection.count());
final MongoCollection<Document> collection = sfr.getDB().getCollection("test"); Assert.assertEquals(1, collection.count());