예제 #1
0
 public void test07() throws Exception {
   String scenarioName = "persons-deps-07";
   Scenario scenario =
       UtilityTest.loadScenarioFromResources(References.persons_deps_07_dbms, true);
   if (logger.isDebugEnabled()) logger.debug(scenario.toString());
   setConfigurationForTest(scenario);
   scenario.getCostManagerConfiguration().setType(LunaticConstants.COST_MANAGER_SIMILARITY);
   scenario.getCostManagerConfiguration().setDoPermutations(false);
   scenario.getConfiguration().setRemoveDuplicates(false);
   DeltaChaseStep result = ChaserFactory.getChaser(scenario).doChase(scenario);
   if (logger.isDebugEnabled()) logger.debug("Scenario " + scenarioName);
   if (logger.isDebugEnabled()) logger.debug(result.toStringWithSort());
   if (logger.isDebugEnabled())
     logger.debug("Number of solutions: " + resultSizer.getPotentialSolutions(result));
   if (logger.isDebugEnabled())
     logger.debug("Number of duplicate solutions: " + resultSizer.getDuplicates(result));
   Assert.assertEquals(1, resultSizer.getPotentialSolutions(result));
   checkSolutions(result);
   //        exportResults("/Temp/expected-" + scenarioName, result);
   checkExpectedSolutions("expected-" + scenarioName, result);
 }
 private EquivalenceClassForSymmetricEGD readNextEquivalenceClass(
     ITupleIterator it,
     Dependency egd,
     IDatabase deltaDB,
     String stepId,
     IChaseState chaseState,
     Scenario scenario) {
   if (!it.hasNext() && (this.lastTupleHandled || this.lastTuple == null)) {
     return null;
   }
   EquivalenceClassForSymmetricEGD equivalenceClass = createEquivalenceClass(egd);
   if (lastTuple != null && !this.lastTupleHandled) {
     if (logger.isDebugEnabled())
       logger.debug("Reading tuple : " + this.lastTuple.toStringWithOIDAndAlias());
     addTuple(
         this.lastTuple,
         equivalenceClass,
         scenario.getCostManagerConfiguration(),
         deltaDB,
         stepId,
         scenario);
     this.lastTupleHandled = true;
   }
   if (logger.isDebugEnabled()) logger.debug("Reading next equivalence class...");
   while (it.hasNext()) {
     if (chaseState.isCancelled())
       ChaseUtility.stopChase(
           chaseState); // throw new ChaseException("Chase interrupted by user");
     Tuple tuple = it.next();
     if (logger.isDebugEnabled())
       logger.debug("Reading tuple : " + tuple.toStringWithOIDAndAlias());
     if (lastTuple == null
         || equivalenceClass.isEmpty()
         || EquivalenceClassUtility.sameEquivalenceClass(tuple, this.lastTuple, egd)) {
       addTuple(
           tuple,
           equivalenceClass,
           scenario.getCostManagerConfiguration(),
           deltaDB,
           stepId,
           scenario);
       this.lastTuple = tuple;
       this.lastTupleHandled = true;
     } else {
       if (logger.isDebugEnabled()) logger.debug("Equivalence class is finished...");
       if (equivalenceClass.isEmpty()) {
         throw new IllegalArgumentException(
             "Unable to create equivalence class for egd:\n"
                 + egd
                 + "\nLast tuple: \n"
                 + lastTuple
                 + "\nCurrent tuple: \n"
                 + tuple);
       }
       this.lastTuple = tuple;
       this.lastTupleHandled = false;
       break;
     }
   }
   if (logger.isDebugEnabled()) logger.debug("Equivalence class loaded");
   if (logger.isDebugEnabled())
     logger.debug("-------- Equivalence class:\n" + equivalenceClass + "\n---------------");
   return equivalenceClass;
 }