@Test public void shouldSummarizeStatisticsAfterCheck() { // given ConsistencySummaryStatistics summary = mock(ConsistencySummaryStatistics.class); ConsistencyReporter.ReportHandler handler = new ConsistencyReporter.ReportHandler( new InconsistencyReport(mock(InconsistencyLogger.class), summary), RecordType.PROPERTY, new PropertyRecord(0)); // when handler.updateSummary(); // then verify(summary).update(RecordType.PROPERTY, 0, 0); verifyNoMoreInteractions(summary); }
@Test public void shouldOnlySummarizeStatisticsWhenAllReferencesAreChecked() { // given ConsistencySummaryStatistics summary = mock(ConsistencySummaryStatistics.class); ConsistencyReporter.ReportHandler handler = new ConsistencyReporter.ReportHandler( new InconsistencyReport(mock(InconsistencyLogger.class), summary), RecordType.PROPERTY, new PropertyRecord(0)); ConsistencyReport.PropertyConsistencyReport report = (ConsistencyReport.PropertyConsistencyReport) Proxy.newProxyInstance( ConsistencyReport.PropertyConsistencyReport.class.getClassLoader(), new Class[] {ConsistencyReport.PropertyConsistencyReport.class}, handler); @SuppressWarnings("unchecked") RecordReference<PropertyRecord> reference = mock(RecordReference.class); @SuppressWarnings("unchecked") ComparativeRecordChecker< PropertyRecord, PropertyRecord, ConsistencyReport.PropertyConsistencyReport> checker = mock(ComparativeRecordChecker.class); handler.forReference(report, reference, checker); @SuppressWarnings("unchecked") ArgumentCaptor<PendingReferenceCheck<PropertyRecord>> captor = (ArgumentCaptor) ArgumentCaptor.forClass(PendingReferenceCheck.class); verify(reference).dispatch(captor.capture()); PendingReferenceCheck pendingRefCheck = captor.getValue(); // when handler.updateSummary(); // then verifyZeroInteractions(summary); // when pendingRefCheck.skip(); // then verify(summary).update(RecordType.PROPERTY, 0, 0); verifyNoMoreInteractions(summary); }