use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FileMoveDetectionStepTest method execute_detects_several_moves.
@Test
public void execute_detects_several_moves() {
// testing:
// - file1 renamed to file3
// - file2 deleted
// - file4 untouched
// - file5 renamed to file6 with a small change
analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
Component file4 = fileComponent(5);
Component file5 = fileComponent(6);
Component file6 = fileComponent(7);
ComponentDto[] dtos = mockComponents(FILE_1.getKey(), FILE_2.getKey(), file4.getKey(), file5.getKey());
mockContentOfFileInDb(FILE_1.getKey(), CONTENT1);
mockContentOfFileInDb(FILE_2.getKey(), LESS_CONTENT1);
mockContentOfFileInDb(file4.getKey(), new String[] { "e", "f", "g", "h", "i" });
mockContentOfFileInDb(file5.getKey(), CONTENT2);
setFilesInReport(FILE_3, file4, file6);
setFileContentInReport(FILE_3_REF, CONTENT1);
setFileContentInReport(file4.getReportAttributes().getRef(), new String[] { "a", "b" });
setFileContentInReport(file6.getReportAttributes().getRef(), LESS_CONTENT2);
underTest.execute();
assertThat(movedFilesRepository.getComponentsWithOriginal()).containsOnly(FILE_3, file6);
MovedFilesRepository.OriginalFile originalFile2 = movedFilesRepository.getOriginalFile(FILE_3).get();
assertThat(originalFile2.getId()).isEqualTo(dtos[0].getId());
assertThat(originalFile2.getKey()).isEqualTo(dtos[0].getKey());
assertThat(originalFile2.getUuid()).isEqualTo(dtos[0].uuid());
MovedFilesRepository.OriginalFile originalFile5 = movedFilesRepository.getOriginalFile(file6).get();
assertThat(originalFile5.getId()).isEqualTo(dtos[3].getId());
assertThat(originalFile5.getKey()).isEqualTo(dtos[3].getKey());
assertThat(originalFile5.getUuid()).isEqualTo(dtos[3].uuid());
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class MutableMovedFilesRepositoryImplTest method setOriginalFile_throws_IAE_when_type_is_no_FILE.
@Test
public void setOriginalFile_throws_IAE_when_type_is_no_FILE() {
for (Component component : COMPONENTS_BUT_FILE) {
try {
underTest.setOriginalFile(component, SOME_ORIGINAL_FILE);
fail("should have raised a NPE");
} catch (IllegalArgumentException e) {
assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("file must be of type FILE");
}
}
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class MutableMovedFilesRepositoryImplTest method getOriginalFile_returns_absent_for_any_type_of_Component_but_file_when_non_empty.
@Test
public void getOriginalFile_returns_absent_for_any_type_of_Component_but_file_when_non_empty() {
underTest.setOriginalFile(SOME_FILE, SOME_ORIGINAL_FILE);
for (Component component : COMPONENTS_BUT_FILE) {
assertThat(underTest.getOriginalFile(component)).isAbsent();
}
assertThat(underTest.getOriginalFile(SOME_FILE)).contains(SOME_ORIGINAL_FILE);
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DuplicationRepositoryImplTest method mockComponentGetType.
private Component mockComponentGetType(Component.Type type) {
Component component = mock(Component.class);
when(component.getType()).thenReturn(type);
return component;
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DuplicationRepositoryImplTest method addDuplication_inner_throws_IAE_if_file_type_is_not_FILE.
@Test
@UseDataProvider("allComponentTypesButFile")
public void addDuplication_inner_throws_IAE_if_file_type_is_not_FILE(Component.Type type) {
expectFileTypeIAE();
Component component = mockComponentGetType(type);
underTest.add(component, SOME_DUPLICATION);
}
Aggregations