@Override public void run() { String changedTable = MutationAnalysisUtils.computeChangedTable(schema, mutant); updateChangedTableMap(id, changedTable); MutationAnalysisUtils.renameChangedTable(mutant, id, changedTable); MutationAnalysisUtils.renameMutantConstraints("mutant_" + id + "_", mutant); }
@Override public AnalysisResult analyse(TestSuiteResult originalResults) { // Get normal results AnalysisResult result = new AnalysisResult(); // Build map of changed tables this.changedTableMap = new HashMap<>(); executor = Executors.newFixedThreadPool(4); for (int id = 0; id < mutants.size(); id++) { Mutant<Schema> mutant = mutants.get(id); executor.submit(new ChangedTableTask(changedTableMap, id, mutant)); } executor.shutdown(); try { executor.awaitTermination(1, TimeUnit.DAYS); } catch (InterruptedException ex) { throw new RuntimeException(ex); } // Build the meta-mutant schema and SQL statements Schema metamutant = MutationAnalysisUtils.mergeMutantsParallel(schema, mutants); createStmts = sqlWriter.writeCreateTableStatements(metamutant); dropStmts = sqlWriter.writeDropTableStatements(metamutant, true); deleteStmts = sqlWriter.writeDeleteFromTableStatements(metamutant); // Build map of results this.resultMap = new HashMap<>(); for (int i = 0; i < mutants.size(); i++) { resultMap.put(i, new TestSuiteResult()); } // Execute test suite executeDropStmts(databaseInteractor); executeCreateStmts(databaseInteractor); for (TestCase testCase : testSuite.getTestCases()) { executeDeleteStmts(databaseInteractor); TestCaseResult normalTestResult = null; Map<Integer, TestCaseResult> failedMutants = new HashMap<>(); Data data = testCase.getState(); normalTestResult = executeInserts(data, normalTestResult, failedMutants, testCase); data = testCase.getData(); normalTestResult = executeInserts(data, normalTestResult, failedMutants, testCase); if (normalTestResult == null) { for (int i = 0; i < mutants.size(); i++) { if (!failedMutants.containsKey(i)) { resultMap.get(i).add(testCase, TestCaseResult.SuccessfulTestCaseResult); } } } } // Build the TestSuiteResult objects for (int i = 0; i < mutants.size(); i++) { TestSuiteResult mutantResult = resultMap.get(i); if (!originalResults.equals(mutantResult)) { result.addKilled(mutants.get(i)); } else { result.addLive(mutants.get(i)); } } executeDropStmts(databaseInteractor); return result; }