assertThat(duplication2.size()).isEqualTo(5);
}
@Test
public void compare_duplications() throws Exception {
ComponentDto currentFile = ComponentTesting.newFileDto(project1).setId(11L);
ComponentDto fileOnSameProject = ComponentTesting.newFileDto(project1).setId(12L);
ComponentDto fileOnDifferentProject = ComponentTesting.newFileDto(project2).setId(13L);
DuplicationsParser.DuplicationComparator comparator = new DuplicationsParser.DuplicationComparator(currentFile);
// On same file
assertThat(comparator.compare(new DuplicationsParser.Duplication(currentFile, 2, 2), new DuplicationsParser.Duplication(currentFile, 5, 2))).isEqualTo(-1);
// Different files on same project
assertThat(comparator.compare(new DuplicationsParser.Duplication(currentFile, 2, 2), new DuplicationsParser.Duplication(fileOnSameProject, 5, 2))).isEqualTo(-1);
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnSameProject, 2, 2), new DuplicationsParser.Duplication(currentFile, 5, 2))).isEqualTo(1);
// Different files on different projects
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnSameProject, 5, 2), new DuplicationsParser.Duplication(fileOnDifferentProject, 2, 2))).isEqualTo(-1);
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2), new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(1);
// Files on 2 different projects
ComponentDto project3 = ComponentTesting.newProjectDto().setId(3L);
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2),
new DuplicationsParser.Duplication(project3, 2, 2))).isEqualTo(1);
// With null duplications
assertThat(comparator.compare(null, new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(-1);