CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef);
+ CloseableIterator<BatchReport.DuplicationBlock> readComponentDuplicationBlocks(int componentRef);
+
CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef);
CloseableIterator<BatchReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef);
return delegate.readComponentDuplications(componentRef);
}
+ @Override
+ public CloseableIterator<BatchReport.DuplicationBlock> readComponentDuplicationBlocks(int componentRef) {
+ return delegate.readComponentDuplicationBlocks(componentRef);
+ }
+
@Override
public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) {
return delegate.readComponentSymbols(componentRef);
private static final BatchReport.Component COMPONENT = BatchReport.Component.newBuilder().setRef(COMPONENT_REF).build();
private static final BatchReport.Issue ISSUE = BatchReport.Issue.newBuilder().build();
private static final BatchReport.Duplication DUPLICATION = BatchReport.Duplication.newBuilder().build();
+ private static final BatchReport.DuplicationBlock DUPLICATION_BLOCK = BatchReport.DuplicationBlock.newBuilder().build();
private static final BatchReport.Symbol SYMBOL = BatchReport.Symbol.newBuilder().build();
private static final BatchReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_1 = BatchReport.SyntaxHighlighting.newBuilder().build();
private static final BatchReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_2 = BatchReport.SyntaxHighlighting.newBuilder().build();
assertThat(underTest.readComponentDuplications(COMPONENT_REF)).isNotSameAs(underTest.readComponentDuplications(COMPONENT_REF));
}
+ @Test
+ public void readComponentDuplicationBlocks_returns_empty_list_if_file_does_not_exist() {
+ assertThat(underTest.readComponentDuplicationBlocks(COMPONENT_REF)).isEmpty();
+ }
+
+ @Test
+ public void verify_readComponentDuplicationBlocks_returns_Issues() {
+ writer.writeDuplicationBlocks(COMPONENT_REF, of(DUPLICATION_BLOCK));
+
+ try (CloseableIterator<BatchReport.DuplicationBlock> res = underTest.readComponentDuplicationBlocks(COMPONENT_REF)) {
+ assertThat(res.next()).isEqualTo(DUPLICATION_BLOCK);
+ assertThat(res.hasNext()).isFalse();
+ }
+ }
+
+ @Test
+ public void readComponentDuplicationBlocks_is_not_cached() {
+ writer.writeDuplicationBlocks(COMPONENT_REF, of(DUPLICATION_BLOCK));
+
+ assertThat(underTest.readComponentDuplicationBlocks(COMPONENT_REF)).isNotSameAs(underTest.readComponentDuplicationBlocks(COMPONENT_REF));
+ }
+
@Test
public void readComponentSymbols_returns_empty_list_if_file_does_not_exist() {
assertThat(underTest.readComponentSymbols(COMPONENT_REF)).isEmpty();
private Map<Integer, BatchReport.Component> components = new HashMap<>();
private Map<Integer, List<BatchReport.Issue>> issues = new HashMap<>();
private Map<Integer, List<BatchReport.Duplication>> duplications = new HashMap<>();
+ private Map<Integer, List<BatchReport.DuplicationBlock>> duplicationBlocks = new HashMap<>();
private Map<Integer, List<BatchReport.Symbol>> symbols = new HashMap<>();
private Map<Integer, List<BatchReport.SyntaxHighlighting>> syntaxHighlightings = new HashMap<>();
private Map<Integer, List<BatchReport.Coverage>> coverages = new HashMap<>();
this.components.clear();
this.issues.clear();
this.duplications.clear();
+ this.duplicationBlocks.clear();
this.symbols.clear();
this.syntaxHighlightings.clear();
this.coverages.clear();
this.duplications.put(componentRef, Arrays.asList(duplications));
}
+ @Override
+ public CloseableIterator<BatchReport.DuplicationBlock> readComponentDuplicationBlocks(int componentRef) {
+ return closeableIterator(this.duplicationBlocks.get(componentRef));
+ }
+
+ public void putDuplicationBlocks(int componentRef, List<BatchReport.DuplicationBlock> duplicationBlocks) {
+ this.duplicationBlocks.put(componentRef, duplicationBlocks);
+ }
+
@Override
public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) {
return closeableIterator(this.symbols.get(componentRef));