mac-op commented on code in PR #22:
URL: https://github.com/apache/uima-uimacpp/pull/22#discussion_r1661992834


##########
src/test/src/test_engine.cpp:
##########
@@ -519,8 +519,108 @@ void testCasMultiplier(uima::util::ConsoleUI & rclConsole)
 }
 
 
+/* For now, aggregate engines do not handle CAS Multipliers correctly.
+   This test will fail if ran.
+   TODO: Implement CAS Multiplier for Aggregate
+ */
+void testAggregateCASMultiplier(const util::ConsoleUI &rclConsole)
+{
+  rclConsole.info("Test Aggregate CAS Multiplier start.");
+  const icu::UnicodeString descriptor("AggregateCASMultiplier.xml");
+  const icu::UnicodeString fileName = 
ResourceManager::resolveFilename(descriptor, descriptor);
+  ErrorInfo err;
+  auto pEngine = 
TextAnalysisEngine::createTextAnalysisEngine(UnicodeStringRef(fileName).asUTF8().c_str(),
 err);
+
+  failIfNotTrue(err.getErrorId() == UIMA_ERR_NONE);
+  failIfNotTrue(pEngine != nullptr);
+
+  //test operational properties settings
+  
failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->getOutputsNewCASes()
 == true);
+  
failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->getModifiesCas()
 == false);
+  
failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->isMultipleDeploymentAllowed()
 == true);
+
+  auto const cas = pEngine->newCAS();
+  cas->setDocumentText(icu::UnicodeString(
+    "This is a sentence with Dave. This is the second sentence with Dave. This 
is the third Dave sentence."));
+  Type dave = cas->getTypeSystem().getType("org.apache.uima.examples.David");
+
+  CASIterator iter = pEngine->processAndOutputNewCASes(*cas);
+  failIfNotTrue(iter.hasNext());
+  int numSegments = 0;
+
+  while (iter.hasNext()) {
+    ++numSegments;
+    CAS &rcas = iter.next();
+    ANIndex anIndex = rcas.getAnnotationIndex(dave);
+
+    // There should be one Dave in each segment
+    failIfNotTrue(anIndex.getSize() == 1);
+    pEngine->getAnnotatorContext().releaseCAS(rcas);
+  }
+
+  failIfNotTrue(numSegments == 3);
+  delete cas;
+  delete pEngine;
+
+  rclConsole.info("Test Aggregate CAS Multiplier end.");
+}
 
 
+/*
+ * This will also not work
+ */
+void testAggregateCASCombiner(const util::ConsoleUI &rclConsole)
+{
+  rclConsole.info("Test Aggregate CAS Combiner start.");
+  const icu::UnicodeString descriptor("SegmentAnnotateMerge.xml");
+  const icu::UnicodeString fileName = 
ResourceManager::resolveFilename(descriptor, descriptor);
+  ErrorInfo err;
+  auto pEngine = 
TextAnalysisEngine::createTextAnalysisEngine(UnicodeStringRef(fileName).asUTF8().c_str(),
 err);
+
+  failIfNotTrue(err.getErrorId() == UIMA_ERR_NONE);
+  failIfNotTrue(pEngine != nullptr);
+
+  //test operational properties settings
+  
failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->getOutputsNewCASes()
 == true);
+  
failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->getModifiesCas()
 == true);
+  
failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->isMultipleDeploymentAllowed()
 == true);
+
+  auto const cas = pEngine->newCAS();
+  cas->setDocumentText(icu::UnicodeString(
+    "First segment. Second segment. Third segment. Fourth segment."));
+  Type token = cas->getTypeSystem().getType("uima.tt.TokenAnnotation");
+  Type srcDocInfo = 
cas->getTypeSystem().getType("uima.tt.SourceDocumentInformation");
+  Feature lastSegment = srcDocInfo.getFeatureByBaseName("lastSegment");
+
+  CASIterator iter = pEngine->processAndOutputNewCASes(*cas);
+  failIfNotTrue(iter.hasNext());
+  int numOutputs = 0;
+
+  while (iter.hasNext()) {

Review Comment:
   @DrDub You were right about [the 
spec](https://uima.apache.org/d/uimaj-current/tug.html#ugr.tug.cm.cm_and_fc) 
that I missed and the default behavior without a Custom Control Flow is `if the 
CAS Multiplier does not produce any output CASes for a given input CAS, then 
that input CAS will continue in the flow.` So this test case is incorrect and 
we should expect 4 output CASes instead of 2.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@uima.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to