@Test public void testAggregateAndReinitialize() throws InterruptedException { RunMapImpl secondRunMap = new RunMapImpl(); AbstractTest test1 = new MockTest(); AbstractTest test2 = new MockTest(); runMap.record(createTestResult(test1, TestResult.Status.PASSED)); runMap.record(createTestResult(test1, TestResult.Status.FAILED)); runMap.record(createTestResult(test1, TestResult.Status.SKIPPED)); runMap.record(createTestResult(test2, TestResult.Status.PASSED)); runMap.record(createTestResult(test2, TestResult.Status.FAILED)); runMap.record(createTestResult(test2, TestResult.Status.SKIPPED)); secondRunMap.record(createTestResult(test1, TestResult.Status.PASSED)); secondRunMap.record(createTestResult(test1, TestResult.Status.FAILED)); secondRunMap.record(createTestResult(test1, TestResult.Status.SKIPPED)); secondRunMap.record(createTestResult(test2, TestResult.Status.PASSED)); secondRunMap.record(createTestResult(test2, TestResult.Status.FAILED)); secondRunMap.record(createTestResult(test2, TestResult.Status.SKIPPED)); runMap.aggregateAndReinitialize(secondRunMap); Assert.assertEquals(2, runMap.getTests().size()); Assert.assertTrue(runMap.getTests().contains(test1)); Assert.assertTrue(runMap.getTests().contains(test2)); Assert.assertEquals(2, runMap.getRecord(test1).getTotalRuns()); Assert.assertEquals(2, runMap.getRecord(test1).getSkippedRuns()); Assert.assertEquals(2, runMap.getRecord(test1).getFailRuns()); Assert.assertEquals(2, runMap.getRecord(test2).getTotalRuns()); Assert.assertEquals(2, runMap.getRecord(test2).getSkippedRuns()); Assert.assertEquals(2, runMap.getRecord(test2).getFailRuns()); Assert.assertEquals(0, secondRunMap.getRecord(test1).getTotalRuns()); Assert.assertEquals(0, secondRunMap.getRecord(test1).getSkippedRuns()); Assert.assertEquals(0, secondRunMap.getRecord(test1).getFailRuns()); Assert.assertEquals(0, secondRunMap.getRecord(test2).getTotalRuns()); Assert.assertEquals(0, secondRunMap.getRecord(test2).getSkippedRuns()); Assert.assertEquals(0, secondRunMap.getRecord(test2).getFailRuns()); Assert.assertEquals(12, runMap.getCurrentTestResults().size()); Assert.assertEquals(0, secondRunMap.getCurrentTestResults().size()); }
public Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap) { RunMapImpl other = (RunMapImpl) otherRunmap; other.testResultsLock.writeLock().lock(); try { this.testResultsLock.writeLock().lock(); try { TestResult testResult = other.currentTestResults.poll(); while (testResult != null) { this.currentTestResults.add(testResult); testResult = other.currentTestResults.poll(); } } finally { this.testResultsLock.writeLock().unlock(); } } finally { other.testResultsLock.writeLock().unlock(); } this.runMapLock.writeLock().lock(); try { other.runMapLock.writeLock().lock(); try { Map<AbstractTest, Long> counts = new HashMap<>(); synchronized (orderedTests) { for (AbstractTest test : other.orderedTests) { TestEntry otherEntry = other.runMap.get(test); TestEntry thisEntry = this.runMap.get(test); if (thisEntry == null) { addTest(test.clone()); thisEntry = this.runMap.get(test); } long count = thisEntry.aggregateAndReinitialize(otherEntry); counts.put(test, count); } } return counts; } finally { other.runMapLock.writeLock().unlock(); } } finally { this.runMapLock.writeLock().unlock(); } }
RunMapImpl implements RunMap { public Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap) { RunMapImpl other = (RunMapImpl) otherRunmap; other.testResultsLock.writeLock().lock(); try { this.testResultsLock.writeLock().lock(); try { TestResult testResult = other.currentTestResults.poll(); while (testResult != null) { this.currentTestResults.add(testResult); testResult = other.currentTestResults.poll(); } } finally { this.testResultsLock.writeLock().unlock(); } } finally { other.testResultsLock.writeLock().unlock(); } this.runMapLock.writeLock().lock(); try { other.runMapLock.writeLock().lock(); try { Map<AbstractTest, Long> counts = new HashMap<>(); synchronized (orderedTests) { for (AbstractTest test : other.orderedTests) { TestEntry otherEntry = other.runMap.get(test); TestEntry thisEntry = this.runMap.get(test); if (thisEntry == null) { addTest(test.clone()); thisEntry = this.runMap.get(test); } long count = thisEntry.aggregateAndReinitialize(otherEntry); counts.put(test, count); } } return counts; } finally { other.runMapLock.writeLock().unlock(); } } finally { this.runMapLock.writeLock().unlock(); } } }
RunMapImpl implements RunMap { public Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap) { RunMapImpl other = (RunMapImpl) otherRunmap; other.testResultsLock.writeLock().lock(); try { this.testResultsLock.writeLock().lock(); try { TestResult testResult = other.currentTestResults.poll(); while (testResult != null) { this.currentTestResults.add(testResult); testResult = other.currentTestResults.poll(); } } finally { this.testResultsLock.writeLock().unlock(); } } finally { other.testResultsLock.writeLock().unlock(); } this.runMapLock.writeLock().lock(); try { other.runMapLock.writeLock().lock(); try { Map<AbstractTest, Long> counts = new HashMap<>(); synchronized (orderedTests) { for (AbstractTest test : other.orderedTests) { TestEntry otherEntry = other.runMap.get(test); TestEntry thisEntry = this.runMap.get(test); if (thisEntry == null) { addTest(test.clone()); thisEntry = this.runMap.get(test); } long count = thisEntry.aggregateAndReinitialize(otherEntry); counts.put(test, count); } } return counts; } finally { other.runMapLock.writeLock().unlock(); } } finally { this.runMapLock.writeLock().unlock(); } } RunMapImpl(); private  RunMapImpl(List<AbstractTest> orderedTests); }
RunMapImpl implements RunMap { public Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap) { RunMapImpl other = (RunMapImpl) otherRunmap; other.testResultsLock.writeLock().lock(); try { this.testResultsLock.writeLock().lock(); try { TestResult testResult = other.currentTestResults.poll(); while (testResult != null) { this.currentTestResults.add(testResult); testResult = other.currentTestResults.poll(); } } finally { this.testResultsLock.writeLock().unlock(); } } finally { other.testResultsLock.writeLock().unlock(); } this.runMapLock.writeLock().lock(); try { other.runMapLock.writeLock().lock(); try { Map<AbstractTest, Long> counts = new HashMap<>(); synchronized (orderedTests) { for (AbstractTest test : other.orderedTests) { TestEntry otherEntry = other.runMap.get(test); TestEntry thisEntry = this.runMap.get(test); if (thisEntry == null) { addTest(test.clone()); thisEntry = this.runMap.get(test); } long count = thisEntry.aggregateAndReinitialize(otherEntry); counts.put(test, count); } } return counts; } finally { other.runMapLock.writeLock().unlock(); } } finally { this.runMapLock.writeLock().unlock(); } } RunMapImpl(); private  RunMapImpl(List<AbstractTest> orderedTests); void addTest(AbstractTest test); TestStatistics getRecord(AbstractTest test); Collection<TestResult> getCurrentTestResults(); Collection<AbstractTest> getTests(); void record(TestResult testResult); Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap); void reinitialize(); void reinitStartTimes(); void clearCurrentTestResults(); RunMap newInstance(); }
RunMapImpl implements RunMap { public Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap) { RunMapImpl other = (RunMapImpl) otherRunmap; other.testResultsLock.writeLock().lock(); try { this.testResultsLock.writeLock().lock(); try { TestResult testResult = other.currentTestResults.poll(); while (testResult != null) { this.currentTestResults.add(testResult); testResult = other.currentTestResults.poll(); } } finally { this.testResultsLock.writeLock().unlock(); } } finally { other.testResultsLock.writeLock().unlock(); } this.runMapLock.writeLock().lock(); try { other.runMapLock.writeLock().lock(); try { Map<AbstractTest, Long> counts = new HashMap<>(); synchronized (orderedTests) { for (AbstractTest test : other.orderedTests) { TestEntry otherEntry = other.runMap.get(test); TestEntry thisEntry = this.runMap.get(test); if (thisEntry == null) { addTest(test.clone()); thisEntry = this.runMap.get(test); } long count = thisEntry.aggregateAndReinitialize(otherEntry); counts.put(test, count); } } return counts; } finally { other.runMapLock.writeLock().unlock(); } } finally { this.runMapLock.writeLock().unlock(); } } RunMapImpl(); private  RunMapImpl(List<AbstractTest> orderedTests); void addTest(AbstractTest test); TestStatistics getRecord(AbstractTest test); Collection<TestResult> getCurrentTestResults(); Collection<AbstractTest> getTests(); void record(TestResult testResult); Map<AbstractTest, Long> aggregateAndReinitialize(RunMap otherRunmap); void reinitialize(); void reinitStartTimes(); void clearCurrentTestResults(); RunMap newInstance();  }